Inheritance: XmlCharacterData
		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;
		}
		public void GetReady ()
		{
			document = new XmlDocument ();
			document.NodeChanged += new XmlNodeChangedEventHandler (this.EventNodeChanged);
			document.NodeChanging += new XmlNodeChangedEventHandler (this.EventNodeChanging);
			comment = document.CreateComment ("foo");
		}
		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 XmlCommentName ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			AssertEquals (comment.NodeType + " Name property broken",
				comment.Name, "#comment");
		}
		public void XmlCommentIsReadOnly ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			AssertEquals ("XmlComment IsReadOnly property broken",
				comment.IsReadOnly, false);
		}
		public XmlCommentTreeNode(XmlComment comment)
			: base(comment)
		{
			this.comment = comment;
			ImageKey = XmlCommentTreeNodeImageKey;
			SelectedImageKey = ImageKey;
			Update();
		}
		public void SetUpFixture()
		{
			base.InitFixture();
			rootComment = (XmlComment)mockXmlTreeView.Document.FirstChild;
			childElement = (XmlElement)mockXmlTreeView.Document.SelectSingleNode("root/child");
			mockXmlTreeView.SelectedComment = rootComment;
			editor.SelectedNodeChanged();
		}
		public void Init()
		{
			base.InitFixture();
			rootElement = editor.Document.DocumentElement;
			bodyElement = (XmlElement)rootElement.FirstChild;
			paragraphElement = (XmlElement)bodyElement.SelectSingleNode("p");
			bodyComment = (XmlComment)bodyElement.SelectSingleNode("comment()");
			paragraphText = (XmlText)paragraphElement.SelectSingleNode("text()");
		}
Esempio n. 9
0
        protected override void ExecuteCore(XmlComment comment)
        {
            if (comment.ParentNode is XmlDocument)
            {
                return;
            }

            Validate();
            var element = comment.OwnerDocument.CreateElement(Name);
            element.InnerText = comment.Value;
            comment.ParentNode.ReplaceChild(element, comment);
        }
Esempio n. 10
0
        protected override void ExecuteCore(XmlComment comment)
        {
            Validate();

            var element = comment.ParentNode as XmlElement;

            if (element != null && element.Attributes[Name] == null)
            {
                var attribute = comment.OwnerDocument.CreateAttribute(Name);
                attribute.Value = comment.Value;
                element.Attributes.Append(attribute);
                element.RemoveChild(comment);
            }
        }
Esempio n. 11
0
		public void XmlCommentCloneNode ()
		{
			document.LoadXml ("<root><foo></foo></root>");
			comment = document.CreateComment ("Comment");
			original = comment;

			shallow = comment.CloneNode (false); // shallow
			XmlNodeBaseProperties (original, shallow);
			
			deep = comment.CloneNode (true); // deep
			XmlNodeBaseProperties (original, deep);
			Assert.AreEqual (original.Value, deep.Value, "Value incorrectly cloned");

			Assert.AreEqual (deep.OuterXml, shallow.OuterXml, "deep cloning differs from shallow cloning");
		}
		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;
		}
		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;
		}
		/// <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>
		/// Removes the specified comment from the tree.
		/// </summary>
		public void RemoveComment(XmlComment comment)
		{
			XmlCommentTreeNode node = FindComment(comment);
			if (node != null) {
				node.Remove();
			}
		}
Esempio n. 16
0
 private void AddXmlComment(StringBuilder sb, int indentationLevel, XmlComment xmlComment)
 {
     Indent(sb, indentationLevel);
     sb.Append(string.Format(@"\cf{0}<!--{1}-->\par", (int)ColorKinds.Comment, XmlEncode(xmlComment.Value)));
 }
		/// <summary>
		/// Updates the corresponding tree node's text based on 
		/// the comment's value.
		/// </summary>
		public void UpdateComment(XmlComment comment)
		{
			XmlCommentTreeNode node = FindComment(comment);
			if (node != null) {
				node.Update();
			}
		}
		/// <summary>
		/// Inserts the comment before the currently selected node.
		/// </summary>
		public void InsertCommentBefore(XmlComment comment)
		{
			xmlElementTreeView.InsertCommentBefore(comment);
		}
		/// <summary>
		/// Inserts the comment after the currently selected node.
		/// </summary>
		public void InsertCommentAfter(XmlComment comment)
		{
			xmlElementTreeView.InsertCommentAfter(comment);
		}
		/// <summary>
		/// Removes the specified xml comment from the tree.
		/// </summary>
		public void RemoveComment(XmlComment comment)
		{
			xmlElementTreeView.RemoveComment(comment);
		}
		/// <summary>
		/// Appends a new child comment node to the currently selected
		/// element.
		/// </summary>
		public void AppendChildComment(XmlComment comment)
		{
			xmlElementTreeView.AppendChildComment(comment);
		}
		/// <summary>
		/// Inserts a comment node before the currently selected
		/// node.
		/// </summary>
		public void InsertCommentBefore(XmlComment comment)
		{
			InsertComment(comment, InsertionMode.Before);
		}
		/// <summary>
		/// Locates the specified comment in the tree.
		/// </summary>
		XmlCommentTreeNode FindComment(XmlComment comment)
		{
			XmlCommentTreeNode selectedCommentTreeNode = SelectedNode as XmlCommentTreeNode;
			if (selectedCommentTreeNode != null && selectedCommentTreeNode.XmlComment == comment) {
				return selectedCommentTreeNode;
			} else {
				return FindComment(comment, Nodes);
			}
		}
		/// <summary>
		/// Inserts a new comment node either before or after the 
		/// currently selected node.
		/// </summary>
		void InsertComment(XmlComment comment, InsertionMode insertionMode)
		{
			ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode;
			if (selectedNode != null) {
				ExtTreeNode parentNode = (ExtTreeNode)selectedNode.Parent;
				XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment);
				int index = 0;
				if (parentNode != null) {
					index = parentNode.Nodes.IndexOf(selectedNode);
				} else {
					index = Nodes.IndexOf(selectedNode);
				}
				if (insertionMode == InsertionMode.After) {
					index++;
				}
				if (parentNode != null) {
					newNode.Insert(index, parentNode);
				} else {
					newNode.Insert(index, this);
				}
			}
		}
		/// <summary>
		/// Inserts a comment node after the currently selected
		/// node.
		/// </summary>
		public void InsertCommentAfter(XmlComment comment)
		{
			InsertComment(comment, InsertionMode.After);
		}
Esempio n. 26
0
 public void UpdateComment(XmlComment comment)
 {
     commentNodesUpdated.Add(comment);
 }
		/// <summary>
		/// Looks at all the nodes in the tree view and returns the
		/// tree node that represents the specified comment node.
		/// </summary>
		XmlCommentTreeNode FindComment(XmlComment comment, TreeNodeCollection nodes)
		{
			foreach (ExtTreeNode node in nodes) {
				XmlCommentTreeNode commentTreeNode = node as XmlCommentTreeNode;
				if (commentTreeNode != null) {
					if (commentTreeNode.XmlComment == comment) {
						return commentTreeNode;
					}
				} else {
					// Look for a match in the node's child nodes.
					XmlCommentTreeNode childCommentTreeNode = FindComment(comment, node.Nodes);
					if (childCommentTreeNode != null) {
						return childCommentTreeNode;
					}
				}
			}
			return null;
		}
Esempio n. 28
0
File: Remove.cs Progetto: rh/mix
 protected override void ExecuteCore(XmlComment comment)
 {
     comment.ParentNode.RemoveChild(comment);
 }
		/// <summary>
		/// Shows the corresponding tree node with the ghosted image 
		/// that indicates it is being cut.
		/// </summary>
		void ShowCutComment(XmlComment comment, bool showGhostImage)
		{
			XmlCommentTreeNode node = FindComment(comment);
			node.ShowGhostImage = showGhostImage;
		}
		/// <summary>
		/// Updates the corresponding tree node's text.
		/// </summary>
		public void UpdateComment(XmlComment comment)
		{
			xmlElementTreeView.UpdateComment(comment);
		}