Exemple #1
0
        public DrawVisualiser()
        {
            RelativeSizeAxes = Axes.Both;
            Children         = new Drawable[]
            {
                overlay       = new InfoOverlay(),
                treeContainer = new TreeContainer
                {
                    ChooseTarget  = chooseTarget,
                    GoUpOneParent = delegate
                    {
                        Drawable lastHighlight = highlightedTarget?.Target;

                        var parent = Target?.Parent;
                        if (parent?.Parent != null)
                        {
                            Target = Target?.Parent;
                        }

                        // Rehighlight the last highlight
                        if (lastHighlight != null)
                        {
                            VisualisedDrawable visualised = findVisualised(lastHighlight, targetDrawable);
                            if (visualised != null)
                            {
                                propertyDisplay.State = Visibility.Visible;
                                setHighlight(visualised);
                            }
                        }
                    },
                    ToggleProperties = delegate
                    {
                        if (targetDrawable == null)
                        {
                            return;
                        }

                        propertyDisplay.ToggleVisibility();

                        if (propertyDisplay.State == Visibility.Visible)
                        {
                            setHighlight(targetDrawable);
                        }
                    },
                },
                new CursorContainer()
            };

            propertyDisplay = treeContainer.PropertyDisplay;

            propertyDisplay.StateChanged += (display, visibility) =>
            {
                switch (visibility)
                {
                case Visibility.Hidden:
                    // Dehighlight everything automatically if property display is closed
                    setHighlight(null);
                    break;
                }
            };
        }
        public DrawVisualiser()
        {
            RelativeSizeAxes = Axes.Both;
            Children         = new Drawable[]
            {
                overlay       = new InfoOverlay(),
                treeContainer = new TreeContainer
                {
                    State        = { BindTarget = State },
                    ChooseTarget = () =>
                    {
                        Searching = true;
                        Target    = null;
                    },
                    GoUpOneParent = delegate
                    {
                        Drawable lastHighlight = highlightedTarget?.Target;

                        var parent = Target?.Parent;

                        if (parent != null)
                        {
                            var lastVisualiser = targetVisualiser;

                            Target = parent;
                            lastVisualiser.SetContainer(targetVisualiser);

                            targetVisualiser.Expand();
                        }

                        // Rehighlight the last highlight
                        if (lastHighlight != null)
                        {
                            VisualisedDrawable visualised = targetVisualiser.FindVisualisedDrawable(lastHighlight);

                            if (visualised != null)
                            {
                                propertyDisplay.Show();
                                setHighlight(visualised);
                            }
                        }
                    },
                    ToggleProperties = delegate
                    {
                        if (targetVisualiser == null)
                        {
                            return;
                        }

                        propertyDisplay.ToggleVisibility();

                        if (propertyDisplay.State.Value == Visibility.Visible)
                        {
                            setHighlight(targetVisualiser);
                        }
                    },
                },
                new CursorContainer()
            };

            propertyDisplay = treeContainer.PropertyDisplay;

            propertyDisplay.State.ValueChanged += v =>
            {
                switch (v.NewValue)
                {
                case Visibility.Hidden:
                    // Dehighlight everything automatically if property display is closed
                    setHighlight(null);
                    break;
                }
            };
        }