예제 #1
0
        public static MenuItemAbstract CreateMenuItem(INodeInformation node)
        {
            MenuItemAbstract menuItem = null;

            switch (node.Parent.InvariantName)
            {
            case "Databases":
                if (!IsDBMenuAdded)
                {
                    menuItem      = new SqlDBMenuItem();
                    IsDBMenuAdded = true;
                }
                break;

            case "UserTables":
                if (!IsTableMenuAdded)
                {
                    menuItem         = new SqlTableMenuItem();
                    IsTableMenuAdded = true;
                }
                break;

            case "Columns":
                if (!IsColumnMenuAdded)
                {
                    menuItem          = new SqlColumnMenuItem();
                    IsColumnMenuAdded = true;
                }
                break;

            default:
                return(null);
            }
            return(menuItem);
        }
예제 #2
0
        private void ActionContextOnCurrentContextChanged(object sender, EventArgs e)
        {
            try
            {
                INodeInformation[] nodes;
                INodeInformation   node;
                int nodeCount;
                IObjectExplorerService objectExplorer = GetService(typeof(IObjectExplorerService)) as ObjectExplorerService;

                if (objectExplorer != null)
                {
                    objectExplorer.GetSelectedNodes(out nodeCount, out nodes);
                    node = nodeCount > 0 ? nodes[0] : null;

                    if (node != null)
                    {
                        MenuItemAbstract menuItem = Factories.MenuItemFactory.CreateMenuItem(node);
                        AddMenuItemToHierarchyObject(node, menuItem);
                    }
                }
            }
            #pragma warning disable 0169
#pragma warning disable CS0168 // Variable is declared but never used
            catch (Exception ObjectExplorerContextException)
#pragma warning restore CS0168 // Variable is declared but never used
            {
                //MessageBox.Show("ObjectExplorerContextException: " + ObjectExplorerContextException.Message);
            }
            #pragma warning restore 0169
        }