예제 #1
0
 /// <summary>
 /// Adds child elements to this tree node.
 /// </summary>
 protected override void Initialize()
 {
     Nodes.Clear();
     foreach (XmlNode childNode in element.ChildNodes)
     {
         XmlElement childElement = childNode as XmlElement;
         XmlText    text         = childNode as XmlText;
         XmlComment comment      = childNode as XmlComment;
         if (childElement != null)
         {
             XmlElementTreeNode treeNode = new XmlElementTreeNode(childElement);
             treeNode.AddTo(this);
         }
         else if (text != null)
         {
             XmlTextTreeNode treeNode = new XmlTextTreeNode(text);
             treeNode.AddTo(this);
         }
         else if (comment != null)
         {
             XmlCommentTreeNode treeNode = new XmlCommentTreeNode(comment);
             treeNode.AddTo(this);
         }
     }
 }
        /// <summary>
        /// Appends a new child comment node to the currently selected element.
        /// </summary>
        public void AppendChildComment(XmlComment comment)
        {
            XmlElementTreeNode selectedNode = SelectedElementNode;

            if (selectedNode != null)
            {
                XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment);
                newNode.AddTo(selectedNode);
                selectedNode.Expand();
            }
        }
		/// <summary>
		/// Adds child elements to this tree node.
		/// </summary>
		protected override void Initialize()
		{
			Nodes.Clear();
			foreach (XmlNode childNode in element.ChildNodes) {
				XmlElement childElement = childNode as XmlElement;
				XmlText text = childNode as XmlText;
				XmlComment comment = childNode as XmlComment;
				if (childElement != null) {
					XmlElementTreeNode treeNode = new XmlElementTreeNode(childElement);
					treeNode.AddTo(this);
				} else if (text != null) {
					XmlTextTreeNode treeNode = new XmlTextTreeNode(text);
					treeNode.AddTo(this);
				} else if (comment != null) {
					XmlCommentTreeNode treeNode = new XmlCommentTreeNode(comment);
					treeNode.AddTo(this);
				}
			}
		}
        /// <summary>
        /// Displays the document in the xml tree.
        /// </summary>
        void ShowDocument()
        {
            Nodes.Clear();
            if (document != null)
            {
                foreach (XmlNode node in document.ChildNodes)
                {
                    switch (node.NodeType)
                    {
                    case XmlNodeType.Element:
                        XmlElementTreeNode elementNode = new XmlElementTreeNode((XmlElement)node);
                        elementNode.AddTo(this);
                        break;

                    case XmlNodeType.Comment:
                        XmlCommentTreeNode commentNode = new XmlCommentTreeNode((XmlComment)node);
                        commentNode.AddTo(this);
                        break;
                    }
                }
            }
        }
		/// <summary>
		/// Displays the document in the xml tree.
		/// </summary>
		void ShowDocument()
		{
			Nodes.Clear();
			if (document != null) {
				foreach (XmlNode node in document.ChildNodes) {
					switch (node.NodeType) {
						case XmlNodeType.Element:
							XmlElementTreeNode elementNode = new XmlElementTreeNode((XmlElement)node);
							elementNode.AddTo(this);
							break;
						case XmlNodeType.Comment:
							XmlCommentTreeNode commentNode = new XmlCommentTreeNode((XmlComment)node);
							commentNode.AddTo(this);
							break;
					}
				}
			}
		}
		/// <summary>
		/// Appends a new child comment node to the currently selected element.
		/// </summary>
		public void AppendChildComment(XmlComment comment)
		{
			XmlElementTreeNode selectedNode = SelectedElementNode;
			if (selectedNode != null) {
				XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment);
				newNode.AddTo(selectedNode);
				selectedNode.Expand();
			}
		}