public void UpdateAdded(MemoTag tag) { _tree.BeginUpdate(); var node = new TreeNodeEx(tag.Name); node.Tag = tag; node.ImageIndex = _tagImageIndex; node.SelectedImageIndex = _tagImageIndex; if (tag.SuperTag == null) { _root.Nodes.Add(node); } else { var parentNode = GetNode(tag.SuperTag); if (parentNode != null) { parentNode.Nodes.Add(node); } } _tree.EndUpdate(); }
private void InsertParentNode(TreeNodeEx node) { //this is where we need to sort on ID, so we INSERT the LP node at the correct place int insertIndex = -1; for (int index = 0; index < TreeView.Nodes.Count - 1; index++) { var lpNodes0 = TreeView.Nodes[index] as TreeNodeEx; var lpNodes1 = TreeView.Nodes[index + 1] as TreeNodeEx; //This means the current material ID is smaller than the first one in the list, so we can add it first, no need to look further if (node.matID < lpNodes0.matID) { insertIndex = index; break; } //Somewhere in between the nodes if (node.matID > lpNodes0.matID && node.matID < lpNodes1.matID) { insertIndex = index + 1; } } //At the end of the list if (insertIndex == -1) { insertIndex = TreeView.Nodes.Count; } //Add the LP node to the tree TreeView.Nodes.Insert(insertIndex, node); }
private TreeNodeEx FindChildAtPoint(TreeNodeCollectionEx nodes, ref int currentPosition, Drawing.Point p) { foreach (TreeNodeEx node in nodes) { if (node.Visible) { currentPosition += this.HeightIndent + this.Font.Height; if (currentPosition > p.Y) { return(node); } if (node.Expanded) { TreeNodeEx node2 = FindChildAtPoint(node.Nodes, ref currentPosition, p); if (node2 != null) { return(node2); } } } } return(null); }
private void AddAsnNode(Asn1Object asn, TreeNodeEx parent) { var nodeAsText = asn.ToString(); if ((asn is Asn1OctetString || asn is Asn1BitString) && nodeAsText.Length > 40) { nodeAsText = nodeAsText.Substring(0, 40) + "..."; } var treeNode = new TreeNodeEx(nodeAsText); var imageIndex = GetImageIndex(asn); treeNode.SelectedImageIndex = imageIndex; treeNode.ImageIndex = imageIndex; var asnt = asn as Asn1StructuredObject; if (asnt != null) { foreach (var asn2 in asnt.Nodes) { AddAsnNode(asn2, treeNode); } } treeNode.Tag = asn; parent.Nodes.Add(treeNode); }
/// <summary> /// Called when [document added]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Delta.CertXplorer.Common.DocumentModel.DocumentEventArgs"/> instance containing the event data.</param> private void OnDocumentAdded(object sender, DocumentEventArgs e) { if (!documents.ContainsKey(e.Document)) { var tnRoot = filesRoot; var caption = "Document"; if (e.Document is IDocument) { caption = ((IDocument)e.Document).Caption; } var tn = new TreeNodeEx(caption); if (e.Document.Source is FileDocumentSource) { tnRoot = filesRoot; } else if (e.Document.Source is X509DocumentSource) { tnRoot = certificatesRoot; } tn.Tag = e.Document; tn.ImageIndex = documentIndex; tn.SelectedImageIndex = documentIndex; documents.Add(e.Document, tn); tnRoot.Nodes.Add(tn); tnRoot.Expand(); } }
public void CreateFolder(TreeNode parent) { var created = default(MemoFolder); _root.Expand(); if (parent == _root) { created = _facade.Workspace.CreateFolder(); created.Name = "新しいクリアファイル"; } else if (parent.Tag is MemoFolder) { var parentFolder = (MemoFolder)parent.Tag; created = _facade.Workspace.CreateFolder(); created.Name = "新しいクリアファイル"; created.ParentFolder = parentFolder; } else if (parent.Tag is Memo) { return; } _tree.BeginUpdate(); var createdNode = new TreeNodeEx(created.Name); createdNode.Tag = created; createdNode.ImageIndex = _folderImageIndex; createdNode.SelectedImageIndex = _folderImageIndex; parent.Nodes.Add(createdNode); _tree.SelectedNode = createdNode; _tree.EndUpdate(); createdNode.BeginEdit(); }
// ------------------------------ // private // ------------------------------ private static void AddNodeRecursively( MemoTag tag, int imageIndex, TreeNodeCollection parentCol, HashSet <MemoTag> targets, HashSet <MemoTag> addeds ) { if (addeds.Contains(tag)) { return; } if (targets != null && !targets.Contains(tag)) { return; } var node = new TreeNodeEx(tag.Name); node.Tag = tag; if (imageIndex > -1) { node.ImageIndex = imageIndex; node.SelectedImageIndex = imageIndex; } parentCol.Add(node); addeds.Add(tag); foreach (var child in tag.SubTags) { AddNodeRecursively(child, imageIndex, node.Nodes, targets, addeds); } }
public TreeNodeEx AddChildNode(ParentNode parentNode, uint hpHandle, ushort id) { //Check if the lpNode already exists - otherwise we're trying to add a childNode to a non-existing parentNode if (m_NodeDictionary.ContainsKey(new Tuple <uint, ushort>(parentNode.Handle, id))) { //Get LP TreeNode var treeLPNode = m_NodeDictionary[new Tuple <uint, ushort>(parentNode.Handle, id)]; //Get childNode var childNode = parentNode.GetChild(id, hpHandle); //Create new HP treeNode var treeHPNode = new TreeNodeEx(childNode.Handle, id, childNode.Name, true) { ParentHandle = parentNode.Handle }; //Add the newly made HP treeNode to the m_NodeDictionary m_NodeDictionary.Add(new Tuple <uint, ushort>(hpHandle, id), treeHPNode); //Add the hpTreeNode to the LPNode treeLPNode.Nodes.Add(treeHPNode); return(treeHPNode); } return(null); }
protected override void OnMouseMove(WinForms.MouseEventArgs args) { TreeNodeEx node = this.GetNodeAt(new Drawing.Point(args.X, args.Y)); if (this.ChangeColorOnMouseOver) { if (mouseOverNode != null) { mouseOverNode.Invalidate(); } if (node != null && node != mouseOverNode) { node.Invalidate(); } else { mouseOverNode = null; } mouseOverNode = node; this.Update(); } if (node != null) { this.toolTip.SetToolTip(this, node.ToolTipText); } base.OnMouseMove(args); }
void FormShare_Load(object sender, EventArgs e) { string sql = "select StetName,MAC,PCName,StetChineseName,Owner from StethoscopeManager where IfDel=0 and StetName!={0}"; using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel)) { MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum); OperationContext.Current.OutgoingMessageHeaders.Add(header); header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode); OperationContext.Current.OutgoingMessageHeaders.Add(header); var ds = Mediator.remoteService.ExecuteDataset(sql, new string[] { StetName }); if (ds != null && ds.Tables.Count > 0) { var Macs = ds.Tables[0].Select().Select(r => r["MAC"] + "").Distinct().ToArray(); foreach (var mac in Macs) { var pcName = ds.Tables[0].Select("MAC='" + mac + "'").First()["PCName"] + ""; var rootNode = new TreeNodeEx(pcName); foreach (DataRow row in ds.Tables[0].Select("MAC='" + mac + "'")) { rootNode.Nodes.Add(new TreeNodeEx() { StetName = row["StetName"] + "", isConnected = true, StetChineseName = row["StetChineseName"] + "", StetOwner = row["Owner"] + "", }); } treeView1.Nodes.Add(rootNode); } treeView1.ExpandAll(); } } }
private void InitializeTreeView() { m_treeView.CheckBoxes = true; m_treeView.ImageList = DefaultImageList.Instance.ImageList; m_treeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(this.OnNodeMouseClick); m_treeView.DrawMode = TreeViewDrawMode.OwnerDrawText; m_treeView.DrawNode += new DrawTreeNodeEventHandler( delegate(object sender, DrawTreeNodeEventArgs e) { TreeNodeEx treeNode = e.Node as TreeNodeEx; if (treeNode != null) { if (!treeNode.CheckBox) { TreeNodeEx.ShowCheckBox(treeNode); } } e.DrawDefault = true; }); m_treeView.TreeViewExNodesCheckedEvent += new TreeViewExTimesheetDateTreeNodesCheckedEventHandler( delegate(TreeViewEx treeView, TreeViewExTimesheetDateTreeNodesCheckedEventArgs e) { UpdateCalculations(e.TimesheetDateTreeNodes); }); m_treeView.AfterCheck += new TreeViewEventHandler( delegate(object sender, TreeViewEventArgs e) { TreeViewEx treeView = (TreeViewEx)sender; UpdateCalculations(treeView.GetCheckedTimesheetDateTreeNodes()); }); }
protected override void OnDragDrop(WinForms.DragEventArgs args) { if (AllowMovementOfNodes) { TreeNodeEx node = (TreeNodeEx)args.Data.GetData(typeof(TreeNodeEx)); if (node != dragOverNode) { // drop the node into the node its over if (this.dragOverNode.Parent != null) { node.Remove(); this.dragOverNode.Parent.Nodes.Insert(this.dragOverNode.Parent.Nodes.IndexOf(dragOverNode), node); } else { node.Remove(); this.Nodes.Insert(this.Nodes.IndexOf(dragOverNode), node); } if (this.NodeMove != null) { this.NodeMove(this, new TreeViewExEventArgs(node)); } this.Invalidate(); this.Update(); } this.dragOverNode = null; } base.OnDragDrop(args); }
private void configPageTree_AfterSelect(object sender, TreeViewEventArgs e) { var node = e.Node as TreeNodeEx; if (node != null) { if (prevPage != null) { prevPage.Visible = false; } prevPage = node.LinkedPage; prevPage.Parent = configPageOwner; prevPage.Dock = DockStyle.Fill; prevPage.Visible = true; StringBuilder sb = new StringBuilder(); sb.Append(node.LinkedPage.Description); TreeNodeEx cn = node.Parent as TreeNodeEx; while (cn != null) { sb.Insert(0, cn.LinkedPage.Description + " - "); cn = cn.Parent as TreeNodeEx; } titleLabel.Text = sb.ToString(); } }
public void Test_UIControls() { ComboItem <object> comboItem = new ComboItem <object>("Test", null); Assert.IsNotNull(comboItem); Assert.AreEqual("Test", comboItem.ToString()); GKListItem listItem = new GKListItem("Test", null); Assert.IsNotNull(listItem); Assert.AreEqual("Test", listItem.ToString()); GKListSubItem listSubItem = new GKListSubItem("Test"); Assert.IsNotNull(listSubItem); MenuItemEx tsMenuItem = new MenuItemEx("Test", null); Assert.IsNotNull(tsMenuItem); TreeNodeEx treeNode = new TreeNodeEx("Test", null); Assert.IsNotNull(treeNode); ModifyEventArgs args = new ModifyEventArgs(RecordAction.raAdd, null); Assert.IsNotNull(args); }
internal void ExecuteExpand(TreeNodeEx node) { if (this.Expand != null) { this.Expand(this, new TreeViewExEventArgs(node)); } }
private void CollapseChildren(TreeNodeEx node) { foreach (TreeNodeEx childNode in node.Nodes) { childNode.Collapse(); CollapseChildren(childNode); } }
private void ExpandChildren(TreeNodeEx node) { foreach (TreeNodeEx childNode in node.Nodes) { childNode.Expand(); ExpandChildren(childNode); } }
public void Remove(TreeNodeEx o) { lock (this) { PreRemoveTreeNode(o); arrayList.Remove(o); } }
public int Add(TreeNodeEx o) { lock (this) { PreAddTreeNode(o); return(arrayList.Add(o)); } }
public void Insert(int index, TreeNodeEx o) { lock (this) { PreAddTreeNode(o); arrayList.Insert(index, o); } }
public void RemoveAt(int index) { lock (this) { TreeNodeEx node = (TreeNodeEx)arrayList[index]; PreRemoveTreeNode(node); arrayList.RemoveAt(index); } }
// ======================================== // constructor // ======================================== public FolderTreePresenter(TreeView tree, TreeNodeEx root) { Contract.Requires(tree != null); Contract.Requires(root != null); _facade = MemopadApplication.Instance; _tree = tree; _root = root; }
private void PreRemoveTreeNode(TreeNodeEx o) { if (o.iTreeView != null) { o.iTreeView.Invalidate(); o.iTreeView.Update(); } // o.iTreeView = null; }
public virtual ContextMenuStrip GetContextMenuStrip(TreeNodeEx node) { // Example //ContextMenuStrip strip = new ContextMenuStrip(); //strip.Items.Add("Menu 1"); //strip.Items.Add("Menu 2"); //return strip; return null; }
protected void GetCheckedTimesheetDateTreeNodes(List<TimesheetDateTreeNode> checkedTreeNodes, TreeNodeEx parentTreeNode) { foreach (TreeNodeEx childTreeNode in parentTreeNode.Nodes) { GetCheckedTimesheetDateTreeNodes(checkedTreeNodes, childTreeNode); } if (parentTreeNode.Checked && parentTreeNode is TimesheetDateTreeNode) { checkedTreeNodes.Add((TimesheetDateTreeNode)parentTreeNode); } }
protected override void OnMouseDown(WinForms.MouseEventArgs args) { TreeNodeEx node = GetNodeAt(new Drawing.Point(args.X, args.Y)); switch (args.Button) { case WinForms.MouseButtons.Left: if ( (node != null && // clicked on image without showplusminus !this.imageList.Images.Empty && !this.ShowPlusMinus && args.X - node.Location.X < this.imageList.ImageSize.Width) || // or clicked on the plus/minus (node != null && this.ShowPlusMinus && args.X - node.Location.X < 15)) { node.Toggle(); } else { // clicked on text if (this.selectedNode != null) { this.selectedNode.Invalidate(); } this.selectedNode = node; // then redraw area if (ChangeColorOnSelected && this.selectedNode != null) { selectedNode.Invalidate(); this.selectedNode.ExecuteSelected(new EventArgs()); this.Update(); } } if (node != null && this.AllowMovementOfNodes) { this.DoDragDrop(node, WinForms.DragDropEffects.Link); } break; case WinForms.MouseButtons.Right: // right button, show context menu if (node.ContextMenu != null) { node.ContextMenu.Show(this, new Drawing.Point(args.X, args.Y)); } break; } base.OnMouseDown(args); }
public ContextMenuStrip GetContextMenuStrip(TreeNodeEx node) { if (node.Tag != null && node.Tag is IDocument) { return(menuStrip); } else { return(null); } }
public void UpdateAdded(MemoSmartFolder smartFolder) { var node = new TreeNodeEx(smartFolder.Name); node.Tag = smartFolder; node.ImageIndex = _smartFolderImageIndex; node.SelectedImageIndex = _smartFolderImageIndex; _tree.BeginUpdate(); _root.Nodes.Add(node); _tree.EndUpdate(); }
protected override void OnMouseLeave(EventArgs args) { this.toolTip.SetToolTip(this, string.Empty); if (this.mouseOverNode != null) { this.mouseOverNode.Invalidate(); this.mouseOverNode = null; this.Update(); } base.OnMouseLeave(args); }
public TreeViewExContextMenu(TreeNodeEx treeNode) { this.TreeNode = treeNode; this.ContextMenu = new ContextMenu(); this.ContextMenu.Tag = this; this.CheckAllMenuItem = new MenuItem("&Check All"); this.UnCheckAllMenuItem = new MenuItem("&UnCheck All"); this.CollapseAllMenuItem = new MenuItem("Co&llapse All"); this.ExpandAllMenuItem = new MenuItem("E&xpand All"); }
public TreeViewExContextMenu(TreeNodeEx treeNode) { this.TreeNode = treeNode; this.ContextMenu = new ContextMenu(); this.ContextMenu.Tag = this; this.CheckAllMenuItem = new MenuItem("&Check All"); this.UnCheckAllMenuItem = new MenuItem("&UnCheck All"); this.CollapseAllMenuItem = new MenuItem("Co&llapse All"); this.ExpandAllMenuItem = new MenuItem("E&xpand All"); }
public void UpdateNode(ParentNode parentNode, ushort matID, bool selectChild = false) { if (m_NodeDictionary.ContainsKey(new Tuple <uint, ushort>(parentNode.Handle, matID))) { //Get the treeNode to update: var lpTreeNode = m_NodeDictionary[new Tuple <uint, ushort>(parentNode.Handle, matID)]; //Default back to white if the parentNode is no longer a PlaceHolder node. if (!parentNode.IsPlaceHolder(matID)) { lpTreeNode.Text = String.Format("{0} - MatID: {1}", parentNode.Name, matID + 1); lpTreeNode.ForeColor = Color.FromArgb(220, 220, 220); } else { lpTreeNode.Text = String.Format("{0} - MatID: {1}", "Missing LP", matID + 1); lpTreeNode.ForeColor = Color.FromArgb(235, 63, 63); } //Update the values lpTreeNode.uHandle = parentNode.Handle; lpTreeNode.matID = matID; //Get all children of parentNode var childHandles = parentNode.GetChildHandles(matID); TreeNodeEx treeHPNode = null; foreach (uint childHandle in childHandles) { //Get ChildNode at matId and handle var childNode = parentNode.GetChild(matID, childHandle); if (m_NodeDictionary.ContainsKey(new Tuple <uint, ushort>(childNode.Handle, matID))) { treeHPNode = m_NodeDictionary[new Tuple <uint, ushort>(childNode.Handle, matID)]; treeHPNode.Name = childNode.Name; treeHPNode.uHandle = childNode.Handle; treeHPNode.matID = matID; treeHPNode.ParentHandle = parentNode.Handle; } else { //The child node doesn't exists, we need to create one treeHPNode = AddChildNode(parentNode, childNode.Handle, matID); } } TreeView.SelectedNode = !selectChild ? lpTreeNode : treeHPNode; } else { throw new Exception("The node you tried to update was not present in the m_NodeDictionary, did you mean to call AddNode()?"); } }
public TreeNodeEx this[int index] { get { return((TreeNodeEx)arrayList[index]); } set { lock (this) { TreeNodeEx node = value; PreAddTreeNode(node); arrayList[index] = node; } } }
public TreeNodeEx CreateDocumentNodes(Asn1Document document, string rootNodeText) { var rootNode = new TreeNodeEx(rootNodeText); rootNode.SelectedImageIndex = documentImageIndex; rootNode.ImageIndex = documentImageIndex; rootNode.Tag = document; foreach (var node in document.Nodes) AddAsnNode(node, rootNode); Nodes.Add(rootNode); return rootNode; }
public static void UnCheckAll(TreeNodeEx treeNode) { lock (m_syncRoot) { TreeViewEx treeView = (TreeViewEx)treeNode.TreeView; if (treeView != null) { treeView.SuspendCheckEvents(); } CheckBoxes.UnCheckAll((TreeNode)treeNode); if (treeView != null) { treeView.InvokeTreeViewExNodesChecked(); treeView.ResumeCheckEvents(); } } }
private void AddAsnNode(Asn1Object asn, TreeNodeEx parent) { var nodeAsText = asn.ToString(); if ((asn is Asn1OctetString || asn is Asn1BitString) && nodeAsText.Length > 40) nodeAsText = nodeAsText.Substring(0, 40) + "..."; var treeNode = new TreeNodeEx(nodeAsText); var imageIndex = GetImageIndex(asn); treeNode.SelectedImageIndex = imageIndex; treeNode.ImageIndex = imageIndex; var asnt = asn as Asn1StructuredObject; if (asnt != null) { foreach (var asn2 in asnt.Nodes) AddAsnNode(asn2, treeNode); } treeNode.Tag = asn; parent.Nodes.Add(treeNode); }
public void Remove(TreeNodeEx o) { lock (this) { PreRemoveTreeNode(o); arrayList.Remove(o); } }
private void PreAddTreeNode(TreeNodeEx o) { lock (this) { if (node != null) { o.iParent = node; o.iTreeView = node.TreeView; } else { o.iParent = null; o.iTreeView = this.treeView; } if (o.iTreeView != null) { o.iTreeView.Invalidate(); o.iTreeView.Update(); } } }
/// <summary> /// Fills the nodes of the treeview. /// </summary> private void FillNodes() { // The nodes rootNode = new TreeNodeEx(SR.CertificateStores); rootNode.ImageIndex = STORES_IMAGE; rootNode.SelectedImageIndex = STORES_IMAGE; tvStores.Nodes.Add(rootNode); // 1st level: locations IEnumerable<CertificateStoreLocation> locations = null; if (ShowOtherLocations) locations = Capi32.GetSystemStoreLocations(); else locations = new StoreLocation[] { StoreLocation.LocalMachine, StoreLocation.CurrentUser }.Select(l => CertificateStoreLocation.FromStoreLocation(l)); rootNode.Nodes.AddRange(locations .OrderBy(location => location.Id) .Select(location => { var locationNode = new FolderTreeNode(location.ToString()); locationNode.CollapsedImageIndex = CLOSED_LOCATION_IMAGE; locationNode.SelectedCollapsedImageIndex = CLOSED_LOCATION_IMAGE; locationNode.ExpandedImageIndex = OPENED_LOCATION_IMAGE; locationNode.SelectedExpandedImageIndex = OPENED_LOCATION_IMAGE; locationNode.Tag = location; // 2nd level: stores locationNode.Nodes.AddRange(Capi32.GetSystemStores(location) .Select(store => { var storeNode = new FolderTreeNode(store.ToLongString()); storeNode.CollapsedImageIndex = CLOSED_STORE_IMAGE; storeNode.SelectedCollapsedImageIndex = CLOSED_STORE_IMAGE; storeNode.ExpandedImageIndex = OPENED_STORE_IMAGE; storeNode.SelectedExpandedImageIndex = OPENED_STORE_IMAGE; storeNode.Tag = store; // 3rd level: physical stores if (ShowPhysicalStores) storeNode.Nodes.AddRange( Capi32.GetPhysicalStores(store.Name) .Select(pstore => { var label = string.Format("{0} [{1}]", pstore, Capi32.LocalizeName(pstore)); var pstoreNode = new TreeNodeEx(label); pstoreNode.ImageIndex = CLOSED_STORE_IMAGE; pstoreNode.SelectedImageIndex = OPENED_STORE_IMAGE; pstoreNode.Tag = store; return pstoreNode; }).ToArray()); return storeNode; }).ToArray()); return locationNode; }).ToArray()); rootNode.Expand(); }
private void RebuildSceneNode(TreeNodeEx node) { Scene.Scene scene = (Scene.Scene)node.Tag; foreach(Shape shape in scene.Shapes) { node.Nodes.Add(shape.Name, shape); } }
public TreeViewExEventArgs(TreeNodeEx node) { this.node = node; }
public TreeNodeExEventArgs(TreeNodeEx bstn) : base() { node = bstn; }
public bool Contains(TreeNodeEx o) { return arrayList.Contains(o); }
/// <summary> /// Sets the tooltip for the apporpriate node. /// </summary> /// <param name="node"></param> /// <param name="displayName"></param> /// <param name="status"></param> /// <param name="email"></param> private void SetFriendToolTip(TreeNodeEx node, string displayName, OnlineStatus status, string email) { // change tool tip text node.ToolTipText = "Name: " + displayName + "\nStatus: " + status.ToString() + "\nEmail: " + email; }
private static void RemoveFriendFromTree(TreeNodeEx parent, TreeNodeEx child) { parent.Nodes.Remove(child); }
private void ExpandChildren(TreeNodeEx node) { foreach (TreeNodeEx childNode in node.Nodes) { childNode.Expand(); ExpandChildren(childNode); } }
public ContextMenuStrip GetContextMenuStrip(TreeNodeEx node) { if (node.Tag != null && node.Tag is IDocument) return menuStrip; else return null; }
public ContextMenuStrip GetContextMenuStrip(TreeNodeEx node) { return menuStrip; }
public void Insert(int index, TreeNodeEx o) { lock (this) { PreAddTreeNode(o); arrayList.Insert(index, o); } }
private static void AddFriendToTree(TreeNodeEx parent, TreeNodeEx child) { parent.Nodes.Add(child); }
public int IndexOf(TreeNodeEx o) { return arrayList.IndexOf(o); }
public int Add(TreeNodeEx o) { lock (this) { PreAddTreeNode(o); return arrayList.Add(o); } }
public TreeNodeEx(ConfigPage linked, TreeNodeEx[] children) : this(linked) { this.Nodes.AddRange(children); }
private void PreRemoveTreeNode(TreeNodeEx o) { if (o.iTreeView != null) { o.iTreeView.Invalidate(); o.iTreeView.Update(); } // o.iTreeView = null; }
/// <summary> /// Checks if this node is either a direct or indirect parent of /// the parameter node. /// </summary> /// <param name="node">Child node to check</param> /// <returns>True if this node is a parent to the parameter node</returns> public bool IsParent(TreeNodeEx node) { if (node == this) return true; foreach (TreeNodeEx child in this.Nodes) { if (child.IsParent(node)) return true; } return false; }
public TreeNodeCollectionEx(TreeNodeEx node) { this.node = node; }
private void CollapseChildren(TreeNodeEx node) { foreach (TreeNodeEx childNode in node.Nodes) { childNode.Collapse(); CollapseChildren(childNode); } }
private void OnTreeViewNodeRemoved(TreeViewEx sender, TreeNodeEx node) { PropertiesContainer named = (PropertiesContainer)node.Tag; if(named != null) { named.NameChanged -= this.OnObjectRenamed; } }
/// <summary> /// Called when [document added]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Delta.CertXplorer.Common.DocumentModel.DocumentEventArgs"/> instance containing the event data.</param> private void OnDocumentAdded(object sender, DocumentEventArgs e) { if (!documents.ContainsKey(e.Document)) { var tnRoot = filesRoot; var caption = "Document"; if (e.Document is IDocument) caption = ((IDocument)e.Document).Caption; var tn = new TreeNodeEx(caption); if (e.Document.Source is FileDocumentSource) tnRoot = filesRoot; else if (e.Document.Source is X509DocumentSource) tnRoot = certificatesRoot; tn.Tag = e.Document; tn.ImageIndex = documentIndex; tn.SelectedImageIndex = documentIndex; documents.Add(e.Document, tn); tnRoot.Nodes.Add(tn); tnRoot.Expand(); } }
private void DrawNode(TreeNodeEx node, Drawing.Graphics graphics, Drawing2D.Matrix matrix, ref int totalHeight) { if (node.Visible) { totalHeight += this.HeightIndent + this.Font.Height; // transform coordinates Drawing.PointF[] p = new Drawing.PointF[1]; p[0] = new Drawing.PointF(0.0f, 0.0f); matrix.TransformPoints(p); // calculate location and size node.Location = new Drawing.Point((int)p[0].X, (int)p[0].Y); node.Size = new Drawing.Size(this.Width, this.Font.Height); if (dragOverNode == node) { // draw drag over line graphics.DrawLine(Drawing.Pens.Black, node.Location.X, node.Location.Y, this.Width, node.Location.Y); } // draw plus/minus if (this.ShowPlusMinus) { if (node.Nodes.Count > 0) { graphics.DrawRectangle(Drawing.Pens.Black, (int)p[0].X + 2, (int)p[0].Y + 2, 8, 8); if (!node.Expanded) { // line across graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6); // down graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 6, (int)p[0].Y + 4, (int)p[0].X + 6, (int)p[0].Y + 8); } else { graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6); } } p[0].X += 12; } // draw node image if (!this.imageList.Images.Empty) { this.imageList.Draw(graphics, new Drawing.Point((int)p[0].X, (int)p[0].Y), (node.Expanded) ? node.ExpandedImageIndex : node.CollapsedImageIndex); p[0].X += this.imageList.ImageSize.Width; } // draw node text Drawing.Brush textBrush; if (node == this.selectedNode && this.ChangeColorOnSelected) textBrush = this.TextSelectedBrush; else if (node == this.mouseOverNode && this.ChangeColorOnMouseOver) textBrush = this.TextMouseOverBrush; else textBrush = node.TextBrush; Drawing.Font font = new Drawing.Font(this.Font.FontFamily.Name, this.Font.Size, node.FontStyle); graphics.DrawString(node.Text, font, textBrush, p[0]); // go through children if (node.Expanded && node.Nodes.Count > 0) { matrix.Translate((float)this.WidthIndent, 0.0f); foreach (TreeNodeEx treeNode in node.Nodes) { matrix.Translate(0.0f, this.HeightIndent + this.Font.Height); DrawNode(treeNode, graphics, matrix, ref totalHeight); } matrix.Translate(-(float)this.WidthIndent, 0.0f); } } else matrix.Translate(0.0f, -((float)this.HeightIndent + this.Font.Height)); }