public static void Setup(int testItems) { SetTestRepo(); for(int i=0;i<testItems;i++){ TreeMenu item=new TreeMenu(); _testRepo._items.Add(item); } }
/// <summary> /// Triggered whenever any link is clicked /// </summary> /// <param name="parameters">The parameters passed in from the link</param> public void LinkClicked(params object[] parameters) { string className = parameters[0].ToString(); string module = parameters[1].ToString(); TreeMenu menuItem = new TreeMenu(); menuItem.ActionClass = className; menuItem.Module = module; ShowControl(menuItem); panelConfiguration.SelectNode(menuItem); }
public static void Setup(TreeMenu item) { SetTestRepo(); _testRepo._items.Add(item); }
/// <summary> /// Outputs the specified text. /// </summary> /// <param name="control">The control.</param> /// <param name="menuItem">The menu item.</param> /// <param name="currentControl">The current control.</param> private void SetControl(Control control, TreeMenu menuItem) { if (control.InvokeRequired) { SetControlCallback scc = new SetControlCallback(SetControl); this.Invoke(scc, new object[] { control, menuItem}); } else { //if (currentControl != null) currentControl.Visible = false; if (currentControl != null) { currentControl.Enabled = false; currentControl.Dock = DockStyle.None; } control.Tag = menuItem.Module; control.Enabled = true; control.Dock = DockStyle.Fill; control.BringToFront(); currentControl = control; } }
/// <summary> /// Shows the control. /// </summary> /// <param name="menuItem">The menu item.</param> private void ShowControl(TreeMenu menuItem) { if (menuItem != null) { if (currentControl != null && currentControl.Name.Equals(menuItem.ActionClass, StringComparison.OrdinalIgnoreCase)) { // Click on the same menu item return; } Control control; if (userControlLookup.TryGetValue(menuItem.ActionClass.ToLower(), out control)) { SetControl(control, menuItem); } } }
/// <summary> /// Initializes a new instance of the <see cref="ActionTriggerEventHandlerArgs"/> class. /// </summary> /// <param name="menuItem">The menu item.</param> public ActionTriggerEventHandlerArgs(TreeMenu menuItem) { this.MenuItem = menuItem; }
/// <summary> /// Selects the node. /// </summary> /// <param name="menu">The menu.</param> public void SelectNode(TreeMenu menu) { List<TreeNode> nodes = FlattenDepth(treeConfig); foreach (TreeNode node in nodes) { if (node.Tag != null && node.Tag.GetType() == typeof(TreeMenu)) { TreeMenu nodeMenu = (TreeMenu)node.Tag; if (!string.IsNullOrEmpty(nodeMenu.ActionClass) && nodeMenu.ActionClass.Equals(menu.ActionClass)) { treeConfig.SelectedNode = node; node.ExpandAll(); return; } } } }
/// <summary> /// Add the nodes to the tree recursively. /// </summary> /// <param name="menuLevelLookup">The menu level lookup.</param> /// <param name="parentNode">The parent node.</param> /// <param name="parentMenu">The parent menu.</param> private void AddToTree(Dictionary<long, List<TreeMenu>> menuLevelLookup, TreeNode parentNode, TreeMenu parentMenu) { // Get the next level List<TreeMenu> menuList; if (menuLevelLookup.TryGetValue(parentMenu.Id, out menuList)) { foreach (TreeMenu menu in menuList.OrderBy(m => m.Sequence)) { TreeNode node = new TreeNode(menu.Text, (int)menu.ImageIndex, (int)menu.SelectedImageIndex); node.Tag = menu; parentNode.Nodes.Add(node); AddToTree(menuLevelLookup, node, menu); } } }