2018-11-27 18:15:17 -08:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2018, Lars Brubaker, John Lewin
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-12-30 10:04:25 -08:00
|
|
|
|
using System;
|
2018-11-27 18:15:17 -08:00
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Agg.VertexSource;
|
|
|
|
|
|
using MatterHackers.MatterControl;
|
2018-12-11 23:29:23 -08:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2018-11-27 18:15:17 -08:00
|
|
|
|
|
2018-12-30 10:53:02 -08:00
|
|
|
|
namespace MatterHackers.MatterControl.Tour
|
2018-11-27 18:15:17 -08:00
|
|
|
|
{
|
|
|
|
|
|
public class TourOverlay : GuiWidget
|
|
|
|
|
|
{
|
2018-12-30 09:05:08 -08:00
|
|
|
|
private ProductTour productTour;
|
2018-12-28 16:37:33 -08:00
|
|
|
|
private Popover popover;
|
2018-11-28 11:54:18 -08:00
|
|
|
|
private ThemeConfig theme;
|
2018-12-30 10:04:25 -08:00
|
|
|
|
private RectangleDouble targetBounds;
|
2018-11-28 11:54:18 -08:00
|
|
|
|
|
2020-07-22 08:05:39 -07:00
|
|
|
|
public TourOverlay(ProductTour productTour, ThemeConfig theme)
|
2018-11-27 18:15:17 -08:00
|
|
|
|
{
|
2018-11-28 11:54:18 -08:00
|
|
|
|
this.theme = theme;
|
2018-12-30 09:05:08 -08:00
|
|
|
|
this.productTour = productTour;
|
2018-11-27 18:15:17 -08:00
|
|
|
|
|
2018-12-11 20:14:06 -08:00
|
|
|
|
this.HAnchor = HAnchor.Stretch;
|
|
|
|
|
|
this.VAnchor = VAnchor.Stretch;
|
2018-11-27 18:15:17 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-28 16:37:33 -08:00
|
|
|
|
public override void OnDraw(Graphics2D graphics2D)
|
|
|
|
|
|
{
|
2018-12-30 10:04:25 -08:00
|
|
|
|
targetBounds = this.GetTargetBounds(productTour.ActiveItem.Widget);
|
|
|
|
|
|
|
2018-12-28 16:37:33 -08:00
|
|
|
|
var dimRegion = new VertexStorage();
|
|
|
|
|
|
dimRegion.MoveTo(LocalBounds.Left, LocalBounds.Bottom);
|
|
|
|
|
|
dimRegion.LineTo(LocalBounds.Right, LocalBounds.Bottom);
|
|
|
|
|
|
dimRegion.LineTo(LocalBounds.Right, LocalBounds.Top);
|
|
|
|
|
|
dimRegion.LineTo(LocalBounds.Left, LocalBounds.Top);
|
|
|
|
|
|
|
|
|
|
|
|
var targetRect = new VertexStorage();
|
|
|
|
|
|
targetRect.MoveTo(targetBounds.Right, targetBounds.Bottom);
|
|
|
|
|
|
targetRect.LineTo(targetBounds.Left, targetBounds.Bottom);
|
|
|
|
|
|
targetRect.LineTo(targetBounds.Left, targetBounds.Top);
|
|
|
|
|
|
targetRect.LineTo(targetBounds.Right, targetBounds.Top);
|
|
|
|
|
|
|
|
|
|
|
|
var overlayMinusTargetRect = new CombinePaths(dimRegion, targetRect);
|
|
|
|
|
|
graphics2D.Render(overlayMinusTargetRect, new Color(Color.Black, 180));
|
|
|
|
|
|
|
|
|
|
|
|
base.OnDraw(graphics2D);
|
|
|
|
|
|
|
2018-12-30 10:04:25 -08:00
|
|
|
|
graphics2D.Render(new Stroke(new RoundedRect(targetBounds, 0), 2), Color.White.WithAlpha(50));
|
2020-07-22 08:05:39 -07:00
|
|
|
|
// graphics2D.Render(new Stroke(new RoundedRect(GetContentBounds(), 3), 4), theme.PrimaryAccentColor);
|
2018-12-28 16:37:33 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnKeyDown(KeyEventArgs keyEvent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (keyEvent.KeyCode == Keys.Escape)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (keyEvent.KeyCode == Keys.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
var topWindow = this.TopmostParent();
|
|
|
|
|
|
this.Close();
|
2018-12-30 09:05:08 -08:00
|
|
|
|
|
|
|
|
|
|
productTour.ShowNext();
|
2018-12-28 16:37:33 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.OnKeyDown(keyEvent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-27 18:15:17 -08:00
|
|
|
|
public override void OnLoad(EventArgs args)
|
|
|
|
|
|
{
|
2018-12-30 10:04:25 -08:00
|
|
|
|
popover = new TourPopover(productTour, theme, this.GetTargetBounds(productTour.ActiveItem.Widget));
|
2018-12-12 14:26:55 -08:00
|
|
|
|
this.AddChild(popover);
|
|
|
|
|
|
|
|
|
|
|
|
this.Focus();
|
|
|
|
|
|
|
|
|
|
|
|
base.OnLoad(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-30 10:04:25 -08:00
|
|
|
|
private RectangleDouble GetTargetBounds(GuiWidget widget)
|
2018-11-27 18:15:17 -08:00
|
|
|
|
{
|
2018-12-30 10:04:25 -08:00
|
|
|
|
var childBounds = widget.TransformToScreenSpace(widget.LocalBounds);
|
2018-12-11 20:14:06 -08:00
|
|
|
|
return this.TransformFromScreenSpace(childBounds);
|
2018-11-27 18:15:17 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-12-28 16:37:33 -08:00
|
|
|
|
}
|