/// <summary> /// Event raises when we click on any contextmenu item /// And then performs the specified action /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cm_OnMenuClick(object sender, EventArgs e) { // assure that the sender is a MenuItem MenuItem mi = sender as MenuItem; LACTreeNode lacnode = mi.Tag as LACTreeNode; if (lacnode != null && lacnode.Nodes.Count != 0) { ADUCDirectoryNode rootNode = lacnode.Nodes[0] as ADUCDirectoryNode; ADUCPage pluginpage = lacnode.PluginPage as ADUCPage; if (pluginpage != null) { pluginpage.TreeNode.IsModified = true; rootNode.IsModified = true; pluginpage.RefreshPluginPage(); pluginpage.TreeNode.TreeView.SelectedNode = pluginpage.TreeNode; rootNode.ListChildren(); if (rootNode.IsExpanded) { rootNode.toggleLACNode(); } } } }
/// <summary> /// Is a delegate that will be called when we click on any node from the treeview /// And Initializes the contextmenu /// </summary> /// <param name="nodeClicked"></param> /// <returns></returns> public ContextMenu GetTreeContextMenu(LACTreeNode nodeClicked) { Logger.Log("ADUCPlugin.GetTreeContextMenu", Logger.manageLogLevel); if (nodeClicked == null) { return(null); } else { ADUCPage aducPage = (ADUCPage)nodeClicked.PluginPage; if (aducPage == null) { Type type = nodeClicked.NodeType; object o = Activator.CreateInstance(type); if (o is IPlugInPage) { ((IPlugInPage)o).SetPlugInInfo(_container, nodeClicked.Plugin, nodeClicked, (LWTreeView)nodeClicked.TreeView, nodeClicked.sc); aducPage = (ADUCPage)nodeClicked.PluginPage; } } ContextMenu aducContextMenu = null; if (aducPage != null) { if (nodeClicked is ADUCDirectoryNode) { aducContextMenu = aducPage.GetTreeContextMenu_curr(nodeClicked as ADUCDirectoryNode); } else { aducContextMenu = aducPage.GetTreeContextMenu(); } } if (_pluginNode == nodeClicked) { if (aducContextMenu == null) { aducContextMenu = new ContextMenu(); } MenuItem m_item = new MenuItem("Connect to Domain", new EventHandler(cm_OnConnect)); aducContextMenu.MenuItems.Add(0, m_item); aducContextMenu.MenuItems.Add(new MenuItem("-")); m_item = new MenuItem("Refresh", new EventHandler(cm_OnMenuClick)); m_item.Tag = nodeClicked; aducContextMenu.MenuItems.Add(m_item); aducContextMenu.MenuItems.Add(new MenuItem("-")); m_item = new MenuItem("Help", new EventHandler(aducPage.cm_OnMenuClick)); aducContextMenu.MenuItems.Add(m_item); } ADUCDirectoryNode dirnode = nodeClicked as ADUCDirectoryNode; return(aducContextMenu); } }