コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConvertVBToCSCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        ConvertVBToCSCommand(REConverterPackage package)
        {
            this._package   = package ?? throw new ArgumentNullException(nameof(package));
            _codeConversion = new CodeConversion(package, package.VsWorkspace, () => package.Options);

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                // Command in main menu
                var menuCommandId = new CommandID(CommandSet, MainMenuCommandId);
                var menuItem      = new OleMenuCommand(CodeEditorMenuItemCallback, menuCommandId);
                menuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatus;
                commandService.AddCommand(menuItem);

                // Command in code editor's context menu
                var ctxMenuCommandId = new CommandID(CommandSet, CtxMenuCommandId);
                var ctxMenuItem      = new OleMenuCommand(CodeEditorMenuItemCallback, ctxMenuCommandId);
                ctxMenuItem.BeforeQueryStatus += CodeEditorMenuItem_BeforeQueryStatus;
                commandService.AddCommand(ctxMenuItem);

                // Command in project item context menu
                var projectItemCtxMenuCommandId = new CommandID(CommandSet, ProjectItemCtxMenuCommandId);
                var projectItemCtxMenuItem      = new OleMenuCommand(ProjectItemMenuItemCallback, projectItemCtxMenuCommandId);
                projectItemCtxMenuItem.BeforeQueryStatus += ProjectItemMenuItem_BeforeQueryStatus;
                commandService.AddCommand(projectItemCtxMenuItem);

                // Command in project context menu
                var solutionOrProjectCtxMenuCommandId = new CommandID(CommandSet, SolutionOrProjectCtxMenuCommandId);
                var solutionOrProjectCtxMenuItem      = new OleMenuCommand(SolutionOrProjectMenuItemCallback, solutionOrProjectCtxMenuCommandId);
                solutionOrProjectCtxMenuItem.BeforeQueryStatus += SolutionOrProjectMenuItem_BeforeQueryStatus;
                commandService.AddCommand(solutionOrProjectCtxMenuItem);
            }
        }
コード例 #2
0
 public void SetTargetThread(uint systemThreadId) {
     int targetThreadIndex = Array.IndexOf(this.GetCurrentProcessThreads(), systemThreadId);
     if (targetThreadIndex == -1) {
         throw new DebuggerException("Invalid thread ID");
     } else {
         if (this.TargetThreadSystemId != systemThreadId) {
             Guid setCurrentThreadCmdGroup;
             uint setCurrentThreadCmdId;
             IVsCmdNameMapping vsCmdNameMapping = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsCmdNameMapping)) as IVsCmdNameMapping;
             vsCmdNameMapping.MapNameToGUIDID("Debug.SetCurrentThread", out setCurrentThreadCmdGroup, out setCurrentThreadCmdId);
             Microsoft.VisualStudio.Shell.OleMenuCommandService commandService = new Microsoft.VisualStudio.Shell.OleMenuCommandService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
             if (!commandService.GlobalInvoke(new CommandID(setCurrentThreadCmdGroup, (int)setCurrentThreadCmdId), Convert.ToString(targetThreadIndex + 1))) {
                 throw new DebuggerException("Unable to set the active thread in the debugger.");
             }
         }
     }
 }
コード例 #3
0
 public void Continue()
 {
     if (this.EnsureDebuggerService())
     {
         DBGMODE[] mode = new DBGMODE[1];
         // Only continue when broken in.
         if ((this.vsDebuggerService.GetMode(mode) == 0) && (mode[0] == DBGMODE.DBGMODE_Break))
         {
             Guid startCmdGroup;
             uint startCmdId;
             IVsCmdNameMapping vsCmdNameMapping = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsCmdNameMapping)) as IVsCmdNameMapping;
             vsCmdNameMapping.MapNameToGUIDID("Debug.Start", out startCmdGroup, out startCmdId);
             Microsoft.VisualStudio.Shell.OleMenuCommandService commandService = new Microsoft.VisualStudio.Shell.OleMenuCommandService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
             if (!commandService.GlobalInvoke(new CommandID(startCmdGroup, (int)startCmdId)))
             {
                 throw new DebuggerException("Unable to continue debugging.");
             }
         }
     }
 }