Ejemplo n.º 1
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.º 2
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>
        VisualTreeItem FindItem(object target)
        {
            var node       = rootVisualTreeItem.FindNode(target);
            var rootVisual = rootVisualTreeItem.MainVisual;

            if (node == null)
            {
                var 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 (!CommonTreeHelper.IsDescendantOf(visual, rootVisual))
                    {
                        var presentationSource = PresentationSource.FromVisual(visual);
                        if (presentationSource == null)
                        {
                            return(null); // Something went wrong. At least we will not crash with null ref here.
                        }

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

                rootVisualTreeItem.Reload();

                node = rootVisualTreeItem.FindNode(target);
            }
            return(node);
        }
Ejemplo n.º 3
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.º 4
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.º 5
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;
		}