Пример #1
0
		/// <summary>
		/// Gets the last child tree node. The LastNode is the last child Node in the NodeCollection stored in the Nodes property of the current tree node. If the Node has no child tree node, the LastNode property returns a null reference (Nothing in Visual Basic).
		/// </summary>
		/// <param name="node">Reference node.</param>
		/// <returns>Last node if found or null if there is no last node.</returns>
		public static Node GetLastNode(Node node)
		{
			if(node.Nodes.Count>0)
			{
				return node.Nodes[node.Nodes.Count-1];
			}
			return null;
		}
Пример #2
0
		/// <summary>
		/// Creates new instance of the object.
		/// </summary>
		/// <param name="linkedNode">Linkded node to initialize new instace with.</param>
		/// <param name="connectorPoints">Connector points collection to initialize new instance with.</param>
		public LinkedNode(Node linkedNode, ConnectorPointsCollection connectorPoints) : this()
		{
			this.Node = linkedNode;
			if(connectorPoints!=null)
			{
				m_ConnectorPoints = connectorPoints;
				m_ConnectorPoints.SetParentNode(m_Parent);
			}
		}
Пример #3
0
		/// <summary>
		/// Returns next visible sibling tree node.
		/// </summary>
		/// <param name="node">Reference node</param>
		/// <returns>Node object or null if next visible node cannot be found</returns>
		public static Node GetNextVisibleSibling(Node node)
		{
			if(node==null)
				return null;
			Node ret = GetNextNode(node);
			while(ret!=null && !ret.Visible)
				ret = GetNextNode(ret);
			return ret;
		}
Пример #4
0
		public TreeGXNodeMouseEventArgs(Node node, MouseButtons button, int clicks, int delta, int x, int y)
		{
			this.Node = node;
			this.Button = button;
			this.Clicks = clicks;
			this.Delta = delta;
			this.X = x;
			this.Y = y;
		}
Пример #5
0
 private void addnode_Click(object sender, EventArgs e)
 {
     Node node = new Node();
     node.Expanded = true;
     node.Name = (++js).ToString();
     if (nodeinput.Text.Trim() == "")
         node.Text = "文本";
     else
         node.Text = nodeinput.Text.Trim();
     Gib.nowmmap.SelectedNode.Nodes.Add(node);
     Gib.nowmmap.SelectNode(node, eTreeAction.Mouse);
     Gib.nowmmap.Refresh();
 }
Пример #6
0
		private Node CreateNode(Node parentNode)
		{
			IDesignerHost dh=(IDesignerHost)GetService(typeof(IDesignerHost));
			if(dh==null)
				return null;
            
			Node node=null;
			TreeGX tree=((Node)this.Component).TreeControl;
			tree.BeginUpdate();
			try
			{
				IComponentChangeService change=this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
				if(change!=null)
				{
					if(parentNode!=null)
						change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(parentNode).Find("Nodes",true));
					else
						change.OnComponentChanging(this.Component,TypeDescriptor.GetProperties(tree).Find("Nodes",true));
				}

				node=dh.CreateComponent(typeof(Node)) as Node;
				if(node!=null)
				{
					node.Text=node.Name;
					node.Expanded = true;
					if(parentNode==null)
						tree.Nodes.Add(node);
					else
					{
						parentNode.Nodes.Add(node);
						parentNode.Expand();
					}
					
					if(change!=null)
					{
						if(parentNode!=null)
							change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(parentNode).Find("Nodes",true),null,null);
						else
							change.OnComponentChanged(this.Component,TypeDescriptor.GetProperties(tree).Find("Nodes",true),null,null);
					}
				}
			}
			finally
			{
				tree.EndUpdate();
			}

			return node;
		}
Пример #7
0
		/// <summary>
		/// Returns full path to the given node.
		/// </summary>
		/// <param name="node">Node to return path to.</param>
		/// <returns>Full path to the node.</returns>
		public static string GetFullPath(Node node,string pathSeparator)
		{
			if(node==null)
				throw new ArgumentNullException("node");
			
			StringBuilder sb=new StringBuilder(node.Text);
			node=node.Parent;
			while(node!=null)
			{
				sb.Insert(0,pathSeparator+node.Text);
				node=node.Parent;
			}

			return sb.ToString();
		}
Пример #8
0
		/// <summary>
		/// Gets the next sibling tree node. The NextNode is the next sibling Node in the NodeCollection stored in the Nodes property of the tree node's parent Node. If there is no next tree node, the NextNode property returns a null reference (Nothing in Visual Basic).
		/// </summary>
		/// <param name="node">Reference node.</param>
		/// <returns>Node object or null if node cannot be found.</returns>
		public static Node GetNextNode(Node node)
		{
            if (node == null)
                return null;
            NodeCollection parentNodes = null;
            if (node.Parent != null)
                parentNodes = node.Parent.Nodes;
            else if (node.internalTreeControl != null)
                parentNodes = node.internalTreeControl.Nodes;

            if (parentNodes != null)
            {
                int index = parentNodes.IndexOf(node);
                if (index < parentNodes.Count - 1)
                    return parentNodes[index + 1];
            }

            return null;
		}
Пример #9
0
		/// <summary>
		/// Load single node and it's child nodes if any.
		/// </summary>
		/// <param name="nodeToLoad">New instance of node that is populated with loaded data.</param>
		/// <param name="context">Provides deserialization context.</param>
		public static void LoadNode(Node nodeToLoad, NodeSerializationContext context)
		{
			XmlElement xmlNode = context.RefXmlElement;
			
			ElementSerializer.Deserialize(nodeToLoad, xmlNode);

			foreach(XmlNode xmlChild in xmlNode.ChildNodes)
			{
				XmlElement xmlElem = xmlChild as XmlElement;
				if(xmlElem == null)
					continue;
				if(xmlElem.Name==XmlNodeName)
				{
					Node node=new Node();
					nodeToLoad.Nodes.Add(node);
					context.RefXmlElement = xmlElem;
					LoadNode(node, context);
				}
				else if(xmlElem.Name == XmlCellsName)
				{
					LoadCells(nodeToLoad, xmlElem);
				}
				else if(xmlElem.Name == XmlCustomName)
				{
					if(context.HasDeserializeNodeHandlers)
					{
						SerializeNodeEventArgs e = new SerializeNodeEventArgs(nodeToLoad, xmlNode, xmlElem);
						context.TreeGX.InvokeDeserializeNode(e);
					}
				}
			}
			context.RefXmlElement = xmlNode;
		}
Пример #10
0
		/// <summary>
		/// Load nodes from XmlElement.
		/// </summary>
		/// <param name="tree">Reference to TreeGX to be populated.</param>
		/// <param name="parent">XmlElement that tree was serialized to.</param>
		public static void Load(TreeGX tree, XmlElement parent)
		{
			tree.BeginUpdate();
			tree.DisplayRootNode = null;
			tree.Nodes.Clear();
			
			NodeSerializationContext context = new NodeSerializationContext();
			context.TreeGX = tree;
			context.HasDeserializeNodeHandlers  = tree.HasDeserializeNodeHandlers;
			context.HasSerializeNodeHandlers = tree.HasSerializeNodeHandlers;
			
			try
			{
				foreach(XmlNode xmlNode in parent.ChildNodes)
				{
					if(xmlNode.Name==XmlNodeName && xmlNode is XmlElement)
					{
						Node node=new Node();
						tree.Nodes.Add(node);
						context.RefXmlElement = xmlNode as XmlElement;
						LoadNode(node, context);
					}
				}
			}
			finally
			{
				tree.EndUpdate();
			}
		}
Пример #11
0
		/// <summary>
		/// Serializes Node and all child nodes to XmlElement object.
		/// </summary>
		/// <param name="node">Node to serialize.</param>
		/// <param name="context">Provides serialization context.</param>
		public static void Save(Node node, NodeSerializationContext context)
		{
			XmlElement parent = context.RefXmlElement;
			
			XmlElement xmlNode=parent.OwnerDocument.CreateElement(XmlNodeName);
			parent.AppendChild(xmlNode);
			
			ElementSerializer.Serialize(node, xmlNode);
			
			if(node.Cells.Count>1)
			{
				XmlElement xmlCells = parent.OwnerDocument.CreateElement(XmlCellsName);
				xmlNode.AppendChild(xmlCells);
				
				for(int i=1; i<node.Cells.Count;i++)
				{
					Cell cell=node.Cells[i];
					XmlElement xmlCell= parent.OwnerDocument.CreateElement(XmlCellName);
					xmlCells.AppendChild(xmlCell);
					ElementSerializer.Serialize(cell, xmlCell);
					if(cell.ShouldSerializeImages())
					{
						XmlElement xmlCellImages = parent.OwnerDocument.CreateElement(XmlCellImagesName);
						xmlCell.AppendChild(xmlCellImages);
						ElementSerializer.Serialize(cell.Images, xmlCellImages);
					}
				}
			}

            if (context.HasSerializeNodeHandlers)
            {
                XmlElement customXml = parent.OwnerDocument.CreateElement(XmlCustomName);
                SerializeNodeEventArgs e = new SerializeNodeEventArgs(node, xmlNode, customXml);
                context.TreeGX.InvokeSerializeNode(e);
                if (customXml.Attributes.Count > 0 || customXml.ChildNodes.Count > 0)
                    xmlNode.AppendChild(customXml);
            }
			
			context.RefXmlElement = xmlNode;
			foreach(Node childNode in node.Nodes)
			{
				Save(childNode, context);
			}
			context.RefXmlElement = parent;
		}
Пример #12
0
		/// <summary>
		/// Sets the parent of the cell.
		/// </summary>
		/// <param name="parent">Parent node.</param>
		internal void SetParent(Node parent)
		{
			m_Parent=parent;
		}
Пример #13
0
		public SerializeNodeEventArgs(Node node, System.Xml.XmlElement itemXmlElement, System.Xml.XmlElement customXmlElement)
		{
			this.Node = node;
			this.ItemXmlElement = itemXmlElement;
			this.CustomXmlElement = customXmlElement;
		}
Пример #14
0
        /// <summary>
        /// Gets the next visible tree node. The NextVisibleNode can be a child, sibling, or a tree node from another branch. If there is no next tree node, the NextVisibleNode property returns a null reference (Nothing in Visual Basic).
        /// </summary>
        /// <param name="node">Reference node.</param>
        /// <returns>Node object or null if node cannot be found.</returns>
        public static Node GetAnyNextNode(Node node)
        {
            Node nextNode = null;

            // Walk into the child nodes
            if (node.Nodes.Count > 0)
            {
                return node.Nodes[0];
            }

            // Get next sibling
            nextNode = GetNextNode(node);

            // Walk-up...
            if (nextNode == null)
            {
                while (nextNode == null && node != null)
                {
                    node = node.Parent;
                    nextNode = GetNextNode(node);
                }
            }

            return nextNode;
        }
Пример #15
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.treeGX1          = new DevComponents.Tree.TreeGX();
     this.node1            = new DevComponents.Tree.Node();
     this.nodeConnector1   = new DevComponents.Tree.NodeConnector();
     this.nodeConnector2   = new DevComponents.Tree.NodeConnector();
     this.elementStyle1    = new DevComponents.Tree.ElementStyle();
     this.nodeCustomRender = new DevComponents.Tree.Node();
     this.node3            = new DevComponents.Tree.Node();
     ((System.ComponentModel.ISupportInitialize)(this.treeGX1)).BeginInit();
     this.SuspendLayout();
     //
     // treeGX1
     //
     this.treeGX1.AllowDrop         = true;
     this.treeGX1.AutoScrollMinSize = new System.Drawing.Size(44, 22);
     //
     // treeGX1.BackgroundStyle
     //
     this.treeGX1.BackgroundStyle.BackColor2SchemePart   = DevComponents.Tree.eColorSchemePart.BarBackground2;
     this.treeGX1.BackgroundStyle.BackColorGradientAngle = 90;
     this.treeGX1.BackgroundStyle.BackColorSchemePart    = DevComponents.Tree.eColorSchemePart.BarBackground;
     this.treeGX1.CommandBackColorGradientAngle          = 90;
     this.treeGX1.CommandMouseOverBackColor2SchemePart   = DevComponents.Tree.eColorSchemePart.ItemHotBackground2;
     this.treeGX1.CommandMouseOverBackColorGradientAngle = 90;
     this.treeGX1.Dock = System.Windows.Forms.DockStyle.Fill;
     this.treeGX1.ExpandLineColorSchemePart = DevComponents.Tree.eColorSchemePart.BarDockedBorder;
     this.treeGX1.Location = new System.Drawing.Point(0, 0);
     this.treeGX1.Name     = "treeGX1";
     this.treeGX1.Nodes.AddRange(new DevComponents.Tree.Node[] {
         this.node1
     });
     this.treeGX1.NodesConnector = this.nodeConnector2;
     this.treeGX1.NodeStyle      = this.elementStyle1;
     this.treeGX1.PathSeparator  = ";";
     this.treeGX1.RootConnector  = this.nodeConnector1;
     this.treeGX1.Size           = new System.Drawing.Size(328, 222);
     this.treeGX1.Styles.Add(this.elementStyle1);
     this.treeGX1.SuspendPaint = false;
     this.treeGX1.TabIndex     = 0;
     this.treeGX1.Text         = "treeGX1";
     //
     // node1
     //
     this.node1.CellPartLayout = DevComponents.Tree.eCellPartLayout.Default;
     this.node1.Expanded       = true;
     this.node1.Name           = "node1";
     this.node1.Nodes.AddRange(new DevComponents.Tree.Node[] {
         this.nodeCustomRender,
         this.node3
     });
     this.node1.Text = "node1";
     //
     // nodeConnector1
     //
     this.nodeConnector1.LineWidth = 5;
     //
     // nodeConnector2
     //
     this.nodeConnector2.LineWidth = 5;
     //
     // elementStyle1
     //
     this.elementStyle1.BackColor2SchemePart   = DevComponents.Tree.eColorSchemePart.BarBackground2;
     this.elementStyle1.BackColorGradientAngle = 90;
     this.elementStyle1.BackColorSchemePart    = DevComponents.Tree.eColorSchemePart.BarBackground;
     this.elementStyle1.BorderBottom           = DevComponents.Tree.eStyleBorderType.Solid;
     this.elementStyle1.BorderBottomWidth      = 1;
     this.elementStyle1.BorderColorSchemePart  = DevComponents.Tree.eColorSchemePart.BarDockedBorder;
     this.elementStyle1.BorderLeft             = DevComponents.Tree.eStyleBorderType.Solid;
     this.elementStyle1.BorderLeftWidth        = 1;
     this.elementStyle1.BorderRight            = DevComponents.Tree.eStyleBorderType.Solid;
     this.elementStyle1.BorderRightWidth       = 1;
     this.elementStyle1.BorderTop      = DevComponents.Tree.eStyleBorderType.Solid;
     this.elementStyle1.BorderTopWidth = 1;
     this.elementStyle1.CornerDiameter = 4;
     this.elementStyle1.CornerType     = DevComponents.Tree.eCornerType.Rounded;
     this.elementStyle1.Font           = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.elementStyle1.Name           = "elementStyle1";
     this.elementStyle1.PaddingBottom  = 3;
     this.elementStyle1.PaddingLeft    = 3;
     this.elementStyle1.PaddingRight   = 3;
     this.elementStyle1.PaddingTop     = 3;
     this.elementStyle1.TextColor      = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(128)));
     //
     // nodeCustomRender
     //
     this.nodeCustomRender.CellPartLayout = DevComponents.Tree.eCellPartLayout.Default;
     this.nodeCustomRender.Expanded       = true;
     this.nodeCustomRender.Name           = "nodeCustomRender";
     this.nodeCustomRender.Text           = "Custom Rendered Node";
     //
     // node3
     //
     this.node3.CellPartLayout = DevComponents.Tree.eCellPartLayout.Default;
     this.node3.Expanded       = true;
     this.node3.Name           = "node3";
     this.node3.Text           = "node3";
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(328, 222);
     this.Controls.Add(this.treeGX1);
     this.Name  = "Form1";
     this.Text  = "Custom Redering";
     this.Load += new System.EventHandler(this.Form1_Load);
     ((System.ComponentModel.ISupportInitialize)(this.treeGX1)).EndInit();
     this.ResumeLayout(false);
 }
Пример #16
0
		/// <summary>
		/// Returns true if node has at least single visible child node.
		/// </summary>
		/// <param name="node">Reference node.</param>
		/// <returns>True if at least single child node is visible otherwise false.</returns>
		public static bool GetAnyVisibleNodes(Node node)
		{
			if(node.Nodes.Count==0)
				return false;
			foreach(Node n in node.Nodes)
			{
				if(n.Visible)
					return true;
			}
			return false;
		}
Пример #17
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="action">Action type.</param>
		/// <param name="node">Context node.</param>
		public CommandButtonEventArgs(eTreeAction action, Node node)
		{
			this.Action=action;
			this.Node=node;
		}
Пример #18
0
		public TreeGXDragDropEventArgs(eTreeAction action, Node node, Node oldParentNode, Node newParentNode):base(action,node)
		{
			this.NewParentNode = newParentNode;
			this.OldParentNode = oldParentNode;
		}
Пример #19
0
		/// <summary>
		/// Sets the parent node.
		/// </summary>
		/// <param name="node">Reference to parent node.</param>
		internal void SetParent(Node node)
		{
			m_Parent = node;
			m_ConnectorPoints.SetParentNode(node);
		}
Пример #20
0
		/// <summary>
		/// Gets the count of visible child nodes (Visible=true) for given node.
		/// </summary>
		/// <param name="parent">Reference to Node object.</param>
		/// <returns>Number of visible nodes.</returns>
		public static int GetVisibleChildNodesCount(Node parent)
		{
			int count = 0;
			foreach(Node node in parent.Nodes)
			{
				if(node.Visible)
					count++;
			}
			return count;
		}
Пример #21
0
		/// <summary>
		/// Creates new instance of the object.
		/// </summary>
		/// <param name="linkedNode">Linkded node to initialize new instace with.</param>
		public LinkedNode(Node linkedNode) : this()
		{
			this.Node = linkedNode;
		}
Пример #22
0
		private static void LoadCells(Node parentNode, XmlElement xmlCells)
		{
			foreach(XmlNode xmlChild in xmlCells.ChildNodes)
			{
				if(xmlChild.Name==XmlCellName && xmlChild is XmlElement)
				{
					Cell cell=new Cell();
					parentNode.Cells.Add(cell);
					ElementSerializer.Deserialize(cell, xmlChild as XmlElement);
					// Load images if any
					foreach(XmlElement xmlImage in xmlChild.ChildNodes)
					{
						if(xmlImage.Name==XmlCellImagesName)
						{
							ElementSerializer.Deserialize(cell.Images, xmlImage);
							break;
						}
					}
				}
			}
		}
Пример #23
0
 void savenode(Node node)
 {
     tempstrs[saves++] = node.Text;
     tempstrs[saves++] = node.Nodes.Count.ToString();
     foreach (Node subnode in node.Nodes)
         if (subnode.Visible)
             savenode(subnode);
 }
Пример #24
0
		/// <summary>
		/// Returns number of visible child nodes for given node.
		/// </summary>
		/// <param name="node">Reference node.</param>
		/// <returns>Number of visible child nodes.</returns>
		public static int GetVisibleNodesCount(Node node)
		{
			if(node.Nodes.Count==0)
				return 0;
			int count=0;
			foreach(Node n in node.Nodes)
			{
				if(n.Visible)
					count++;
			}
			return count;
		}
Пример #25
0
        void setmapbegin()
        {
            root = new Node();
            root.Expanded = true;
            root.Name = root.Text = "文本";
            Gib.nowmmap.Nodes.Add(root);
            Gib.nowmmap.SelectNode(root, eTreeAction.Mouse);

            Node node1 = new Node();
            node1.Expanded = true;
            node1.Name = node1.Text = "1";
            Gib.nowmmap.SelectedNode.Nodes.Add(node1);
            Gib.nowmmap.Refresh();

            Node node2 = new Node();
            node2.Expanded = true;
            node2.Name = node2.Text = "2";
            Gib.nowmmap.SelectedNode.Nodes.Add(node2);
            Gib.nowmmap.Refresh();

            Node node3 = new Node();
            node3.Expanded = true;
            node3.Name = node3.Text = "3";
            Gib.nowmmap.SelectedNode.Nodes.Add(node3);
            Gib.nowmmap.Refresh();

            Node node4 = new Node();
            node4.Expanded = true;
            node4.Name = node4.Text = "4";
            Gib.nowmmap.SelectedNode.Nodes.Add(node4);
            Gib.nowmmap.Refresh();
        }
Пример #26
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="action">Default action</param>
		/// <param name="node">Default node.</param>
		public TreeGXNodeCancelEventArgs(eTreeAction action, Node node):base(action,node)
		{
		}
Пример #27
0
		/// <summary>
		/// Gets the first visible child node or returns null if node cannot be found.
		/// </summary>
		/// <param name="parent">Reference to Node object.</param>
		/// <returns>First visible node or null if node cannot be found.</returns>
		public static Node GetFirstVisibleChildNode(Node parent)
		{
			foreach(Node node in parent.Nodes)
			{
				if(node.Visible)
					return node;
			}
			return null;
		}
Пример #28
0
		/// <summary>
		/// Sets the node collection belongs to.
		/// </summary>
		/// <param name="parent">ColumnHeader that is parent of this collection.</param>
		internal void SetParentNode(Node parent)
		{
			m_ParentNode=parent;
		}
Пример #29
0
 void openmap()
 {
     Gib.nowmmap.Nodes.Clear();
     js = opens = 1;
     root = new Node();
     root.Expanded = true;
     root.Name = (++js).ToString();
     root.Text = openstrs[0];
     Gib.nowmmap.Nodes.Add(root);
     Gib.nowmmap.SelectNode(root, eTreeAction.Mouse);
     int temp = Convert.ToInt32(openstrs[opens++]), i;
     for (i = 0; i < temp; ++i)
         opennode(root);
     Gib.nowmmap.SelectNode(root, eTreeAction.Mouse);
     Gib.nowmmap.Refresh();
 }
Пример #30
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="action">Default action</param>
		/// <param name="node">Default node.</param>
		public TreeGXNodeEventArgs(eTreeAction action, Node node)
		{
			this.Action = action;
			this.Node = node;
		}
Пример #31
0
 void opennode(Node rnode)
 {
     Node node = new Node();
     node.Expanded = true;
     node.Name = (++js).ToString();
     node.Text = openstrs[opens++];
     rnode.Nodes.Add(node);
     int temp = Convert.ToInt32(openstrs[opens++]), i;
     for (i = 0; i < temp; ++i)
         opennode(node);
 }