Пример #1
0
        protected override void Reload(List <ElementTreeItem> toBeRemoved)
        {
            base.Reload(toBeRemoved);

            ResourceDictionary resources = ResourceDictionary;

            if (resources != null && resources.Count != 0)
            {
                bool foundItem = false;
                foreach (ElementTreeItem item in toBeRemoved)
                {
                    if (item.Target == resources)
                    {
                        toBeRemoved.Remove(item);
                        item.Reload();
                        foundItem = true;
                        break;
                    }
                }
                if (!foundItem)
                {
                    Children.Add(ElementTreeItem.Construct(resources, this));
                }
            }
        }
Пример #2
0
 public void Inspect(object target)
 {
     _rootObject = target;
     Load(target);
     SelectedItem = _root;
     OnPropertyChanged("Root");
 }
Пример #3
0
        internal void SelectItem(object target)
        {
            ElementTreeItem node       = _root.FindNode(target);
            Visual          rootVisual = _root.MainVisual;

            if (node == null)
            {
                Visual visual = target as Visual;
                if (visual != null && rootVisual != null)
                {
                    // ensure that the visual is contained within the subtree of the _root element
                    if (!visual.IsDescendantOf(rootVisual))
                    {
                        _root = new VisualItem(PresentationSource.FromVisual(visual).RootVisual, null);
                    }
                }

                _root.Reload();
                _root.UpdateVisualChildrenCount();
                node = _root.FindNode(target);

                Filter = _filter;
            }
            if (node != null)
            {
                SelectedItem = node;
            }
        }
Пример #4
0
 protected override void OnRequestClose()
 {
     // cleanup
     _root       = null;
     _rootObject = null;
     _filtered.Clear();
     _selectedItem = null;
     base.OnRequestClose();
 }
Пример #5
0
        private void Load(object rootTarget)
        {
            _filtered.Clear();

            _root = ElementTreeItem.Construct(rootTarget, null);
            _root.Reload();
            _root.UpdateVisualChildrenCount();

            Filter = _filter;
        }
Пример #6
0
 private void FilterBindings(ElementTreeItem node)
 {
     foreach (ElementTreeItem child in node.Children)
     {
         if (child.HasBindingError)
         {
             _filtered.Add(child);
         }
         else
         {
             FilterBindings(child);
         }
     }
 }
Пример #7
0
 private void FilterTree(ElementTreeItem node, string filter)
 {
     foreach (ElementTreeItem child in node.Children)
     {
         if (child.Filter(filter))
         {
             _filtered.Add(child);
         }
         else
         {
             FilterTree(child, filter);
         }
     }
 }
Пример #8
0
        private void Refresh()
        {
            object currentTarget = (SelectedItem != null) ? SelectedItem.Target : null;

            _filtered.Clear();

            _root = ElementTreeItem.Construct(_rootObject, null);
            _root.Reload();
            _root.UpdateVisualChildrenCount();

            if (currentTarget != null)
            {
                SelectItem(currentTarget);
            }

            Filter = _filter;
        }
Пример #9
0
        public ElementTreeItem FindNode(object target)
        {
            if (Target == target)
            {
                return(this);
            }

            foreach (ElementTreeItem child in Children)
            {
                ElementTreeItem node = child.FindNode(target);
                if (node != null)
                {
                    return(node);
                }
            }
            return(null);
        }
Пример #10
0
        protected override void Reload(List <ElementTreeItem> toBeRemoved)
        {
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(Visual); i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(Visual, i);
                if (child != null)
                {
                    bool foundItem = false;
                    foreach (ElementTreeItem item in toBeRemoved)
                    {
                        if (item.Target == child)
                        {
                            toBeRemoved.Remove(item);
                            item.Reload();
                            foundItem = true;
                            break;
                        }
                    }
                    if (!foundItem)
                    {
                        Children.Add(ElementTreeItem.Construct(child, this));
                    }
                }
            }

            Grid grid = Visual as Grid;

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

            base.Reload(toBeRemoved);
        }
Пример #11
0
        public static ElementTreeItem Construct(object target, ElementTreeItem parent)
        {
            ElementTreeItem item;

            if (target is Visual)
            {
                item = new VisualItem((Visual)target, parent);
            }
            else if (target is ResourceDictionary)
            {
                item = new ResourceDictionaryItem((ResourceDictionary)target, parent);
            }
            else if (target is Application)
            {
                item = new ApplicationTreeItem((Application)target, parent);
            }
            else
            {
                item = new ElementTreeItem(target, parent);
            }
            item.Reload();
            return(item);
        }
Пример #12
0
        protected override void Reload(List <ElementTreeItem> toBeRemoved)
        {
            base.Reload(toBeRemoved);

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

                if (!foundMainWindow)
                {
                    Children.Add(ElementTreeItem.Construct(_application.MainWindow, this));
                }
            }
        }
Пример #13
0
 public ResourceContainerItem(object target, ElementTreeItem parent)
     : base(target, parent)
 {
 }
Пример #14
0
 public ResourceItem(object target, object key, ElementTreeItem parent)
     : base(target, parent)
 {
     _key = key;
 }
Пример #15
0
 protected ElementTreeItem(object target, ElementTreeItem parent)
 {
     _target = target;
     _parent = parent;
 }
Пример #16
0
 protected void RemoveChild(ElementTreeItem item)
 {
     item.IsSelected = false;
     Children.Remove(item);
 }
Пример #17
0
 public ApplicationTreeItem(Application application, ElementTreeItem parent)
     : base(application, parent)
 {
     _application = application;
 }
Пример #18
0
 protected ElementTreeItem(object target, ElementTreeItem parent)
 {
     _target = target;
     _parent = parent;
 }
Пример #19
0
 public VisualItem(Visual visual, ElementTreeItem parent)
     : base(visual, parent)
 {
     _visual = visual;
 }
Пример #20
0
 protected override void OnRequestClose()
 {
     // cleanup
     _root = null;
     _rootObject = null;
     _filtered.Clear();
     _selectedItem = null;
     base.OnRequestClose();
 }
Пример #21
0
 private void FilterBindings(ElementTreeItem node)
 {
     foreach (ElementTreeItem child in node.Children)
     {
         if (child.HasBindingError)
         {
             _filtered.Add(child);
         }
         else
         {
             FilterBindings(child);
         }
     }
 }
Пример #22
0
 private void FilterTree(ElementTreeItem node, string filter)
 {
     foreach (ElementTreeItem child in node.Children)
     {
         if (child.Filter(filter))
         {
             _filtered.Add(child);
         }
         else
         {
             FilterTree(child, filter);
         }
     }
 }
Пример #23
0
        private void Load(object rootTarget)
        {
            _filtered.Clear();

            _root = ElementTreeItem.Construct(rootTarget, null);
            _root.Reload();
            _root.UpdateVisualChildrenCount();

            Filter = _filter;
        }
Пример #24
0
        private void Refresh()
        {
            object currentTarget = (SelectedItem != null) ? SelectedItem.Target : null;

            _filtered.Clear();

            _root = ElementTreeItem.Construct(_rootObject, null);
            _root.Reload();
            _root.UpdateVisualChildrenCount();

            if (currentTarget != null)
            {
                SelectItem(currentTarget);
            }

            Filter = _filter;
        }
Пример #25
0
 public ResourceItem(object target, object key, ElementTreeItem parent)
     : base(target, parent)
 {
     _key = key;
 }
Пример #26
0
        internal void SelectItem(object target)
        {
            ElementTreeItem node = _root.FindNode(target);
            Visual rootVisual = _root.MainVisual;
            if (node == null)
            {
                Visual visual = target as Visual;
                if (visual != null && rootVisual != null)
                {
                    // ensure that the visual is contained within the subtree of the _root element
                    if (!visual.IsDescendantOf(rootVisual))
                    {
                        _root = new VisualItem(PresentationSource.FromVisual(visual).RootVisual, null);
                    }
                }

                _root.Reload();
                _root.UpdateVisualChildrenCount();
                node = _root.FindNode(target);

                Filter = _filter;
            }
            if (node != null)
            {
                SelectedItem = node;
            }
        }
Пример #27
0
 public ResourceDictionaryItem(ResourceDictionary dictionary, ElementTreeItem parent)
     : base(dictionary, parent)
 {
     _dictionary = dictionary;
 }
Пример #28
0
 public ResourceDictionaryItem(ResourceDictionary dictionary, ElementTreeItem parent)
     : base(dictionary, parent)
 {
     _dictionary = dictionary;
 }
Пример #29
0
 protected void RemoveChild(ElementTreeItem item)
 {
     item.IsSelected = false;
     Children.Remove(item);
 }
Пример #30
0
 public static ElementTreeItem Construct(object target, ElementTreeItem parent)
 {
     ElementTreeItem item;
     if (target is Visual)
     {
         item = new VisualItem((Visual)target, parent);
     }
     else if (target is ResourceDictionary)
     {
         item = new ResourceDictionaryItem((ResourceDictionary)target, parent);
     }
     else if (target is Application)
     {
         item = new ApplicationTreeItem((Application)target, parent);
     }
     else
     {
         item = new ElementTreeItem(target, parent);
     }
     item.Reload();
     return item;
 }
Пример #31
0
 public ResourceContainerItem(object target, ElementTreeItem parent)
     : base(target, parent)
 {
 }
Пример #32
0
 public void Inspect(object target)
 {
     _rootObject = target;
     Load(target);
     SelectedItem = _root;
     OnPropertyChanged("Root");
 }