private void CreateIfNotExist(TreeNode node) { if (node == null) { return; } if (!Items.ContainsKey(node)) { NavMenuItem menuItem = new NavMenuItem(); Items.TryAdd(node, menuItem); } }
private TabPage CreateTabIfNotExists(NavMenuItem item) { if (item == null) { return(null); } if (item.PageIndex < 0 && item.PageGuid == Guid.Empty) { return(null); } for (int i = 0; i < tabControl.TabPages.Count; i++) { TabPage page = tabControl.TabPages[i]; if (!PageItems.ContainsKey(page)) { if (page.Controls.Count == 0) { PageItems.TryAdd(page, item); return(page); } } else { if (item.PageGuid != Guid.Empty) { if (PageItems[page].PageGuid == item.PageGuid) { return(page); } } else { if (item.PageIndex >= 0 && PageItems[page].PageIndex == item.PageIndex) { return(page); } } } } TabPage newPage = new TabPage(); newPage.SuspendLayout(); newPage.Text = "tabPage" + tabControl.TabPages.Count; tabControl.Controls.Add(newPage); PageItems.TryAdd(newPage, item); newPage.ResumeLayout(); return(newPage); }
public void Add(TreeNode node, NavMenuItem item) { if (node == null || item == null) { return; } if (this[node] == null) { Items.TryAdd(node, item); } else { Items[node] = item; } node.ImageIndex = item.ImageIndex; node.SelectedImageIndex = item.SelectedImageIndex; node.Tag = item; }
public void SetNodeItem(TreeNode node, NavMenuItem item) { MenuHelper.Add(node, item); }