/// <summary> /// It is called before every command. Update the running state. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnBeforeClangCommand(object sender, EventArgs e) { if (!(sender is OleMenuCommand command)) { return; } if (IsAToolbarCommand(command)) { if (SolutionInfo.AreToolbarCommandsEnabled() == false) { command.Enabled = false; return; } } else if (SolutionInfo.AreContextMenuCommandsEnabled() == false) { command.Enabled = false; return; } if (VsServiceProvider.TryGetService(typeof(DTE), out object dte) && !(dte as DTE2).Solution.IsOpen) { command.Visible = command.Enabled = false; } else if (vsBuildRunning && command.CommandID.ID != CommandIds.kSettingsId) { command.Visible = command.Enabled = false; } else { command.Visible = command.Enabled = command.CommandID.ID != CommandIds.kStopClang ? !running : running; } }
/// <summary> /// It is called before every command. Update the running state. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnBeforeClangCommand(object sender, EventArgs e) { if (!(sender is OleMenuCommand command)) { return; } if (IsAToolbarCommand(command)) { if (SolutionInfo.AreToolbarCommandsEnabled() == false) { command.Enabled = command.CommandID.ID == CommandIds.kClangFormatToolbarId && SolutionInfo.ActiveDocumentValidation(); return; } } else if (SolutionInfo.AreContextMenuCommandsEnabled() == false) { command.Enabled = false; return; } if (VsServiceProvider.TryGetService(typeof(DTE), out object dte) && !(dte as DTE2).Solution.IsOpen) { command.Visible = command.Enabled = false; } //else if (command.CommandID.ID == CommandIds.kJsonCompilationDatabase) //{ // ItemsCollector itemsCollector = new ItemsCollector(true); // command.Visible = command.Enabled = itemsCollector.SolutionOrProjectIsSelected(); //} else if (vsBuildRunning && command.CommandID.ID != CommandIds.kSettingsId) { command.Visible = command.Enabled = false; } else { command.Visible = command.Enabled = command.CommandID.ID != CommandIds.kStopClang ? !running : running; } }