Ejemplo n.º 1
0
 protected VisualTreeItem(object target, VisualTreeItem parent)
 {
     this.target = target;
     this.parent = parent;
     if (parent != null)
         this.depth = parent.depth + 1;
 }
Ejemplo n.º 2
0
        public static VisualTreeItem Construct(object target, VisualTreeItem parent)
        {
            VisualTreeItem visualTreeItem;

            if (target is Visual)
            {
                visualTreeItem = new VisualItem((Visual)target, parent);
            }
            else if (target is ResourceDictionary)
            {
                visualTreeItem = new ResourceDictionaryItem((ResourceDictionary)target, parent);
            }
            else if (target is Application)
            {
                visualTreeItem = new ApplicationTreeItem((Application)target, parent);
            }
            else
            {
                visualTreeItem = new VisualTreeItem(target, parent);
            }

            visualTreeItem.Reload();

            return(visualTreeItem);
        }
Ejemplo n.º 3
0
        private void HandlePreProcessInput(object sender, PreProcessInputEventArgs e)
        {
            this.OnPropertyChanged("CurrentFocus");

            ModifierKeys currentModifiers = InputManager.Current.PrimaryKeyboardDevice.Modifiers;

            if (!((currentModifiers & ModifierKeys.Control) != 0 && (currentModifiers & ModifierKeys.Shift) != 0))
            {
                return;
            }

            //ModifierKeys currentModifiers = InputManager.Current.PrimaryKeyboardDevice.Modifiers;
            if ((currentModifiers & ModifierKeys.Alt) != 0)
            {
                return;
            }

            Visual directlyOver = Mouse.PrimaryDevice.DirectlyOver as Visual;

            if ((directlyOver == null) || directlyOver.IsDescendantOf(this))
            {
                return;
            }

            VisualTreeItem node = this.FindItem(directlyOver);

            if (node != null)
            {
                this.CurrentSelection = node;
            }
        }
Ejemplo n.º 4
0
        public static VisualTreeItem Construct(object target, VisualTreeItem parent)
        {
            VisualTreeItem visualTreeItem;

            if (target is IReflectionHelperInterfaceWrapper)
            {
                visualTreeItem = new VisualItem(((IReflectionHelperInterfaceWrapper)target).Source, parent);
            }
            else if (target.Wrap <IFrameworkRenderElementContext>() != null)
            {
                visualTreeItem = new VisualItem(target, parent);
            }
            else if (target is Visual)
            {
                visualTreeItem = new VisualItem((Visual)target, parent);
            }
            else if (target is ResourceDictionary)
            {
                visualTreeItem = new ResourceDictionaryItem((ResourceDictionary)target, parent);
            }
            else if (target is Application)
            {
                visualTreeItem = new ApplicationTreeItem((Application)target, parent);
            }
            else
            {
                visualTreeItem = new DumbVisualTreeItem(target, parent);
            }
            //visualTreeItem = new VisualTreeItem(target, parent);

            visualTreeItem.Reload();

            return(visualTreeItem);
        }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
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));
            }
        }
Ejemplo n.º 7
0
        public void Next()
        {
            if (!IsFiltering)
            {
                return;
            }
            var            lFilter = Filter.ToLower();
            VisualTreeItem current = null;

            while (ItemsEnumerator.MoveNext())
            {
                current = ItemsEnumerator.Current;
                if (current.MatchesFilter(lFilter) && current != Root)
                {
                    break;
                }
                current = null;
            }
            if (current != null)
            {
                SelectElement(current);
            }
            else
            {
                if (reloading)
                {
                    return;
                }
                reloading = true;
                PrepareNewFilter();
                Next();
                reloading = false;
            }
        }
Ejemplo n.º 8
0
        public static void AddEditedProperty(Dispatcher dispatcher, VisualTreeItem propertyOwner,
                                             PropertyInformation propInfo)
        {
            lock (_lock) {
                List <PropertyValueInfo> propInfoList = null;
                Dictionary <VisualTreeItem, List <PropertyValueInfo> > dispatcherList = null;

                // first get the dictionary we're using for the given dispatcher
                if (!_itemsWithEditedProperties.TryGetValue(dispatcher, out dispatcherList))
                {
                    dispatcherList = new Dictionary <VisualTreeItem, List <PropertyValueInfo> >();
                    _itemsWithEditedProperties.Add(dispatcher, dispatcherList);
                }

                // now get the property info list for the owning object
                if (!dispatcherList.TryGetValue(propertyOwner, out propInfoList))
                {
                    propInfoList = new List <PropertyValueInfo>();
                    dispatcherList.Add(propertyOwner, propInfoList);
                }

                // if we already have a property of that name on this object, remove it
                var existingPropInfo = propInfoList.FirstOrDefault(l => l.PropertyName == propInfo.DisplayName);
                if (existingPropInfo != null)
                {
                    propInfoList.Remove(existingPropInfo);
                }

                // finally add the edited property info
                propInfoList.Add(new PropertyValueInfo {
                    PropertyName  = propInfo.DisplayName,
                    PropertyValue = propInfo.Value
                });
            }
        }
Ejemplo n.º 9
0
        public VisualTreeItem FindNode(object target)
        {
            // it might be faster to have a map for the lookup
            // check into this at some point
            if (this.Target == target)
            {
                if (DXMethods.IsChrome(Target) && target is IInputElement)
                {
                    var root = DXMethods.GetRoot(Target);
                    if (root != null)
                    {
                        var child = RenderTreeHelper.HitTest(root, System.Windows.Input.Mouse.GetPosition((IInputElement)target));
                        var node  = FindNode(child);
                        if (node != null)
                        {
                            return(node);
                        }
                    }
                }
                return(this);
            }

            foreach (VisualTreeItem child in this.Children)
            {
                VisualTreeItem node = child.FindNode(target);
                if (node != null)
                {
                    return(node);
                }
            }
            return(null);
        }
Ejemplo n.º 10
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));
                }
            }
        }
        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));
                }
            }
        }
Ejemplo n.º 12
0
        public static VisualTreeItem Construct(object target, VisualTreeItem parent)
        {
            VisualTreeItem visualTreeItem;

            if (DXMethods.IsFrameworkRenderElementContext(target))
            {
                visualTreeItem = new VisualItem(target, parent);
            }
            else if (target is Visual)
            {
                visualTreeItem = new VisualItem((Visual)target, parent);
            }
            else if (target is ResourceDictionary)
            {
                visualTreeItem = new ResourceDictionaryItem((ResourceDictionary)target, parent);
            }
            else if (target is Application)
            {
                visualTreeItem = new ApplicationTreeItem((Application)target, parent);
            }
            else
            {
                visualTreeItem = new VisualTreeItem(target, parent);
            }

            visualTreeItem.Reload();

            return(visualTreeItem);
        }
Ejemplo n.º 13
0
		protected VisualTreeItem(object target, VisualTreeItem parent)
		{
		    if (target == null) throw new ArgumentNullException("target");
		    this.target = target;
			this.parent = parent;
			if (parent != null)
				this.depth = parent.depth + 1;
		}
Ejemplo n.º 14
0
        void Load(object root)
        {
            this.root = root;

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

            OnPropertyChanged("Root");
        }
Ejemplo n.º 15
0
 void RaiseEndUpdate(VisualTreeItem element)
 {
     if (Parent != null)
     {
         Parent.RaiseEndUpdate(element);
         return;
     }
     EndUpdate?.Invoke(element, EventArgs.Empty);
 }
Ejemplo n.º 16
0
 public VisualItem(object visual, VisualTreeItem parent) : base(visual, parent)
 {
     Visual = visual;
     if (visual is Visual)
     {
         var vVisual = (Visual)visual;
         VisualDiagnostics.VisualTreeChanged += VisualDiagnostics_VisualTreeChanged;
     }
 }
Ejemplo n.º 17
0
 protected VisualTreeItem(object target, VisualTreeItem parent)
 {
     this.target = target;
     this.parent = parent;
     if (parent != null)
     {
         this.depth = parent.depth + 1;
     }
 }
Ejemplo n.º 18
0
        private void HandleTreeSelectedItemChanged(object sender, EventArgs e)
        {
            VisualTreeItem item = this.Tree.SelectedItem as VisualTreeItem;

            if (item != null)
            {
                this.CurrentSelection = item;
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Loop through the properties in the current PropertyGrid and save away any properties
 /// that have been changed by the user.
 /// </summary>
 /// <param name="owningObject">currently selected object that owns the properties in the grid (before changing selection to the new object)</param>
 private void SaveEditedProperties(VisualTreeItem owningObject)
 {
     foreach (PropertyInformation property in PropertyGrid.PropertyGrid.Properties)
     {
         if (property.IsValueChangedByUser)
         {
             EditedPropertiesHelper.AddEditedProperty(Dispatcher, owningObject, property);
         }
     }
 }
Ejemplo n.º 20
0
 private void SelectItem(DependencyObject item)
 {
     if (item != null)
     {
         VisualTreeItem node = this.FindItem(item);
         if (node != null)
         {
             this.CurrentSelection = node;
         }
     }
 }
Ejemplo n.º 21
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");
        }
Ejemplo n.º 22
0
 void OnChildExpanded(VisualTreeItem child)
 {
     if (Parent != null)
     {
         Parent.OnChildExpanded(child);
         return;
     }
     if (child == null || ChildExpandedChanged == null)
     {
         return;
     }
     ChildExpandedChanged(child, EventArgs.Empty);
 }
Ejemplo n.º 23
0
 protected VisualTreeItem(object target, VisualTreeItem parent)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     this.target = target;
     this.parent = parent;
     if (parent != null)
     {
         this.depth = parent.depth + 1;
     }
 }
Ejemplo n.º 24
0
 private void FilterTree(VisualTreeItem node, string filter)
 {
     foreach (VisualTreeItem child in node.Children)
     {
         if (child.Filter(filter))
         {
             this.visualTreeItems.Add(child);
         }
         else
         {
             FilterTree(child, filter);
         }
     }
 }
Ejemplo n.º 25
0
 private void FilterBindings(VisualTreeItem node)
 {
     foreach (VisualTreeItem child in node.Children)
     {
         if (child.HasBindingError)
         {
             this.visualTreeItems.Add(child);
         }
         else
         {
             FilterBindings(child);
         }
     }
 }
Ejemplo n.º 26
0
        public bool ApplyReduceDepthFilterIfNeeded(ProperTreeViewItem curNode)
        {
            if (_pendingRoot != null)
            {
                OnRootLoaded();
            }

            if (_maxDepth == 0)
            {
                return(false);
            }

            VisualTreeItem rootItem = (VisualTreeItem)_rootItem.Target;

            if (rootItem == null)
            {
                return(false);
            }

            if (_snoopUI == null)
            {
                _snoopUI = VisualTreeHelper2.GetAncestor <SnoopUI>(this);
                if (_snoopUI == null)
                {
                    return(false);
                }
            }

            VisualTreeItem item         = (VisualTreeItem)curNode.DataContext;
            VisualTreeItem selectedItem = _snoopUI.CurrentSelection;

            if (selectedItem != null && item.Depth < selectedItem.Depth)
            {
                item = selectedItem;
            }

            if ((item.Depth - rootItem.Depth) <= _maxDepth)
            {
                return(false);
            }

            for (int i = 0; i < _maxDepth; ++i)
            {
                item = item.Parent;
            }

            _snoopUI.ApplyReduceDepthFilter(item);
            return(true);
        }
Ejemplo n.º 27
0
		public static VisualTreeItem Construct(object target, VisualTreeItem parent)
		{
			VisualTreeItem visualTreeItem;

			if (target is Visual)
				visualTreeItem = new VisualItem((Visual)target, parent);
			else if (target is ResourceDictionary)
				visualTreeItem = new ResourceDictionaryItem((ResourceDictionary)target, parent);
			else if (target is Application)
				visualTreeItem = new ApplicationTreeItem((Application)target, parent);
			else
				visualTreeItem = new VisualTreeItem(target, parent);

			visualTreeItem.Reload();

			return visualTreeItem;
		}
Ejemplo n.º 28
0
        private void HandleInspect(object sender, ExecutedRoutedEventArgs e)
        {
            Visual visual = e.Parameter as Visual;

            if (visual != null)
            {
                VisualTreeItem node = this.FindItem(visual);
                if (node != null)
                {
                    this.CurrentSelection = node;
                }
            }
            else if (e.Parameter != null)
            {
                this.PropertyGrid.SetTarget(e.Parameter);
            }
        }
Ejemplo n.º 29
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));
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Find the VisualTreeItem for the specified visual.
        /// If the item is not found and is not part of the Snoop UI,
        /// the tree will be adjusted to include the window the item is in.
        /// </summary>
        private VisualTreeItem FindItem(object target)
        {
            if (this.rootVisualTreeItem == null)
            {
                return(null);
            }

            VisualTreeItem node       = this.rootVisualTreeItem.FindNode(target);
            Visual         rootVisual = this.rootVisualTreeItem.MainVisual;

            if (node == null)
            {
                Visual visual = target as Visual;
                if (visual != null && rootVisual != null)
                {
                    // If target is a part of the SnoopUI, let's get out of here.
                    if (visual.IsDescendantOf(this))
                    {
                        return(null);
                    }

                    // If not in the root tree, make the root be the tree the visual is in.
                    if (!visual.IsDescendantOf(rootVisual))
                    {
                        var presentationSource = PresentationSource.FromVisual(visual);
                        if (presentationSource == null)
                        {
                            return(null);                            // Something went wrong. At least we will not crash with null ref here.
                        }

                        this.Root = new VisualItem(presentationSource.RootVisual, null);
                    }
                }

                this.rootVisualTreeItem.Reload();

                node = this.rootVisualTreeItem.FindNode(target);

                this.SetFilter(this.filter);
            }
            return(node);
        }
Ejemplo n.º 31
0
        public VisualTreeItem FindNode(object target)
        {
            // it might be faster to have a map for the lookup
            // check into this at some point

            if (this.Target == target)
            {
                return(this);
            }

            foreach (VisualTreeItem child in this.Children)
            {
                VisualTreeItem node = child.FindNode(target);
                if (node != null)
                {
                    return(node);
                }
            }
            return(null);
        }
Ejemplo n.º 32
0
 public void ApplyReduceDepthFilter(VisualTreeItem newRoot)
 {
     if (m_reducedDepthRoot != newRoot)
     {
         if (m_reducedDepthRoot == null)
         {
             Dispatcher.BeginInvoke
             (
                 DispatcherPriority.Background,
                 (function)
                 delegate
             {
                 this.visualTreeItems.Clear();
                 this.visualTreeItems.Add(m_reducedDepthRoot);
                 m_reducedDepthRoot = null;
             }
             );
         }
         m_reducedDepthRoot = newRoot;
     }
 }
Ejemplo n.º 33
0
        VisualTreeItem GetItemAtImpl(ref int index)
        {
            if (index == 0)
            {
                return(this);
            }
            index--;
            VisualTreeItem result = null;

            if (!isExpanded)
            {
                return(null);
            }
            foreach (var child in Children)
            {
                if (result != null)
                {
                    return(result);
                }
                result = child.GetItemAtImpl(ref index);
            }
            return(result);
        }
Ejemplo n.º 34
0
        public static void AddEditedProperty( Dispatcher dispatcher, VisualTreeItem propertyOwner, PropertyInformation propInfo)
        {
            lock ( _lock )
            {
                List<PropertyValueInfo> propInfoList = null;
                Dictionary<VisualTreeItem, List<PropertyValueInfo>> dispatcherList = null;

                // first get the dictionary we're using for the given dispatcher
                if ( !_itemsWithEditedProperties.TryGetValue( dispatcher, out dispatcherList ) )
                {
                    dispatcherList = new Dictionary<VisualTreeItem, List<PropertyValueInfo>>();
                    _itemsWithEditedProperties.Add( dispatcher, dispatcherList );
                }

                // now get the property info list for the owning object
                if ( !dispatcherList.TryGetValue( propertyOwner, out propInfoList ) )
                {
                    propInfoList = new List<PropertyValueInfo>();
                    dispatcherList.Add( propertyOwner, propInfoList );
                }

                // if we already have a property of that name on this object, remove it
                var existingPropInfo = propInfoList.FirstOrDefault( l => l.PropertyName == propInfo.DisplayName );
                if ( existingPropInfo != null )
                {
                    propInfoList.Remove( existingPropInfo );
                }

                // finally add the edited property info
                propInfoList.Add( new PropertyValueInfo
                                  {
                                  	PropertyName = propInfo.DisplayName,
                                  	PropertyValue = propInfo.Value,
                                  } );
            }
        }
Ejemplo n.º 35
0
 public ResourceItem(object target, object key, VisualTreeItem parent)
     : base(target, parent)
 {
     this.key = key;
 }
Ejemplo n.º 36
0
		public ApplicationTreeItem(Application application, VisualTreeItem parent)
			: base(application, parent)
		{
			this.application = application;
		}
Ejemplo n.º 37
0
 private void DumpItem(VisualTreeItem item)
 {
     // Base indent
     StringBuilder sb = new StringBuilder();
     for (int i = 0; i <= item.Depth; i++)
     {
         sb.Append("  ");
     }
     String baseIndent = sb.ToString();
     // Write node element
     Writer.Write(baseIndent);
     Writer.Write("<node");
     String nodeName = item.Name;
     if (string.IsNullOrEmpty(nodeName))
     {
         nodeName = item.ToString();
     }
     Writer.Write(" name=\"");
     Writer.Write(EscapeXML(nodeName));
     Writer.Write("\"");
     Writer.WriteLine(">");
     foreach (PropertyInformation propInfo in PropertyInformation.GetProperties(item.Target))
     {
         if (!"Children".Equals(propInfo.DisplayName) && !"Parent".Equals(propInfo.DisplayName))
         {
             Writer.Write(baseIndent);
             WriteProperty(propInfo.DisplayName, propInfo.Value);
         }
         propInfo.Teardown();
     }
     FrameworkElement elem = item.Target as FrameworkElement;
     if (elem != null)
     {
         if (RootVisual == null)
         {
             RootVisual = elem;
         }
         try
         {
             Rect bounds = elem.TransformToAncestor(RootVisual).TransformBounds(VisualTreeHelper.GetDescendantBounds(elem));
             if (!bounds.IsEmpty)
             {
                 Writer.Write(baseIndent);
                 WriteProperty("x-BoundsInClientArea", bounds.ToString());
                 //bounds.Offset(new Vector(0, SystemParameters.WindowCaptionHeight));
                 //Writer.Write(baseIndent);
                 //WriteProperty("x-BoundsInWindow", bounds.ToString());
             }
         }
         catch (Exception)
         {
             // In case this element is not a child of the root. Ignore.
         }
     }
     foreach (VisualTreeItem child in item.Children)
     {
         DumpItem(child);
     }
     Writer.Write(baseIndent);
     Writer.WriteLine("</node>");
 }
Ejemplo n.º 38
0
 private void FilterBindings(VisualTreeItem node)
 {
     foreach (VisualTreeItem child in node.Children)
     {
         if (child.HasBindingError)
             this.visualTreeItems.Add(child);
         else
             FilterBindings(child);
     }
 }
Ejemplo n.º 39
0
        private void Load(object root)
        {
            this.root = root;

            this.visualTreeItems.Clear();

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

            this.SetFilter(this.filter);

            this.OnPropertyChanged("Root");
        }
Ejemplo n.º 40
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.rootVisualTreeItem = 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;
            }
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Find the VisualTreeItem for the specified visual.
        /// If the item is not found and is not part of the Snoop UI,
        /// the tree will be adjusted to include the window the item is in.
        /// </summary>
        private VisualTreeItem FindItem(object target)
        {
            VisualTreeItem node = this.rootVisualTreeItem.FindNode(target);
            Visual rootVisual = this.rootVisualTreeItem.MainVisual;
            if (node == null)
            {
                Visual visual = target as Visual;
                if (visual != null && rootVisual != null)
                {
                    // If target is a part of the SnoopUI, let's get out of here.
                    if (visual.IsDescendantOf(this))
                    {
                        return null;
                    }

                    // If not in the root tree, make the root be the tree the visual is in.
                    if (!visual.IsDescendantOf(rootVisual))
                    {
                        var presentationSource = PresentationSource.FromVisual(visual);
                        if (presentationSource == null)
                        {
                            return null; // Something went wrong. At least we will not crash with null ref here.
                        }

                        this.rootVisualTreeItem = new VisualItem(presentationSource.RootVisual, null);
                    }
                }

                this.rootVisualTreeItem.Reload();

                node = this.rootVisualTreeItem.FindNode(target);

                this.SetFilter(this.filter);
            }
            return node;
        }
Ejemplo n.º 42
0
 public VisualItem(Visual visual, VisualTreeItem parent)
     : base(visual, parent)
 {
     this.visual = visual;
 }
Ejemplo n.º 43
0
 public ResourceDictionaryItem(ResourceDictionary dictionary, VisualTreeItem parent)
     : base(dictionary, parent)
 {
     this.dictionary = dictionary;
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Loop through the properties in the current PropertyGrid and save away any properties
 /// that have been changed by the user.  
 /// </summary>
 /// <param name="owningObject">currently selected object that owns the properties in the grid (before changing selection to the new object)</param>
 private void SaveEditedProperties( VisualTreeItem owningObject )
 {
     foreach (PropertyInformation property in PropertyGrid.PropertyGrid.Properties)
     {
         if (property.IsValueChangedByUser)
         {
             EditedPropertiesHelper.AddEditedProperty( Dispatcher, owningObject, property );
         }
     }
 }
Ejemplo n.º 45
0
 public static void DumpTree(VisualTreeItem root, System.IO.StreamWriter writer)
 {
     XMLTreeWriter treeWriter = new XMLTreeWriter(writer);
     writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
     writer.WriteLine("<root>");
     treeWriter.DumpItem(root);
     writer.WriteLine("</root>");
 }
Ejemplo n.º 46
0
 public void ApplyReduceDepthFilter(VisualTreeItem newRoot)
 {
     if (m_reducedDepthRoot != newRoot)
     {
         if (m_reducedDepthRoot == null)
         {
             Dispatcher.BeginInvoke
             (
                 DispatcherPriority.Background,
                 (function)
                 delegate
                 {
                     this.visualTreeItems.Clear();
                     this.visualTreeItems.Add(m_reducedDepthRoot);
                     m_reducedDepthRoot = null;
                 }
             );
         }
         m_reducedDepthRoot = newRoot;
     }
 }
Ejemplo n.º 47
0
		public ResourceContainerItem(object target, VisualTreeItem parent): base(target, parent)
		{
		}
Ejemplo n.º 48
0
 private void FilterTree(VisualTreeItem node, string filter)
 {
     foreach (VisualTreeItem child in node.Children)
     {
         if (child.Filter(filter))
             this.visualTreeItems.Add(child);
         else
             FilterTree(child, filter);
     }
 }
Ejemplo n.º 49
0
		protected void RemoveChild(VisualTreeItem item)
		{
			item.IsSelected = false;
			this.Children.Remove(item);
		}