コード例 #1
0
        /// <summary>
        /// This function is called when the user clicks the menu item that shows the
        /// tool window. See the Initialize method to see how the menu item is associated to
        /// this function using the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void ShowToolWindow(object sender, EventArgs e)
        {
            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            toolWindow = this.FindToolWindow(typeof(BuildProgressToolWindow), 0, true) as BuildProgressToolWindow;
            if ((null == toolWindow) || (null == toolWindow.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }
            IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
コード例 #2
0
 /// <summary>
 /// This function is called when the user clicks the menu item that shows the 
 /// tool window. See the Initialize method to see how the menu item is associated to 
 /// this function using the OleMenuCommandService service and the MenuCommand class.
 /// </summary>
 private void ShowToolWindow(object sender, EventArgs e)
 {
     // Get the instance number 0 of this tool window. This window is single instance so this instance
     // is actually the only one.
     // The last flag is set to true so that if the tool window does not exists it will be created.
     toolWindow = this.FindToolWindow(typeof(BuildProgressToolWindow), 0, true) as BuildProgressToolWindow;
     if ((null == toolWindow) || (null == toolWindow.Frame))
     {
         throw new NotSupportedException(Resources.CanNotCreateWindow);
     }
     IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame;
     Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
 }
コード例 #3
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            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 tool window
                CommandID   toolwndCommandID = new CommandID(GuidList.guidProgressBarCmdSet, (int)PkgCmdIDList.cmdidProgressBar);
                MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }

            // Get shell object
            vsShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsShell)) as IVsShell;
            if (vsShell != null)
            {
                // Initialize VisualEffects values, so themes can determine if various effects are supported by the environment
                object effectsAllowed;
                if (ErrorHandler.Succeeded(vsShell.GetProperty((int)__VSSPROPID4.VSSPROPID_VisualEffectsAllowed, out effectsAllowed)))
                {
                    // VSSPROPID_VisualEffectsAllowed is a VT_I4 property, so casting to int should be safe
                    Debug.Assert(effectsAllowed is int, "VSSPROPID_VisualEffectsAllowed should be of type int");
                    this.visualEffectsAllowed = (int)effectsAllowed;
                }
                else
                {
                    Debug.Fail("Failed to get the VSSPROPID_VisualEffectsAllowed property value.");
                }

                // Subscribe to shell property changes to update VisualEffects values if the user modifies the settings
                vsShell.AdviseShellPropertyChanges(this, out shellPropertyChangesCookie);
            }

            // Get solution
            solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
            if (solution != null)
            {
                // Get count of any currently loaded projects
                object count;
                solution.GetProperty((int)__VSPROPID.VSPROPID_ProjectCount, out count);
                totalProjects = (int)count;

                // Register for solution events
                solution.AdviseSolutionEvents(this, out solutionEventsCookie);
            }

            // Get solution build manager
            sbm = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
            if (sbm != null)
            {
                sbm.AdviseUpdateSolutionEvents(this, out updateSolutionEventsCookie);
            }

            // Get tool window
            if (toolWindow == null)
            {
                toolWindow = this.FindToolWindow(typeof(BuildProgressToolWindow), 0, true) as BuildProgressToolWindow;
            }

            // Set initial value of EffectsEnabled in tool window
            toolWindow.EffectsEnabled = visualEffectsAllowed != 0;
        }
コード例 #4
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            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 tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidProgressBarCmdSet, (int)PkgCmdIDList.cmdidProgressBar);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }

            // Get shell object
            vsShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsShell)) as IVsShell;
            if (vsShell != null)
            {
                // Initialize VisualEffects values, so themes can determine if various effects are supported by the environment
                object effectsAllowed;
                if (ErrorHandler.Succeeded(vsShell.GetProperty((int)__VSSPROPID4.VSSPROPID_VisualEffectsAllowed, out effectsAllowed)))
                {
                    // VSSPROPID_VisualEffectsAllowed is a VT_I4 property, so casting to int should be safe
                    Debug.Assert(effectsAllowed is int, "VSSPROPID_VisualEffectsAllowed should be of type int");
                    this.visualEffectsAllowed = (int)effectsAllowed;
                }
                else
                {
                    Debug.Fail("Failed to get the VSSPROPID_VisualEffectsAllowed property value.");
                }

                // Subscribe to shell property changes to update VisualEffects values if the user modifies the settings
                vsShell.AdviseShellPropertyChanges(this, out shellPropertyChangesCookie);
            }

            // Get solution
            solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
            if (solution != null)
            {
                // Get count of any currently loaded projects
                object count;
                solution.GetProperty((int)__VSPROPID.VSPROPID_ProjectCount, out count);
                totalProjects = (int)count;

                // Register for solution events
                solution.AdviseSolutionEvents(this, out solutionEventsCookie);
            }

            // Get solution build manager
            sbm = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
            if (sbm != null)
            {
                sbm.AdviseUpdateSolutionEvents(this, out updateSolutionEventsCookie);
            }

            // Get tool window
            if (toolWindow == null)
            {
                toolWindow = this.FindToolWindow(typeof(BuildProgressToolWindow), 0, true) as BuildProgressToolWindow;
            }

            // Set initial value of EffectsEnabled in tool window
            toolWindow.EffectsEnabled = visualEffectsAllowed != 0;
        }