protected void InitializeVisualElements() { SuspendLayout(); try { this.LabelEdit = true; this.AllowDrop = true; m_Icons = new ImageList(); m_Icons.ColorDepth = ColorDepth.Depth32Bit; m_Icons.ImageSize = new Size(16, 16); m_Icons.TransparentColor = Color.White; this.ImageList = m_Icons; m_ContextMenu = m_ToolStripFactory.CreateToolbar <ContextMenuStrip>(this); this.ContextMenuStrip = m_ContextMenu; Dictionary <int, NodeWapper> folders = new Dictionary <int, NodeWapper>(); Dictionary <int, ContentNode> nodes = new Dictionary <int, ContentNode>(); foreach (object instance in GetStore()) { NodeWapper nodeWappper = new NodeWapper(instance); folders.Add(nodeWappper.Id, nodeWappper); } while (folders.Count > 0) { NodeWapper[] tmpList = new NodeWapper[folders.Count]; folders.Values.CopyTo(tmpList, 0); foreach (NodeWapper folder in tmpList) { if (folders.ContainsKey(folder.Parent)) { continue; } ContentNode parent = null; nodes.TryGetValue(folder.Parent, out parent); ContentNode node = CreateNode(folder); InsertNode((null == parent) ? this.Nodes : parent.Nodes, node); nodes.Add(node.Id, node); folders.Remove(folder.Id); } } } finally { ResumeLayout(); } }
public ContentNode CreateNode(NodeWapper content) { ContentNode node = new ContentNode(content); node.ImageKey = content.Icon; node.SelectedImageKey = content.Icon; EnsureIconIsInImageList(content.Icon); return(node); }
private void MailPage_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { this.SelectedNode = e.Node; if (e.Button != MouseButtons.Right) { return; } m_ContextMenu.Items.Clear(); NodeWapper nodeWapper = ((IContentProvider)e.Node).Content as NodeWapper; m_ContextMenu.Items.AddRange(m_ToolStripFactory.GetItems(nodeWapper.GetInstance())); }
public ContentNode(NodeWapper content) : base(content.ToString()) { m_Content = content; }