Exemplo n.º 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);
         }
     }
 }
		public void SetUpFixture()
		{
			using (XmlTreeViewContainerControl treeViewContainer = new XmlTreeViewContainerControl()) {
				
				XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty);
				treeViewContainer.LoadXml("<test/>", completionDataProvider);
				
				doc = treeViewContainer.Document;
				XmlTreeViewControl treeView = treeViewContainer.TreeView;
				
				treeViewContainer.Document = doc;
				initialElementSelected = treeView.SelectedElement;
				initialIsElementSelected = treeView.IsElementSelected;
				
				// Set the document element again to make sure the existing node 
				// is removed.
				doc.LoadXml("<root/>");
				treeViewContainer.Document = null;
				treeViewContainer.Document = doc;
				documentElement = treeViewContainer.Document.DocumentElement;
				
				rootNode = (XmlElementTreeNode)treeView.Nodes[0];
				nodeCount = treeView.Nodes.Count;
			}
		}
		public void SetUp()
		{
			XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty);
			treeViewContainerControl = new XmlTreeViewContainerControl();
			treeView = treeViewContainerControl.TreeView;
			treeViewContainerControl.LoadXml(GetXml(), completionDataProvider);
			doc = treeViewContainerControl.Document;
			
			clipboardHandler = treeViewContainerControl as IClipboardHandler;
			
			htmlElement = doc.DocumentElement;
			bodyElement = htmlElement.FirstChild as XmlElement;
			paragraphElement = bodyElement.SelectSingleNode("p") as XmlElement;
			paragraphText = paragraphElement.SelectSingleNode("text()") as XmlText;
			bodyComment = bodyElement.SelectSingleNode("comment()") as XmlComment;
			
			htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;
			htmlTreeNode.PerformInitialization();
			bodyTreeNode = htmlTreeNode.FirstNode as XmlElementTreeNode;
			bodyTreeNode.PerformInitialization();
			bodyCommentTreeNode = bodyTreeNode.FirstNode as XmlCommentTreeNode;
			paragraphTreeNode = bodyTreeNode.LastNode as XmlElementTreeNode;
			paragraphTreeNode.PerformInitialization();
			paragraphTextTreeNode = paragraphTreeNode.FirstNode as XmlTextTreeNode;
		}
		public void Init()
		{
			treeViewContainer = new XmlTreeViewContainerControl();
							
			XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
			XmlSchemaCompletionData xhtmlSchema = new XmlSchemaCompletionData(reader);
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xhtmlSchema, String.Empty);
			
			treeViewContainer.LoadXml("<!-- comment --><html><body class='a'><p>Text</p></body></html>", provider);
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			commentTreeNode = (XmlCommentTreeNode)treeView.Nodes[0];
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[1];
			htmlTreeNode.Expanding();
			
			bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0];
			bodyTreeNode.Expanding();
			
			paraTreeNode = (XmlElementTreeNode)bodyTreeNode.Nodes[0];
			paraTreeNode.Expanding();
			
			textTreeNode = (XmlTextTreeNode)paraTreeNode.Nodes[0];
		}
		public void SetUp()
		{
			SD.InitializeForUnitTests();
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
			string xml = "<!-- Root comment --><root><!-- Child comment --><child></child></root>";
			treeViewContainer.LoadXml(xml);
			
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			// Get the root comment node in the tree.
			rootCommentNode = (XmlComment)doc.FirstChild;
			rootCommentTreeNode = treeView.Nodes[0] as XmlCommentTreeNode;
			
			// Get the child comment node in the tree.
			rootElementTreeNode = (XmlElementTreeNode)treeView.Nodes[1];
			rootElementTreeNode.Expanding();
			rootElement = rootElementTreeNode.XmlElement;
			
			childCommentTreeNode = rootElementTreeNode.Nodes[0] as XmlCommentTreeNode;
			childCommentNode = (XmlComment)rootElementTreeNode.XmlElement.FirstChild;
			
			childElementTreeNode = rootElementTreeNode.Nodes[1] as XmlElementTreeNode;
			childElement = childElementTreeNode.XmlElement;
		}
        /// <summary>
        /// Removes the specified element from the tree.
        /// </summary>
        public void RemoveElement(XmlElement element)
        {
            XmlElementTreeNode node = FindElement(element);

            if (node != null)
            {
                node.Remove();
            }
        }
        /// <summary>
        /// Appends a new child text node to the currently selected element.
        /// </summary>
        public void AppendChildTextNode(XmlText textNode)
        {
            XmlElementTreeNode selectedNode = SelectedElementNode;

            if (selectedNode != null)
            {
                XmlTextTreeNode newNode = new XmlTextTreeNode(textNode);
                newNode.AddTo(selectedNode);
                selectedNode.Expand();
            }
        }
        /// <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>
        /// Finds the corresponding XmlElementTreeNode.
        /// </summary>
        XmlElementTreeNode FindElement(XmlElement element)
        {
            XmlElementTreeNode selectedElementTreeNode = SelectedNode as XmlElementTreeNode;

            if (selectedElementTreeNode != null && selectedElementTreeNode.XmlElement == element)
            {
                return(selectedElementTreeNode);
            }
            else
            {
                return(FindElement(element, Nodes));
            }
        }
Exemplo n.º 10
0
		public void Init()
		{
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
			treeViewContainer.LoadXml("<html><body></body></html>");
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[0];
			htmlTreeNode.Expanding();
			bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0];
			
			bodyElement = (XmlElement)doc.SelectSingleNode("/html/body");
		}
Exemplo n.º 11
0
        /// <summary>
        /// Inserts a new text node either before or after the
        /// currently selected node.
        /// </summary>
        void InsertTextNode(XmlText textNode, InsertionMode insertionMode)
        {
            ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode;

            if (selectedNode != null)
            {
                XmlElementTreeNode parentNode = (XmlElementTreeNode)selectedNode.Parent;
                XmlTextTreeNode    newNode    = new XmlTextTreeNode(textNode);
                int index = parentNode.Nodes.IndexOf(selectedNode);
                if (insertionMode == InsertionMode.After)
                {
                    index++;
                }
                newNode.Insert(index, parentNode);
            }
        }
		public void Init()
		{
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
							
			XmlSchemaCompletion xhtmlSchema = new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema());
			XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
			
			treeViewContainer.LoadXml("<html><body></body></html>", schemas, null);
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[0];
			htmlTreeNode.Expanding();
			bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0];
			
			bodyElement = (XmlElement)doc.SelectSingleNode("/html/body");
		}
Exemplo n.º 13
0
		public void Init()
		{
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
			treeViewContainer.DirtyChanged += TreeViewContainerDirtyChanged;
			
			treeViewContainer.LoadXml("<html id='a'>text<body></body></html>");
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[0];
			htmlTreeNode.Expanding();
			textTreeNode = (XmlTextTreeNode)htmlTreeNode.Nodes[0];

			splitContainer = (SplitContainer)treeViewContainer.Controls["splitContainer"];
			
			textBox = (RichTextBox)splitContainer.Panel2.Controls["textBox"];
			errorMessageTextBox = (RichTextBox)splitContainer.Panel2.Controls["errorMessageTextBox"];
			attributesGrid = (PropertyGrid)splitContainer.Panel2.Controls["attributesGrid"];
		}
		public void Init()
		{
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
							
			XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
			XmlSchemaCompletionData xhtmlSchema = new XmlSchemaCompletionData(reader);
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xhtmlSchema, String.Empty);
			
			treeViewContainer.LoadXml("<html><body></body></html>", provider);
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[0];
			htmlTreeNode.Expanding();
			bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0];
			
			bodyElement = (XmlElement)doc.SelectSingleNode("/html/body");
		}
Exemplo n.º 15
0
		public void Init()
		{
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
			treeViewContainer.LoadXml("<!-- comment --><html><body class='a'><p>Text</p></body></html>");
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			commentTreeNode = (XmlCommentTreeNode)treeView.Nodes[0];
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[1];
			htmlTreeNode.Expanding();
			
			bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0];
			bodyTreeNode.Expanding();
			
			paraTreeNode = (XmlElementTreeNode)bodyTreeNode.Nodes[0];
			paraTreeNode.Expanding();
			
			textTreeNode = (XmlTextTreeNode)paraTreeNode.Nodes[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);
				}
			}
		}
		public void SetUpFixture()
		{
			using (XmlTreeViewContainerControl treeViewContainer = new XmlTreeViewContainerControl()) {
				XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty);
				treeViewContainer.LoadXml("<root/>", completionDataProvider);
				
				doc = treeViewContainer.Document;
				XmlTreeViewControl treeView = treeViewContainer.TreeView;
				
				//treeView.DocumentElement = doc.DocumentElement;
				rootNode = (XmlElementTreeNode)treeView.Nodes[0];

				// No node selected in treeview - adding a child 
				// node should do nothing.
				treeView.SelectedNode = null;
				XmlElement testElement = doc.CreateElement("test");
				treeViewContainer.AppendChildElement(testElement);
				
				treeView.SelectedNode = rootNode;
				XmlElement childElement = doc.CreateElement("child");
				treeViewContainer.AppendChildElement(childElement);
				
				// No node selected in treeview - inserting a node 
				// node should do nothing.
				treeView.SelectedNode = null;
				treeViewContainer.AppendChildElement(testElement);

				XmlElementTreeNode childNode = (XmlElementTreeNode)rootNode.Nodes[0];
				treeView.SelectedNode = childNode;
				XmlElement beforeElement = doc.CreateElement("before");
				treeViewContainer.InsertElementBefore(beforeElement);	
				
				// No node selected in treeview - inserting a node 
				// node should do nothing.
				treeView.SelectedNode = null;
				treeViewContainer.AppendChildElement(testElement);

				treeView.SelectedNode = childNode;
				XmlElement afterElement = doc.CreateElement("after");
				treeViewContainer.InsertElementAfter(afterElement);	
			}
		}
		public void SetUp()
		{
			MockOpenedFile openedFile = new MockOpenedFile("test.xml");
			XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
			xmlView = new MockXmlViewContent(openedFile);
			view = new XmlTreeView(xmlView, schemas, null);
			treeViewContainer = (XmlTreeViewContainerControl)view.Control;
			treeView = treeViewContainer.TreeView;
			clipboardHandler = view as IClipboardHandler;
			xmlView.GetDocumentForFile(null).Text = "<html><body><p></p></body></html>";
			openedFile.SwitchToView(view);
			
			htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;
			htmlTreeNode.PerformInitialization();
			bodyTreeNode = htmlTreeNode.Nodes[0] as XmlElementTreeNode;
			bodyTreeNode.PerformInitialization();
			paragraphTreeNode = bodyTreeNode.Nodes[0] as XmlElementTreeNode;

			treeView.SelectedNode = null;
		}
		public override void FixtureSetUp()
		{
			base.FixtureSetUp();
			using (DerivedXmlTreeViewContainerControl treeViewContainer = new DerivedXmlTreeViewContainerControl()) {
				treeViewContainer.LoadXml("<root/>");
				
				doc = treeViewContainer.Document;
				XmlTreeViewControl treeView = treeViewContainer.TreeView;
				
				rootNode = (XmlElementTreeNode)treeView.Nodes[0];

				// No node selected in treeview - adding a child 
				// node should do nothing.
				treeView.SelectedNode = null;
				XmlElement testElement = doc.CreateElement("test");
				treeViewContainer.AppendChildElement(testElement);
				
				treeView.SelectedNode = rootNode;
				XmlElement childElement = doc.CreateElement("child");
				treeViewContainer.AppendChildElement(childElement);
				
				// No node selected in treeview - inserting a node 
				// node should do nothing.
				treeView.SelectedNode = null;
				treeViewContainer.AppendChildElement(testElement);

				XmlElementTreeNode childNode = (XmlElementTreeNode)rootNode.Nodes[0];
				treeView.SelectedNode = childNode;
				XmlElement beforeElement = doc.CreateElement("before");
				treeViewContainer.InsertElementBefore(beforeElement);	
				
				// No node selected in treeview - inserting a node 
				// node should do nothing.
				treeView.SelectedNode = null;
				treeViewContainer.AppendChildElement(testElement);

				treeView.SelectedNode = childNode;
				XmlElement afterElement = doc.CreateElement("after");
				treeViewContainer.InsertElementAfter(afterElement);	
			}
		}
		public void SetUp()
		{
			XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty);
			treeViewContainerControl = new XmlTreeViewContainerControl();
			treeView = treeViewContainerControl.TreeView;
			treeViewContainerControl.LoadXml("<root><top>text</top><bottom><child>text</child></bottom></root>", completionDataProvider);
			doc = treeViewContainerControl.Document;
			
			ExtTreeNode rootNode = (ExtTreeNode)treeView.Nodes[0];
			rootNode.Expanding();
			
			topElementTreeNode = (XmlElementTreeNode)rootNode.Nodes[0];
			topElementTreeNode.Expanding();
			
			topTextTreeNode = (XmlTextTreeNode)topElementTreeNode.Nodes[0];
			
			ExtTreeNode bottomNode = (ExtTreeNode)rootNode.Nodes[1];
			bottomNode.Expanding();
			
			childElementTreeNode = (XmlElementTreeNode)bottomNode.Nodes[0];
			childElementTreeNode.Expanding();
		}
Exemplo n.º 21
0
        /// <summary>
        /// Looks at all the nodes in the tree view and returns the
        /// tree node that represents the specified element.
        /// </summary>
        XmlElementTreeNode FindElement(XmlElement element, TreeNodeCollection nodes)
        {
            foreach (ExtTreeNode node in nodes)
            {
                XmlElementTreeNode elementTreeNode = node as XmlElementTreeNode;
                if (elementTreeNode != null)
                {
                    if (elementTreeNode.XmlElement == element)
                    {
                        return(elementTreeNode);
                    }

                    // Look for a match in the element's child nodes.
                    XmlElementTreeNode childElementTreeNode = FindElement(element, elementTreeNode.Nodes);
                    if (childElementTreeNode != null)
                    {
                        return(childElementTreeNode);
                    }
                }
            }
            return(null);
        }
		public void SetUp()
		{
			MockOpenedFile openedFile = new MockOpenedFile("test.xml");
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			xmlView = new XmlView(new DefaultTextEditorProperties(), schemas);
			xmlView.SetPrimaryFileUnitTestMode(openedFile);
			view = new XmlTreeView(xmlView, null, null);
			treeViewContainer = (XmlTreeViewContainerControl)view.Control;
			treeView = treeViewContainer.TreeView;
			clipboardHandler = view as IClipboardHandler;
			
			xmlView.XmlEditor.Text = "<html><body><p></p></body></html>";
			openedFile.SwitchToView(view);
			
			htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;
			htmlTreeNode.PerformInitialization();
			bodyTreeNode = htmlTreeNode.Nodes[0] as XmlElementTreeNode;
			bodyTreeNode.PerformInitialization();
			paragraphTreeNode = bodyTreeNode.Nodes[0] as XmlElementTreeNode;

			treeView.SelectedNode = null;
		}
Exemplo n.º 23
0
        /// <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;
                    }
                }
            }
        }
		public void Init()
		{
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
			treeViewContainer.DirtyChanged += TreeViewContainerDirtyChanged;
							
			XmlSchemaCompletion xhtmlSchema = new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema());
			schemas = new XmlSchemaCompletionCollection();
			
			treeViewContainer.LoadXml("<html id='a'>text<body></body></html>", schemas, null);
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[0];
			htmlTreeNode.Expanding();
			textTreeNode = (XmlTextTreeNode)htmlTreeNode.Nodes[0];

			splitContainer = (SplitContainer)treeViewContainer.Controls["splitContainer"];
			
			textBox = (RichTextBox)splitContainer.Panel2.Controls["textBox"];
			errorMessageTextBox = (RichTextBox)splitContainer.Panel2.Controls["errorMessageTextBox"];
			attributesGrid = (PropertyGrid)splitContainer.Panel2.Controls["attributesGrid"];
		}
		public void SetUp()
		{
			treeViewContainerControl = new XmlTreeViewContainerControl();
			treeView = treeViewContainerControl.TreeView;
			string xml = "<root><top>text</top><bottom><child>text</child></bottom></root>";
			treeViewContainerControl.LoadXml(xml, new XmlSchemaCompletionCollection(), null);
			doc = treeViewContainerControl.Document;
			
			ExtTreeNode rootNode = (ExtTreeNode)treeView.Nodes[0];
			rootNode.Expanding();
			
			topElementTreeNode = (XmlElementTreeNode)rootNode.Nodes[0];
			topElementTreeNode.Expanding();
			
			topTextTreeNode = (XmlTextTreeNode)topElementTreeNode.Nodes[0];
			
			ExtTreeNode bottomNode = (ExtTreeNode)rootNode.Nodes[1];
			bottomNode.Expanding();
			
			childElementTreeNode = (XmlElementTreeNode)bottomNode.Nodes[0];
			childElementTreeNode.Expanding();
		}
		public void SetUpFixture()
		{
			using (DerivedXmlTreeViewContainerControl treeViewContainer = new DerivedXmlTreeViewContainerControl()) {
				treeViewContainer.LoadXml("<test/>");
				
				doc = treeViewContainer.Document;
				XmlTreeViewControl treeView = treeViewContainer.TreeView;
				
				treeViewContainer.Document = doc;
				initialElementSelected = treeView.SelectedElement;
				initialIsElementSelected = treeView.IsElementSelected;
				
				// Set the document element again to make sure the existing node 
				// is removed.
				doc.LoadXml("<root/>");
				treeViewContainer.Document = null;
				treeViewContainer.Document = doc;
				documentElement = treeViewContainer.Document.DocumentElement;
				
				rootNode = (XmlElementTreeNode)treeView.Nodes[0];
				nodeCount = treeView.Nodes.Count;
			}
		}
		public void Init()
		{
			treeViewContainer = new XmlTreeViewContainerControl();
							
			XmlSchemaCompletion xhtmlSchema = new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema());
			XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
			
			treeViewContainer.LoadXml("<!-- comment --><html><body class='a'><p>Text</p></body></html>", schemas, null);
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			commentTreeNode = (XmlCommentTreeNode)treeView.Nodes[0];
			htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[1];
			htmlTreeNode.Expanding();
			
			bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0];
			bodyTreeNode.Expanding();
			
			paraTreeNode = (XmlElementTreeNode)bodyTreeNode.Nodes[0];
			paraTreeNode.Expanding();
			
			textTreeNode = (XmlTextTreeNode)paraTreeNode.Nodes[0];
		}
		public void SetUp()
		{
			treeViewContainerControl = new DerivedXmlTreeViewContainerControl();
			treeView = treeViewContainerControl.TreeView;
			treeViewContainerControl.LoadXml(GetXml());
			doc = treeViewContainerControl.Document;
			
			clipboardHandler = treeViewContainerControl as IClipboardHandler;
			
			htmlElement = doc.DocumentElement;
			bodyElement = htmlElement.FirstChild as XmlElement;
			paragraphElement = bodyElement.SelectSingleNode("p") as XmlElement;
			paragraphText = paragraphElement.SelectSingleNode("text()") as XmlText;
			bodyComment = bodyElement.SelectSingleNode("comment()") as XmlComment;
			
			htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;
			htmlTreeNode.PerformInitialization();
			bodyTreeNode = htmlTreeNode.FirstNode as XmlElementTreeNode;
			bodyTreeNode.PerformInitialization();
			bodyCommentTreeNode = bodyTreeNode.FirstNode as XmlCommentTreeNode;
			paragraphTreeNode = bodyTreeNode.LastNode as XmlElementTreeNode;
			paragraphTreeNode.PerformInitialization();
			paragraphTextTreeNode = paragraphTreeNode.FirstNode as XmlTextTreeNode;
		}
		public void SetUp()
		{
			XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty);
			treeViewContainer = new DerivedXmlTreeViewContainerControl();
			treeViewContainer.LoadXml("<!-- Root comment --><root><!-- Child comment --><child></child></root>", completionDataProvider);
			
			doc = treeViewContainer.Document;
			treeView = treeViewContainer.TreeView;
			
			// Get the root comment node in the tree.
			rootCommentNode = (XmlComment)doc.FirstChild;
			rootCommentTreeNode = treeView.Nodes[0] as XmlCommentTreeNode;
			
			// Get the child comment node in the tree.
			rootElementTreeNode = (XmlElementTreeNode)treeView.Nodes[1];
			rootElementTreeNode.Expanding();
			rootElement = rootElementTreeNode.XmlElement;
			
			childCommentTreeNode = rootElementTreeNode.Nodes[0] as XmlCommentTreeNode;
			childCommentNode = (XmlComment)rootElementTreeNode.XmlElement.FirstChild;
			
			childElementTreeNode = rootElementTreeNode.Nodes[1] as XmlElementTreeNode;
			childElement = childElementTreeNode.XmlElement;
		}
Exemplo n.º 30
0
        /// <summary>
        /// Shows the corresponding tree node with the ghosted image
        /// that indicates it is being cut.
        /// </summary>
        void ShowCutElement(XmlElement element, bool showGhostImage)
        {
            XmlElementTreeNode node = FindElement(element);

            node.ShowGhostImage = showGhostImage;
        }
		/// <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 element to the currently selected node.
		/// </summary>
		public void AppendChildElement(XmlElement element)
		{
			XmlElementTreeNode selectedNode = SelectedElementNode;
			if (selectedNode != null) {
				XmlElementTreeNode newNode = new XmlElementTreeNode(element);
				newNode.AddTo(selectedNode);
				selectedNode.Expand();
			}
		}
 public void PrefixedName()
 {
     XmlElement element = doc.CreateElement("t", "child", "http://test.com");
     XmlElementTreeNode node = new XmlElementTreeNode(element);
     Assert.AreEqual("t:child", node.Text);
 }
		/// <summary>
		/// Inserts a new element node either before or after the 
		/// currently selected element node.
		/// </summary>
		void InsertElement(XmlElement element, InsertionMode insertionMode)
		{
			ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode;
			if (selectedNode != null) {
				XmlElementTreeNode parentNode = (XmlElementTreeNode)selectedNode.Parent;
				XmlElementTreeNode newNode = new XmlElementTreeNode(element);
				int index = parentNode.Nodes.IndexOf(selectedNode);
				if (insertionMode == InsertionMode.After) {
					index++;
				}
				newNode.Insert(index, parentNode);
			}
		}
 public void UnqualifiedName()
 {
     XmlElement element = doc.CreateElement("child");
     XmlElementTreeNode node = new XmlElementTreeNode(element);
     Assert.AreEqual("child", node.Text);
 }