/// <summary>
 /// Checks whether the specified tree node represents the xml element.
 /// </summary>
 static bool NodeHasElement(WixTreeNode node, XmlElement element)
 {
     if (node != null)
     {
         return(Object.ReferenceEquals(element, node.XmlElement));
     }
     return(false);
 }
        /// <summary>
        /// The selected element's attributes have changed so refresh the node.
        /// </summary>
        public void RefreshSelectedElement()
        {
            WixTreeNode selectedNode = (WixTreeNode)SelectedNode;

            if (selectedNode != null)
            {
                selectedNode.Refresh();
            }
        }
        /// <summary>
        /// Gets the allowed child elements for the current selected node.
        /// </summary>
        StringCollection GetAllowedChildElements(object owner)
        {
            WixTreeNode             node     = owner as WixTreeNode;
            WixPackageFilesTreeView treeView = owner as WixPackageFilesTreeView;

            if (node != null)
            {
                treeView = node.TreeView as WixPackageFilesTreeView;
            }

            if (treeView != null)
            {
                return(treeView.AllowedChildElements);
            }
            return(new StringCollection());
        }
        /// <summary>
        /// Adds a new element to the tree.
        /// </summary>
        /// <remarks>If no node is currently selected this element is added as a
        /// root node.</remarks>
        public void AddElement(XmlElement element)
        {
            WixTreeNode selectedNode = (WixTreeNode)SelectedNode;

            if (selectedNode == null)
            {
                WixTreeNodeBuilder.AddNode(this, element);
            }
            else
            {
                if (selectedNode.IsInitialized)
                {
                    WixTreeNodeBuilder.AddNode(selectedNode, element);
                }
                else
                {
                    // Initializing the node will add all the child elements.
                    selectedNode.PerformInitialization();
                }
            }
        }
 /// <summary>
 /// Finds the node that represents the specified xml element.
 /// </summary>
 /// <remarks>
 /// This currently looks in nodes that have been opened. Really it
 /// should explore the entire tree, but child nodes are only added if the
 /// node is expanded.
 /// </remarks>
 WixTreeNode FindNode(TreeNodeCollection nodes, XmlElement element)
 {
     foreach (ExtTreeNode node in nodes)
     {
         WixTreeNode wixTreeNode = node as WixTreeNode;
         if (wixTreeNode != null)
         {
             if (NodeHasElement(wixTreeNode, element))
             {
                 return(wixTreeNode);
             }
             else
             {
                 WixTreeNode foundNode = FindNode(wixTreeNode.Nodes, element);
                 if (foundNode != null)
                 {
                     return(foundNode);
                 }
             }
         }
     }
     return(null);
 }
		/// <summary>
		/// Checks whether the specified tree node represents the xml element.
		/// </summary>
		static bool NodeHasElement(WixTreeNode node, XmlElement element)
		{
			if (node != null) {
				return Object.ReferenceEquals(element, node.XmlElement);
			}
			return false;
		}