コード例 #1
0
        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.QtProjectSettingsId:
            {
                var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte);
                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;
            }
        }
コード例 #2
0
        private void execHandler(object sender, EventArgs e)
        {
            var command = sender as OleMenuCommand;

            if (command == null)
            {
                return;
            }

            switch ((CommandId)command.CommandID.ID)
            {
            case CommandId.ImportPriFileProjectId:
                ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.ExportPriFileProjectId:
                ExtLoader.ExportPriFile();
                break;

            case CommandId.ExportProFileProjectId:
                ExtLoader.ExportProFile();
                break;

            case CommandId.CreateNewTsFileProjectId:
                Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(Vsix
                                                                                          .Instance.Dte));
                break;

            case CommandId.lUpdateOnProjectId:
                Translation.RunlUpdate(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.lReleaseOnProjectId:
                Translation.RunlRelease(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.ConvertToQtProjectId:
            case CommandId.ConvertToQmakeProjectId:
            {
                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.QtProjectSettingsProjectId:
            {
                var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte);
                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.ChangeProjectQtVersionProjectId:
            {
                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.ProjectConvertToQtMsBuild:
            {
                QtMsBuildConverter.ProjectToQtMsBuild(
                    HelperFunctions.GetSelectedProject(Vsix.Instance.Dte));
            }
            break;

            case CommandId.ProjectAddNewQtClassProjectId:
            {
                try {
                    var project = HelperFunctions.GetSelectedProject(Vsix.Instance.Dte);
                    if (!HelperFunctions.IsQtProject(project))
                    {
                        return;
                    }

                    var vcProject = project.Object as VCProject;
                    if (vcProject == null)
                    {
                        return;
                    }

                    var loop = true;
                    do
                    {
                        var classWizard = new Wizards.ClassWizard.AddClassWizard();
                        loop = classWizard.Run(Vsix.Instance.Dte, vcProject.Name,
                                               vcProject.ProjectDirectory) == Wizards.WizardResult.Exception;
                    } while (loop);
                } catch {
                    // Deliberately ignore any kind of exception but close the dialog.
                }
            }
            break;
            }
        }