コード例 #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)
        {
            try
            {
                object o = GetService(typeof(IVsTeamFoundationBuild));

                IVsTeamFoundationBuild tfsBuild = o as IVsTeamFoundationBuild;

                // 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.
                ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true);
                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException(Resources.CanNotCreateWindow);
                }

                MyToolWindow myWindow  = (MyToolWindow)window;
                MyControl    myControl = (MyControl)myWindow.Content;
                myControl.Package  = this;
                myControl.TfsBuild = tfsBuild;

                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch (Exception ex)
            {
                ActivityLog.LogError("PowerDeliveryVSExtension2012", string.Format("Message: {0} Stack: {1}", ex.Message, ex.StackTrace));
            }
        }
コード例 #2
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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                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 tool window
                    CommandID   toolwndCommandID = new CommandID(GuidList.guidPowerDeliveryVSExtensionCmdSet, (int)PkgCmdIDList.cmdidDeploymentPipelines);
                    MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);
                    mcs.AddCommand(menuToolWin);
                }

                ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true);

                if (window != null)
                {
                    MyToolWindow           myWindow = (MyToolWindow)window;
                    IVsTeamFoundationBuild tfsBuild = (IVsTeamFoundationBuild)GetService(typeof(IVsTeamFoundationBuild));
                    MyControl myControl             = (MyControl)myWindow.Content;
                    myControl.Package  = this;
                    myControl.TfsBuild = tfsBuild;
                }
            }
            catch (Exception ex)
            {
                ActivityLog.LogError("PowerDeliveryVSExtension2012", string.Format("Message: {0} Stack: {1}", ex.Message, ex.StackTrace));
            }
        }
コード例 #3
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)
        {
            VsTeamFoundationBuild tfsBuild = (VsTeamFoundationBuild)GetService(typeof(IVsTeamFoundationBuild));

            // 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.
            ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }

            MyToolWindow myWindow  = (MyToolWindow)window;
            MyControl    myControl = (MyControl)myWindow.Content;

            myControl.Package  = this;
            myControl.TfsBuild = tfsBuild;

            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }