Example #1
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method handles opening a solution builder solution when an output
 /// solution is opened.</summary>
 ///--------------------------------------------------------------------------------
 private void CheckOpenCurrentSolution()
 {
     try
     {
         SolutionBuilderWindow window = this.FindToolWindow(typeof(SolutionBuilderWindow), 0, false) as SolutionBuilderWindow;
         if (window != null)
         {
             if (ApplicationObject.Solution.FullName != string.Empty)
             {
                 window.Control.TreeViewModel.SolutionsFolder.CheckOpenCurrentSolution(System.IO.Path.GetDirectoryName(ApplicationObject.Solution.FullName));
                 IVsWindowFrame frame = window.Frame as IVsWindowFrame;
                 if (frame == null)
                 {
                     throw new COMException(this.GetResourceString("@102"));
                 }
                 // Bring the tool window to the front and give it focus
                 ErrorHandler.ThrowOnFailure(frame.Show());
             }
         }
     }
     catch (System.Exception ex)
     {
         // put exception message in output pane
         SolutionBuilderPane.OutputString(ex.Message);
     }
 }
Example #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method is used to show the solution designer window.</summary>
        ///--------------------------------------------------------------------------------
        private void ShowSolutionDesignerWindow()
        {
            try
            {
                // Get the instance number 0 of this tool window. This window is single instance so this instance
                // is actually the only one.
                SolutionDesignerWindow window = this.FindToolWindow(typeof(SolutionDesignerWindow), 0, false) as SolutionDesignerWindow;
                if (window == null)
                {
                    window = this.CreateToolWindow(typeof(SolutionDesignerWindow), 0) as SolutionDesignerWindow;
                    if ((null == window) || (null == window.Frame))
                    {
                        throw new NotSupportedException(Resources.CanNotCreateWindow);
                    }
                }

                // dock the window as an mdi child, user can override
                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                ((IVsWindowFrame)window.Frame).SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_MdiChild);
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Error showing solution designer: {0}", ex.ToString()));
                // put exception message in output pane
                SolutionBuilderPane.OutputString(ex.Message);
            }
        }
Example #3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method displays a message in the output area.</summary>
        ///
        /// <param name="outputMessage">The message to show.</param>
        /// <param name="outputTitle">The title for the message.</param>
        /// <param name="appendMessage">Flag indicating whether message should be appended to existing message.</param>
        ///--------------------------------------------------------------------------------
        public void ShowOutput(string outputMessage, string outputTitle, bool appendMessage)
        {
            if (appendMessage == false)
            {
                // clear output pane
                SolutionBuilderPane.Clear();
            }

            if (outputTitle != string.Empty)
            {
                // put output title to output pane
                SolutionBuilderPane.OutputString("\r\n" + outputTitle);
            }

            // put output message to output pane
            SolutionBuilderPane.OutputString("\r\n" + outputMessage + "\r\n");
        }
Example #4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method opens the output solution for a solution.</summary>
 ///
 /// <param name="solutionPath">Path to the solution to open.</param>
 ///--------------------------------------------------------------------------------
 public void OpenOutputSolution(string solutionPath)
 {
     try
     {
         if (solutionPath.EndsWith(".sln") == true)
         {
             // open the .net solution if not already open
             if (SolutionService != null && ApplicationObject.Solution.FullName.ToLower() != solutionPath.ToLower())
             {
                 SolutionService.OpenSolutionFile((uint)__VSSLNOPENOPTIONS.SLNOPENOPT_Silent, solutionPath);
             }
             // Bring the solution explorer window to the front and give it focus
             ApplicationObject.ToolWindows.SolutionExplorer.Parent.Activate();
             ApplicationObject.ToolWindows.SolutionExplorer.Parent.SetFocus();
         }
         else
         {
             // open other solution type
             if (File.Exists(solutionPath))
             {
                 ProcessStartInfo info = new ProcessStartInfo();
                 info.FileName = solutionPath;
                 using (System.Diagnostics.Process p = new System.Diagnostics.Process())
                 {
                     p.StartInfo = info;
                     p.Start();
                 }
             }
         }
     }
     catch (ApplicationException ex)
     {
         // put exception message in output pane
         SolutionBuilderPane.OutputString(ex.Message);
     }
     catch (Exception ex)
     {
         // put exception message in output pane
         SolutionBuilderPane.OutputString(ex.Message);
     }
 }
Example #5
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method determines if visual studio can close.</summary>
 ///--------------------------------------------------------------------------------
 public int get_CanClose(out bool pfCanClose)
 {
     pfCanClose = true;
     try
     {
         // cancel close if either solution designer or solution builder cannot close
         SolutionDesignerWindow solutionDesigner = this.FindToolWindow(typeof(SolutionDesignerWindow), 0, false) as SolutionDesignerWindow;
         if (solutionDesigner != null)
         {
             if (solutionDesigner.CanClose() == false)
             {
                 pfCanClose = false;
                 return(VSConstants.E_ABORT);
             }
             solutionDesigner.Control.DesignerView.CloseNoPromptAllItems();
             IVsWindowFrame windowFrame = (IVsWindowFrame)solutionDesigner.Frame;
             windowFrame.Hide();
         }
         SolutionBuilderWindow solutionBuilder = this.FindToolWindow(typeof(SolutionBuilderWindow), 0, false) as SolutionBuilderWindow;
         if (solutionBuilder != null)
         {
             if (solutionBuilder.CanClose() == false)
             {
                 pfCanClose = false;
                 return(VSConstants.E_ABORT);
             }
             solutionBuilder.Control.CloseAllSolutions(true);
             IVsWindowFrame windowFrame = (IVsWindowFrame)solutionBuilder.Frame;
             windowFrame.Hide();
         }
     }
     catch (System.Exception ex)
     {
         // put exception message in output pane
         SolutionBuilderPane.OutputString(ex.Message);
     }
     return(VSConstants.S_OK);
 }
Example #6
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 (mcs != null)
                {
                    // Create the solution builder command for the Mo+ Menu
                    CommandID   incodeBuilderCommandID = new CommandID(GuidList.guidInCodeMenuCmdSet, (int)PkgCmdIDList.cmdidSolutionBuilderControl);
                    MenuCommand incodeBuilderToolWin   = new MenuCommand(SolutionBuilderCallback, incodeBuilderCommandID);
                    mcs.AddCommand(incodeBuilderToolWin);

                    // Create the solution updater command for the Mo+ Menu
                    CommandID   incodeUpdaterCommandID = new CommandID(GuidList.guidInCodeMenuCmdSet, (int)PkgCmdIDList.cmdidSolutionUpdaterControl);
                    MenuCommand incodeUpdaterToolWin   = new MenuCommand(SolutionUpdaterCallback, incodeUpdaterCommandID);
                    mcs.AddCommand(incodeUpdaterToolWin);
                }
                else
                {
                    SolutionBuilderPane.OutputString("Could not get IMenuCommandService.");
                }

                // add the handler for tracking solution opens and closes
                if (ApplicationObject != null)
                {
                    // wire up solution events
                    PackageSolutionEvents         = ApplicationObject.Events.SolutionEvents;
                    PackageSolutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(CheckOpenCurrentSolution);

                    // get the solution command bar
                    CommandBar solutionCommandBar = ((CommandBars)ApplicationObject.CommandBars)["Solution"];

                    // set up the main Mo+ context menu
                    CommandBarPopup solutionPopup = (CommandBarPopup)solutionCommandBar.Controls.Add(MsoControlType.msoControlPopup, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 3, true);
                    solutionPopup.Caption = "Mo+";

                    // add solution builder submenu
                    CommandBarControl solutionBuilderControl = solutionPopup.Controls.Add(MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true);
                    solutionBuilderControl.Caption              = "Solution Builder";
                    launchSolutionBuilderMenuItemHandler        = (CommandBarEvents)ApplicationObject.Events.get_CommandBarEvents(solutionBuilderControl);
                    launchSolutionBuilderMenuItemHandler.Click += new _dispCommandBarControlEvents_ClickEventHandler(launchSolutionBuilder_Click);

                    // add solution updater submenu
                    CommandBarControl solutionUpdaterControl = solutionPopup.Controls.Add(MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true);
                    solutionUpdaterControl.Caption       = "Update Solution";
                    updateSolutionMenuItemHandler        = (CommandBarEvents)ApplicationObject.Events.get_CommandBarEvents(solutionUpdaterControl);
                    updateSolutionMenuItemHandler.Click += new _dispCommandBarControlEvents_ClickEventHandler(updateSolution_Click);

                    // if solution is already open, load it
                    CheckOpenCurrentSolution();
                }
            }
            catch (System.Exception ex)
            {
                // put exception message in output pane
                SolutionBuilderPane.OutputString(ex.Message);
            }
        }
Example #7
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 ShowSolutionBuilderWindow(object sender, EventArgs e)
        {
            try
            {
                // show solution builder
                SolutionBuilderPane.Clear();

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

                // wire up solution builder window events
                window.Control.ProgressChanged               -= SolutionBuilderControl_ProgressChanged;
                window.Control.ProgressChanged               += new SolutionBuilderControl.StatusChangeEventHandler(SolutionBuilderControl_ProgressChanged);
                window.Control.StatusChanged                 -= SolutionBuilderControl_StatusChanged;
                window.Control.StatusChanged                 += new SolutionBuilderControl.StatusChangeEventHandler(SolutionBuilderControl_StatusChanged);
                window.Control.OutputChanged                 -= SolutionBuilderControl_OutputChanged;
                window.Control.OutputChanged                 += new SolutionBuilderControl.StatusChangeEventHandler(SolutionBuilderControl_OutputChanged);
                window.Control.OpenOutputSolutionRequested   -= SolutionBuilderControl_OpenOutputSolutionRequested;
                window.Control.OpenOutputSolutionRequested   += new SolutionBuilderControl.SolutionEventHandler(SolutionBuilderControl_OpenOutputSolutionRequested);
                window.Control.ShowSolutionDesignerRequested -= SolutionBuilderControl_ShowSolutionDesignerRequested;
                window.Control.ShowSolutionDesignerRequested += new SolutionBuilderControl.SolutionEventHandler(SolutionBuilderControl_ShowSolutionDesignerRequested);

                // show designer window
                ShowSolutionDesignerWindow();

                // show getting started help
                if (window.Control.DataContext is BuilderViewModel)
                {
                    (window.Control.DataContext as BuilderViewModel).ResourcesFolder.ShowGettingStartedHelp();
                }

                // TODO: remove this later
                window.DesignerWindow = this.FindToolWindow(typeof(SolutionDesignerWindow), 0, false) as SolutionDesignerWindow;

                // if solution is already open, load it
                CheckOpenCurrentSolution();

                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                // put solution builder output to output pane
                SolutionBuilderPane.OutputString("Solution Builder shown.");
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Error showing solution builder: {0}", ex.ToString()));
                // put exception message in output pane
                string           message   = ex.Message;
                System.Exception exception = ex.InnerException;
                while (exception != null)
                {
                    message  += "\r\n" + exception.Message;
                    exception = exception.InnerException;
                }
                SolutionBuilderPane.OutputString(message);
            }
        }