コード例 #1
0
ファイル: CVXConnect.cs プロジェクト: tigaliang/ClangVSx
        /// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary>
        /// <param term='commandName'>The name of the command to execute.</param>
        /// <param term='executeOption'>Describes how the command should be run.</param>
        /// <param term='varIn'>Parameters passed from the caller to the command handler.</param>
        /// <param term='varOut'>Parameters passed from the command handler to the caller.</param>
        /// <param term='handled'>Informs the caller if the command was handled or not.</param>
        /// <seealso class='Exec' />
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut,
                         ref bool handled)
        {
            handled = false;
            if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                String cmd = GetCommandShortName(commandName);
                switch (cmd)
                {
                case COMMAND_CLANG_SETTINGS_DLG:
                {
                    handled = true;
                    ShowCVXSettingsDialog();
                }
                break;

                case COMMAND_CLANG_CANCEL_BUILD:
                {
                    handled         = true;
                    BuildCancelFlag = true;
                }
                break;

                case COMMAND_CLANG_RELINK_ACTIVE:
                case COMMAND_CLANG_REBUILD_ACTIVE:
                {
                    handled = true;
                    _applicationObject.Documents.SaveAll();

                    try
                    {
                        BuildCancelFlag = false;

                        // build a config options block, set the delegates for build events to toggle
                        // our local build-is-running variable that will disable all other Clang actions until it finishes
                        var pbc = new ClangOps.ProjectBuildConfig();
                        pbc.BuildBegun        = (bool success) => { BuildInProgress = true; };
                        pbc.BuildFinished     = (bool success) => { BuildInProgress = false; };
                        pbc.BuildShouldCancel = this;
                        pbc.JustLink          = (cmd == COMMAND_CLANG_RELINK_ACTIVE);

                        // start the build on another thread so the output pane updates asynchronously
                        ParameterizedThreadStart buildDelegate =
                            _CVXOps.BuildActiveProject;
                        var newThread = new Thread(buildDelegate);
                        newThread.Start(pbc);
                    }
                    catch (Exception ex)
                    {
                        BuildInProgress = false;
                        MessageBox.Show(ex.Message, "ClangVSx - Project Build Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                break;
                }
            }
        }
コード例 #2
0
ファイル: CVXConnect.cs プロジェクト: tigaliang/ClangVSx
        /// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary>
        /// <param term='commandName'>The name of the command to execute.</param>
        /// <param term='executeOption'>Describes how the command should be run.</param>
        /// <param term='varIn'>Parameters passed from the caller to the command handler.</param>
        /// <param term='varOut'>Parameters passed from the command handler to the caller.</param>
        /// <param term='handled'>Informs the caller if the command was handled or not.</param>
        /// <seealso class='Exec' />
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut,
            ref bool handled)
        {
            handled = false;
              if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
              {
            String cmd = GetCommandShortName(commandName);
            switch (cmd)
            {
              case COMMAND_CLANG_SETTINGS_DLG:
            {
              handled = true;
              ShowCVXSettingsDialog();
            }
            break;

              case COMMAND_CLANG_CANCEL_BUILD:
            {
              handled = true;
              BuildCancelFlag = true;
            }
            break;

              case COMMAND_CLANG_RELINK_ACTIVE:
              case COMMAND_CLANG_REBUILD_ACTIVE:
            {
              handled = true;
              _applicationObject.Documents.SaveAll();

              try
              {
                BuildCancelFlag = false;

                // build a config options block, set the delegates for build events to toggle
                // our local build-is-running variable that will disable all other Clang actions until it finishes
                var pbc = new ClangOps.ProjectBuildConfig();
                pbc.BuildBegun = (bool success) => { BuildInProgress = true; };
                pbc.BuildFinished = (bool success) => { BuildInProgress = false; };
                pbc.BuildShouldCancel = this;
                pbc.JustLink = (cmd == COMMAND_CLANG_RELINK_ACTIVE);

                // start the build on another thread so the output pane updates asynchronously
                ParameterizedThreadStart buildDelegate =
                    _CVXOps.BuildActiveProject;
                var newThread = new Thread(buildDelegate);
                newThread.Start(pbc);
              }
              catch (Exception ex)
              {
                BuildInProgress = false;
                MessageBox.Show(ex.Message, "ClangVSx - Project Build Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
              }
            }
            break;
            }
              }
        }