diff options
Diffstat (limited to 'Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs')
| -rw-r--r-- | Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs index 2acc25187..4bc972fbb 100644 --- a/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs +++ b/Software/Visual_Studio/VSIX/Tango.BuildExtensions/RemoteDebugCommand.cs @@ -20,6 +20,7 @@ using Tango.Core.IO; using Tango.PMR.IO; using Google.Protobuf; using EnvDTE; +using System.Collections.Generic; namespace Tango.BuildExtensions { @@ -32,6 +33,9 @@ namespace Tango.BuildExtensions private ITransporter transporter; private bool _attached; private string processId; + private OleMenuCommand _menuCommand; + private IList<Project> _projects; + /// <summary> /// Command ID. @@ -64,14 +68,44 @@ namespace Tango.BuildExtensions _dteDebuggerEvents.OnEnterDesignMode += _dteDebuggerEvents_OnEnterDesignMode; + DTE.Events.SolutionEvents.Opened += () => + { + _projects = GetSolutionProjects().ToList(); + }; + this.package = package; OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService != null) { var menuCommandID = new CommandID(CommandSet, CommandId); - var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID); - commandService.AddCommand(menuItem); + _menuCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID); + _menuCommand.Visible = false; + _menuCommand.BeforeQueryStatus += _menuCommand_BeforeQueryStatus; + commandService.AddCommand(_menuCommand); + } + } + + private void _menuCommand_BeforeQueryStatus(object sender, EventArgs e) + { + (sender as OleMenuCommand).Visible = false; + + if (DTE.Debugger.CurrentMode == dbgDebugMode.dbgDesignMode + && DTE.Solution != null + && DTE.Solution.IsOpen) + { + String projectName = DTE.Solution.Properties.Item("StartupProject").Value.ToStringSafe(); + + if (projectName != null) + { + var project = _projects.SingleOrDefault(x => x.Name == projectName); + String path = GetProjectOutputFilePath(project); + + if (Path.GetExtension(path.ToLower()) == ".exe") + { + (sender as OleMenuCommand).Visible = true; + } + } } } |
