Example #1
0
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                {
                    // Create the command for the menu item.
                    CommandID   menuCommandID = new CommandID(GuidList.guidSqlProjPowerPackCmdSet, (int)PkgCmdIDList.cmdIdTest);
                    MenuCommand menuItem      = new MenuCommand(OnTestCallback, menuCommandID);
                    mcs.AddCommand(menuItem);
                }
                {
                    // Create the command for the menu item.
                    CommandID      menuCommandID = new CommandID(GuidList.guidSqlProjPowerPackCmdSet, (int)PkgCmdIDList.cmdIdImportDBSchema);
                    OleMenuCommand menuItem      = new OleMenuCommand(OnImportDBSchemaCallback, menuCommandID);

                    menuItem.BeforeQueryStatus += new EventHandler((sender, e) =>
                    {
                        MenuCommand menuCommand = sender as OleMenuCommand;
                        if (menuCommand != null)
                        {
                            bool isSqlProj      = ProjectHelper.IsSqlProj(selectionEvents.GetSelectedProject());
                            menuCommand.Visible = isSqlProj;
                            menuCommand.Enabled = isSqlProj;
                        }
                        Debug.WriteLine(String.Format("BeforeQueryStatus = {0}", visible.ToString()));
                    });

                    mcs.AddCommand(menuItem);
                }
            }
            _instance = this;
        }
        protected override void Initialize()
        {
            Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if ( null != mcs )
            {
                {
                    // Create the command for the menu item.
                    CommandID menuCommandID = new CommandID(GuidList.guidSqlProjPowerPackCmdSet, (int)PkgCmdIDList.cmdIdTest);
                    MenuCommand menuItem = new MenuCommand(OnTestCallback, menuCommandID);
                    mcs.AddCommand(menuItem);
                }
                {
                    // Create the command for the menu item.
                    CommandID menuCommandID = new CommandID(GuidList.guidSqlProjPowerPackCmdSet, (int)PkgCmdIDList.cmdIdImportDBSchema);
                    OleMenuCommand menuItem = new OleMenuCommand(OnImportDBSchemaCallback, menuCommandID);

                    menuItem.BeforeQueryStatus += new EventHandler((sender, e) =>
                        {
                            MenuCommand menuCommand = sender as OleMenuCommand;
                            if (menuCommand != null)
                            {
                                bool isSqlProj = ProjectHelper.IsSqlProj(selectionEvents.GetSelectedProject());
                                menuCommand.Visible = isSqlProj;
                                menuCommand.Enabled = isSqlProj;
                            }
                            Debug.WriteLine(String.Format("BeforeQueryStatus = {0}", visible.ToString()));
                        });

                    mcs.AddCommand(menuItem);
                }
            }
            _instance = this;
        }