예제 #1
0
        private void HandleRefresh(object sender, ExecutedRoutedEventArgs e)
        {
            Cursor saveCursor = Mouse.OverrideCursor;

            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                object currentTarget = this.CurrentSelection != null ? this.CurrentSelection.Target : null;

                this.visualTreeItems.Clear();

                this.Root = VisualTreeItem.Construct(this.root, null);

                if (currentTarget != null)
                {
                    VisualTreeItem visualItem = this.FindItem(currentTarget);
                    if (visualItem != null)
                    {
                        this.CurrentSelection = visualItem;
                    }
                }

                this.SetFilter(this.filter);
            }
            finally
            {
                Mouse.OverrideCursor = saveCursor;
            }
        }
예제 #2
0
        protected override void Reload(List <VisualTreeItem> toBeRemoved)
        {
            // having the call to base.Reload here ... puts the application resources at the very top of the tree view
            base.Reload(toBeRemoved);

            // what happens in the case where the application's main window is invisible?
            // in this case, the application will only have one visual item underneath it: the collapsed/hidden window.
            // however, you are still able to ctrl-shift mouse over the visuals in the visible window.
            // when you do this, snoop reloads the visual tree with the visible window as the root (versus the application).

            if (this.application.MainWindow != null)
            {
                bool foundMainWindow = false;
                foreach (VisualTreeItem item in toBeRemoved)
                {
                    if (item.Target == this.application.MainWindow)
                    {
                        toBeRemoved.Remove(item);
                        item.Reload();
                        foundMainWindow = true;
                        break;
                    }
                }

                if (!foundMainWindow)
                {
                    this.Children.Add(VisualTreeItem.Construct(this.application.MainWindow, this));
                }
            }
        }
예제 #3
0
        protected override void Reload(List <VisualTreeItem> toBeRemoved)
        {
            // having the call to base.Reload here ... puts the application resources at the very top of the tree view
            base.Reload(toBeRemoved);

            foreach (Window window in this.application.Windows)
            {
                if (window.IsInitialized == false ||
                    window.CheckAccess() == false)
                {
                    continue;
                }

                // windows which have an owner are added as child items in VisualItem, so we have to skip them here
                if (window.Owner != null)
                {
                    continue;
                }

                // don't recreate existing items but reload them instead
                var existingItem = toBeRemoved.FirstOrDefault(x => ReferenceEquals(x.Target, window));
                if (existingItem != null)
                {
                    toBeRemoved.Remove(existingItem);
                    existingItem.Reload();
                    continue;
                }

                this.Children.Add(VisualTreeItem.Construct(window, this));
            }
        }
        protected override void Reload(List <VisualTreeItem> toBeRemoved)
        {
            base.Reload(toBeRemoved);

            ResourceDictionary resources = this.ResourceDictionary;

            if (resources != null && resources.Count != 0)
            {
                bool foundItem = false;
                foreach (VisualTreeItem item in toBeRemoved)
                {
                    if (item.Target == resources)
                    {
                        toBeRemoved.Remove(item);
                        item.Reload();
                        foundItem = true;
                        break;
                    }
                }
                if (!foundItem)
                {
                    this.Children.Add(VisualTreeItem.Construct(resources, this));
                }
            }
        }
예제 #5
0
        void Load(object root)
        {
            this.root = root;

            Root             = VisualTreeItem.Construct(root, null);
            CurrentSelection = rootVisualTreeItem;

            OnPropertyChanged("Root");
        }
예제 #6
0
        private void Load(object root)
        {
            this.root = root;

            this.visualTreeItems.Clear();

            this.Root             = VisualTreeItem.Construct(root, null);
            this.CurrentSelection = this.rootVisualTreeItem;

            this.SetFilter(this.filter);

            this.OnPropertyChanged("Root");
        }
예제 #7
0
        protected override void Reload(List <VisualTreeItem> toBeRemoved)
        {
            // having the call to base.Reload here ... puts the application resources at the very top of the tree view.
            // this used to be at the bottom. putting it here makes it consistent (and easier to use) with ApplicationTreeItem
            base.Reload(toBeRemoved);

            // remove items that are no longer in tree, add new ones.
            for (int i = 0; i < CommonTreeHelper.GetChildrenCount(this.Visual); i++)
            {
                object child = CommonTreeHelper.GetChild(this.Visual, i);
                if (child != null)
                {
                    bool foundItem = false;
                    foreach (VisualTreeItem item in toBeRemoved)
                    {
                        if (item.Target == child)
                        {
                            toBeRemoved.Remove(item);
                            item.Reload();
                            foundItem = true;
                            break;
                        }
                    }
                    if (!foundItem)
                    {
                        this.Children.Add(VisualTreeItem.Construct(child, this));
                    }
                }
            }

            Grid grid = this.Visual as Grid;

            if (grid != null)
            {
                foreach (RowDefinition row in grid.RowDefinitions)
                {
                    this.Children.Add(VisualTreeItem.Construct(row, this));
                }
                foreach (ColumnDefinition column in grid.ColumnDefinitions)
                {
                    this.Children.Add(VisualTreeItem.Construct(column, this));
                }
            }
        }
예제 #8
0
        void HandleRefresh(object sender, ExecutedRoutedEventArgs e)
        {
            var saveCursor = Mouse.OverrideCursor;

            Mouse.OverrideCursor = Cursors.Wait;
            try {
                var currentTarget = CurrentSelection != null ? CurrentSelection.Target : null;

                Root = VisualTreeItem.Construct(root, null);

                if (currentTarget != null)
                {
                    var visualItem = FindItem(currentTarget);
                    if (visualItem != null)
                    {
                        CurrentSelection = visualItem;
                    }
                }
            }
            finally {
                Mouse.OverrideCursor = saveCursor;
            }
        }
예제 #9
0
        protected override void Reload(List <VisualTreeItem> toBeRemoved)
        {
            // having the call to base.Reload here ... puts the application resources at the very top of the tree view.
            // this used to be at the bottom. putting it here makes it consistent (and easier to use) with ApplicationTreeItem
            base.Reload(toBeRemoved);

            var window = this.Visual as Window;

            if (window != null)
            {
                foreach (Window ownedWindow in window.OwnedWindows)
                {
                    if (ownedWindow.CheckAccess() == false)
                    {
                        continue;
                    }

                    // don't recreate existing items but reload them instead
                    var existingItem = toBeRemoved.FirstOrDefault(x => ReferenceEquals(x.Target, ownedWindow));
                    if (existingItem != null)
                    {
                        toBeRemoved.Remove(existingItem);
                        existingItem.Reload();
                        continue;
                    }

                    this.Children.Add(VisualTreeItem.Construct(ownedWindow, this));
                }
            }

            // remove items that are no longer in tree, add new ones.
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(this.Visual); i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(this.Visual, i);
                if (child != null)
                {
                    bool foundItem = false;
                    foreach (VisualTreeItem item in toBeRemoved)
                    {
                        if (item.Target == child)
                        {
                            toBeRemoved.Remove(item);
                            item.Reload();
                            foundItem = true;
                            break;
                        }
                    }
                    if (!foundItem)
                    {
                        this.Children.Add(VisualTreeItem.Construct(child, this));
                    }
                }
            }

            Grid grid = this.Visual as Grid;

            if (grid != null)
            {
                foreach (RowDefinition row in grid.RowDefinitions)
                {
                    this.Children.Add(VisualTreeItem.Construct(row, this));
                }
                foreach (ColumnDefinition column in grid.ColumnDefinitions)
                {
                    this.Children.Add(VisualTreeItem.Construct(column, this));
                }
            }
        }