예제 #1
0
        private GuiWidget CreateBodyWidgets(ProductTour productTour)
        {
            var body = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Absolute,
                VAnchor = VAnchor.Fit,
            };

            body.AddChild(new WrappedTextWidget(productTour.ActiveItem.Description, textColor: theme.TextColor, pointSize: theme.DefaultFontSize)
            {
                Margin  = 5,
                HAnchor = HAnchor.Stretch
            });

            var buttonRow = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.Stretch,
                Margin  = new BorderDouble(0, 0, 0, 5)
            };

            body.AddChild(buttonRow);

            var prevButton = new ArrowButton("Prev".Localize(), ArrowDirection.Left, theme, pointSize: theme.DefaultFontSize - 2)
            {
                Height  = theme.ButtonHeight - 4,
                Padding = theme.TextButtonPadding.Clone(left: theme.TextButtonPadding.Left + 8)
            };

            prevButton.Click += (s, e) =>
            {
                this.Parent.Close();
                productTour.ShowPrevious();
            };
            buttonRow.AddChild(prevButton);

            buttonRow.AddChild(new HorizontalSpacer());

            buttonRow.AddChild(new CarouselIndicators(productTour, theme));

            buttonRow.AddChild(new HorizontalSpacer());

            var nextButton = new ArrowButton("Next".Localize(), ArrowDirection.Right, theme, pointSize: theme.DefaultFontSize - 2)
            {
                Height  = theme.ButtonHeight - 4,
                Padding = theme.TextButtonPadding.Clone(right: theme.TextButtonPadding.Right + 8)
            };

            nextButton.Click += (s, e) =>
            {
                this.Parent.Close();

                productTour.ShowNext();
            };
            buttonRow.AddChild(nextButton);

            body.Size = new Vector2(280, body.Height);

            return(body);
        }
예제 #2
0
        public TourOverlay(ProductTour productTour, ThemeConfig theme)
        {
            this.theme       = theme;
            this.productTour = productTour;

            this.HAnchor = HAnchor.Stretch;
            this.VAnchor = VAnchor.Stretch;
        }
예제 #3
0
        public TourOverlay(SystemWindow tourWindow, ProductTour productTour, ThemeConfig theme)
        {
            this.tourWindow  = tourWindow;
            this.theme       = theme;
            this.productTour = productTour;

            this.HAnchor = HAnchor.Stretch;
            this.VAnchor = VAnchor.Stretch;
        }
예제 #4
0
        public CarouselIndicators(ProductTour productTour, ThemeConfig theme)
        {
            this.Tour  = productTour;
            this.theme = theme;

            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit | VAnchor.Center;

            this.InactiveColor  = theme.SlightShade;
            this.ActiveColor    = theme.PrimaryAccentColor;
            this.HighlightColor = theme.PrimaryAccentColor;

            for (var i = 0; i < productTour.Count; i++)
            {
                this.AddChild(new StepIndicator(this, i)
                {
                    //ToolTipText = productTour.Locations[i].Widget.Name ?? ""
                });
            }
        }
예제 #5
0
        public static async void StartTour()
        {
            var topWindow = ApplicationController.Instance.MainView.TopmostParent() as SystemWindow;

            var tourLocations = await ApplicationController.Instance.LoadProductTour();

            // Finding matching widgets by name
            var visibleTourWidgets = topWindow.FindDescendants(tourLocations.Select(t => t.WidgetName));

            // Filter to on-screen items
            var visibleTourItems = tourLocations.Where(t =>
            {
                var widget = visibleTourWidgets.FirstOrDefault(w => w.Name == t.WidgetName && w.Widget.ActuallyVisibleOnScreen());

                // Update widget reference on tour object
                t.Widget = widget?.Widget;

                return(widget != null);
            });

            var productTour = new ProductTour(topWindow, visibleTourItems.ToList(), ApplicationController.Instance.Theme);

            productTour.ShowNext();
        }
예제 #6
0
        public TourPopover(ProductTour productTour, ThemeConfig theme, RectangleDouble targetBounds)
            : base(ArrowDirection.Left, 0, 7, 0)
        {
            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit;
            this.theme   = theme;

            var targetWidget = productTour.ActiveItem.Widget;

            var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Fit,
                VAnchor = VAnchor.Fit
            };

            this.AddChild(column);

            var row = new GuiWidget()
            {
                Margin  = new BorderDouble(5),
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Fit
            };

            column.AddChild(row);

            var title = new TextWidget(productTour.ActiveItem.Title, pointSize: theme.DefaultFontSize, textColor: theme.PrimaryAccentColor)
            {
                HAnchor = HAnchor.Left,
                Margin  = new BorderDouble(top: 4, left: 4),
                VAnchor = VAnchor.Center,
            };

            row.AddChild(title);

            var closeButton = theme.CreateSmallResetButton();

            closeButton.HAnchor = HAnchor.Right;
            closeButton.VAnchor = VAnchor.Top;
            closeButton.Margin  = 0;
            closeButton.Click  += (s, e) =>
            {
                this.Parent.CloseOnIdle();
            };

            row.AddChild(closeButton);

            var body = this.CreateBodyWidgets(productTour);

            body.Padding = new BorderDouble(theme.DefaultContainerPadding).Clone(top: 0);
            column.AddChild(body);

            var totalWidth  = this.Width + this.DeviceMarginAndBorder.Width;
            var totalHeight = this.Height + this.DeviceMarginAndBorder.Height;

            var totalBounds = new RectangleDouble(0, 0, totalWidth, totalHeight);

            var targetCenterX = targetWidget.Width / 2;
            var targetCenterY = targetWidget.Height / 2;

            if (targetBounds.Right >= totalBounds.Width)
            {
                if (targetBounds.Bottom < totalBounds.Height / 2)
                {
                    if (targetBounds.Bottom - totalBounds.Height < 0)
                    {
                        // Down arrow
                        this.ArrowDirection = ArrowDirection.Down;

                        // Arrow centered on target in x, to the right
                        totalBounds      = this.GetTotalBounds();
                        this.ArrowOffset = (int)(totalBounds.Right - targetCenterX);

                        // Popover positioned above target, aligned right
                        this.Position = new Vector2(
                            this.LeftForAlignTargetRight(targetBounds.Right, totalBounds),
                            targetBounds.Top + 1);
                    }
                    else
                    {
                        // Right arrow
                        this.ArrowDirection = ArrowDirection.Right;

                        //  Arrow centered on target in y, to the top
                        totalBounds      = this.GetTotalBounds();
                        this.ArrowOffset = (int)(totalBounds.Height - targetCenterY);

                        // Popover positioned left of target, aligned top
                        this.Position = new Vector2(
                            this.LeftForAlignTargetRight(targetBounds.Right, totalBounds),
                            targetBounds.Top - totalBounds.Height);
                    }
                }
                else
                {
                    // Up arrow
                    this.ArrowDirection = ArrowDirection.Up;

                    // Arrow centered on target in x, to the right
                    totalBounds      = this.GetTotalBounds();
                    this.ArrowOffset = (int)(totalBounds.Right - targetCenterX);

                    // Popover positioned below target, aligned right
                    this.Position = new Vector2(
                        this.LeftForAlignTargetRight(targetBounds.Right, totalBounds),
                        targetBounds.Bottom - totalBounds.Height - 1);
                }
            }
            else
            {
                if (targetBounds.Bottom < totalBounds.Height)
                {
                    // Left arrow
                    this.ArrowDirection = ArrowDirection.Left;

                    // Arrow centered on target in y (or top - 20 if target larger than content)
                    totalBounds = this.GetTotalBounds();
                    if (targetWidget.Height > totalBounds.Height)
                    {
                        this.ArrowOffset = 20;
                    }
                    else
                    {
                        this.ArrowOffset = (int)targetCenterY;
                    }

                    // Popover positioned right of target, aligned top
                    this.Position = new Vector2(
                        targetBounds.Right + 1,
                        targetBounds.Top - totalBounds.Height);
                }
                else
                {
                    this.ArrowDirection = ArrowDirection.Up;

                    // Arrow centered on target in x, to the left
                    totalBounds      = this.GetTotalBounds();
                    this.ArrowOffset = (int)targetCenterX;

                    // Popover positioned below target, aligned left
                    this.Position = new Vector2(
                        targetBounds.Left,
                        targetBounds.Bottom - totalBounds.Height - 1);
                }
            }

            this.TagColor = theme.ResolveColor(theme.BackgroundColor, theme.AccentMimimalOverlay.WithAlpha(50));

            this.RebuildShape();
        }