private void execHandler(object sender, EventArgs e) { var command = sender as OleMenuCommand; if (command == null) { return; } switch ((CommandId)command.CommandID.ID) { case CommandId.LaunchDesignerId: DefaultEditorsHandler.Instance.StartEditor(DefaultEditor.Kind.Ui); break; case CommandId.LaunchLinguistId: DefaultEditorsHandler.Instance.StartEditor(DefaultEditor.Kind.Ts); break; case CommandId.OpenProFileId: ExtLoader.ImportProFile(); break; case CommandId.ImportPriFileId: ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte)); break; case CommandId.ExportPriFileId: ExtLoader.ExportPriFile(); break; case CommandId.ExportProFileId: ExtLoader.ExportProFile(); break; case CommandId.CreateNewTsFileId: Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(Vsix .Instance.Dte)); break; case CommandId.ConvertToQtId: case CommandId.ConvertToQmakeId: { var caption = SR.GetString("ConvertTitle"); var text = SR.GetString("ConvertConfirmation"); if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes) { HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(Vsix .Instance.Dte)); } } break; case CommandId.ConvertToQtMsBuild: { QtMsBuildConverter.SolutionToQtMsBuild(); } break; case CommandId.QtProjectSettingsId: { var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte); int projectVersion = QtProject.GetFormatVersion(pro); if (projectVersion >= Resources.qtMinFormatVersion_Settings) { Vsix.Instance.Dte.ExecuteCommand("Project.Properties"); } else if (pro != null) { using (var formProjectQtSettings = new FormProjectQtSettings()) { formProjectQtSettings.SetProject(pro); formProjectQtSettings.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(Vsix.Instance.Dte); formProjectQtSettings.ShowDialog(ww); } } else { MessageBox.Show(SR.GetString("NoProjectOpened")); } } break; case CommandId.ChangeProjectQtVersionId: { var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte); if (HelperFunctions.IsQMakeProject(pro)) { using (var formChangeQtVersion = new FormChangeQtVersion()) { formChangeQtVersion.UpdateContent(ChangeFor.Project); var ww = new MainWinWrapper(Vsix.Instance.Dte); if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK) { var qtVersion = formChangeQtVersion.GetSelectedQtVersion(); HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true); } } } } break; case CommandId.QtOptionsId: { using (var formQtVersions = new FormVSQtSettings()) { formQtVersions.LoadSettings(); formQtVersions.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(Vsix.Instance.Dte); if (formQtVersions.ShowDialog(ww) == DialogResult.OK) { formQtVersions.SaveSettings(); } } } break; } }
private void execHandler(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); var command = sender as OleMenuCommand; if (command == null) { return; } switch ((CommandId)command.CommandID.ID) { case CommandId.ViewQtHelpId: VsShellUtilities.OpenSystemBrowser("https://www.qt.io/developers"); break; case CommandId.LaunchDesignerId: QtVsToolsPackage.Instance.QtDesigner.Start(hideWindow: false); break; case CommandId.LaunchLinguistId: QtVsToolsPackage.Instance.QtLinguist.Start(hideWindow: false); break; case CommandId.OpenProFileId: ExtLoader.ImportProFile(); break; case CommandId.ImportPriFileId: ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte)); break; case CommandId.ExportPriFileId: ExtLoader.ExportPriFile(); break; case CommandId.ExportProFileId: ExtLoader.ExportProFile(); break; case CommandId.ConvertToQtId: case CommandId.ConvertToQmakeId: { var caption = SR.GetString("ConvertTitle"); var text = SR.GetString("ConvertConfirmation"); if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes) { HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(QtVsToolsPackage .Instance.Dte)); } } break; case CommandId.ConvertToQtMsBuild: { QtMsBuildConverter.SolutionToQtMsBuild(); } break; case CommandId.QtProjectSettingsId: { var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte); int projectVersion = QtProject.GetFormatVersion(pro); if (projectVersion >= Resources.qtMinFormatVersion_Settings) { QtVsToolsPackage.Instance.Dte.ExecuteCommand("Project.Properties"); } else if (pro != null) { using (var formProjectQtSettings = new FormProjectQtSettings()) { formProjectQtSettings.SetProject(pro); formProjectQtSettings.StartPosition = FormStartPosition.CenterParent; var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte); formProjectQtSettings.ShowDialog(ww); } } else { MessageBox.Show(SR.GetString("NoProjectOpened")); } } break; case CommandId.ChangeProjectQtVersionId: { var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte); if (HelperFunctions.IsQMakeProject(pro)) { using (var formChangeQtVersion = new FormChangeQtVersion()) { formChangeQtVersion.UpdateContent(ChangeFor.Project); var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte); if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK) { var qtVersion = formChangeQtVersion.GetSelectedQtVersion(); HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true); } } } } break; case CommandId.QtOptionsId: QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtOptionsPage)); break; case CommandId.QtVersionsId: QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtVersionsPage)); break; } }