private void Provider_SelectionChanged(object sender, NodesChangedEventArgs args) { INavigationContextProvider provider = (INavigationContextProvider)sender; INodeInformation node = (args.ChangedNodes.Count > 0 ? args.ChangedNodes[0] : null); if (_tableMenu == null && _tableRegex.IsMatch(node.Context)) { _tableMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler)); MenuItem item = new MenuItem(); _tableMenu.AddChild(string.Empty, item); } }
private void Provider_SelectionChanged(object sender, NodesChangedEventArgs args) { Connect.ViewsSelected = false; INodeInformation node = Connect.ObjectExplorerSelectedNode; if (node != null) { System.Diagnostics.Debug.WriteLine(node.UrnPath); System.Diagnostics.Debug.WriteLine(node.Name); System.Diagnostics.Debug.WriteLine(node.Context); // Mobile Device connections not supported if (node.Connection.ServerName.StartsWith("Mobile Device\\", StringComparison.Ordinal)) { // short circuit node = null; } } if (node != null && _serverMenu == null && urnPath == node.UrnPath) { _serverMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler)); _serverMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); DatabaseMenuItem item = new DatabaseMenuItem(); _serverMenu.AddChild(string.Empty, item); ServerMenuItem serveritem = new ServerMenuItem(); _serverMenu.AddChild(string.Empty, serveritem); } if (node != null && _tableMenu == null && tableUrnPath == node.UrnPath) { _tableMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler)); _tableMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); EditTableMenuItem itemE = new EditTableMenuItem(); _tableMenu.AddChild(string.Empty, itemE); _tableMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); ScriptTableMenuItem item = new ScriptTableMenuItem(); _tableMenu.AddChild(string.Empty, item); _tableMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); ImportTableMenuItem item2 = new ImportTableMenuItem(); _tableMenu.AddChild(string.Empty, item2); _tableMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); RenameTableMenuItem item3 = new RenameTableMenuItem(); _tableMenu.AddChild(string.Empty, item3); } if (node != null && _indexMenu == null && indexUrnPath == node.UrnPath) { _indexMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler)); _indexMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); ScriptIndexMenuItem itemI = new ScriptIndexMenuItem(); _indexMenu.AddChild(string.Empty, itemI); } if (node != null && _viewMenu == null && viewUrnPath == node.UrnPath) { _viewMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler)); _viewMenu.AddChild(string.Empty, new ToolStripSeparatorMenuItem()); EditTableMenuItem itemV = new EditTableMenuItem(); _viewMenu.AddChild(string.Empty, itemV); } // Set this each time if (node != null && viewUrnPath == node.UrnPath) { Connect.ViewsSelected = true; } }
private void AddMenuItemToHierarchyObject(INodeInformation node, object item) { dbMenu = (HierarchyObject)node.GetService(typeof(IMenuHandler)); dbMenu.AddChild(string.Empty, item); }