Beispiel #1
0
        public void Exec(string commandName,
                  EnvDTE.vsCommandExecOption executeOption,
                  ref object varIn,
                  ref object varOut,
                  ref bool handled)
        {
            try
            {
                handled = false;
                if (executeOption == EnvDTE.vsCommandExecOption.vsCommandExecOptionDoDefault)
                {
                    switch (commandName)
                    {
                        case Res.LaunchDesignerFullCommand:
                            handled = true;
                            extLoader.loadDesigner(null);
                            break;
                        case Res.LaunchLinguistFullCommand:
                            handled = true;
                            ExtLoader.loadLinguist(null);
                            break;
                        case Res.LaunchAssistantFullCommand:
                            handled = true;
                            ExtLoader.loadAssistant();
                            break;
                        case Res.ImportProFileFullCommand:
                            handled = true;
                            ExtLoader.ImportProFile();
                            break;
                        case Res.ImportPriFileFullCommand:
                            handled = true;
                            ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(_applicationObject));
                            break;
                        case Res.ExportPriFileFullCommand:
                            handled = true;
                            ExtLoader.ExportPriFile();
                            break;
                        case Res.ExportProFileFullCommand:
                            handled = true;
                            ExtLoader.ExportProFile();
                            break;
                        case Res.ChangeSolutionQtVersionFullCommand:
                            QtVersionManager vManager = QtVersionManager.The();
                            if (formChangeQtVersion == null)
                                formChangeQtVersion = new FormChangeQtVersion();
                            formChangeQtVersion.UpdateContent(ChangeFor.Solution);
                            if (formChangeQtVersion.ShowDialog() == DialogResult.OK)
                            {
                                string newQtVersion = formChangeQtVersion.GetSelectedQtVersion();
                                if (newQtVersion != null)
                                {
                                    string currentPlatform = null;
                                    try
                                    {
                                        SolutionConfiguration config = _applicationObject.Solution.SolutionBuild.ActiveConfiguration;
                                        SolutionConfiguration2 config2 = config as SolutionConfiguration2;
                                        currentPlatform = config2.PlatformName;
                                    }
                                    catch
                                    {
                                    }
                                    if (string.IsNullOrEmpty(currentPlatform))
                                        return;

                                    vManager.SetPlatform(currentPlatform);

                                    foreach (Project project in HelperFunctions.ProjectsInSolution(_applicationObject))
                                    {
                                        if (HelperFunctions.IsQt4Project(project))
                                        {
                                            string OldQtVersion = vManager.GetProjectQtVersion(project, currentPlatform);
                                            if (OldQtVersion == null)
                                                OldQtVersion = vManager.GetDefaultVersion();

                                            QtProject qtProject = QtProject.Create(project);
                                            bool newProjectCreated = false;
                                            qtProject.ChangeQtVersion(OldQtVersion, newQtVersion, ref newProjectCreated);
                                        }
                                    }
                                    vManager.SaveSolutionQtVersion(_applicationObject.Solution, newQtVersion);
                                }
                            }
                            break;
                        case Res.ProjectQtSettingsFullCommand:
                            handled = true;
                            EnvDTE.DTE dte = _applicationObject;
                            Project pro = HelperFunctions.GetSelectedQtProject(dte);
                            if (pro != null)
                            {
                                if (formProjectQtSettings == null)
                                    formProjectQtSettings = new FormProjectQtSettings();
                                formProjectQtSettings.SetProject(pro);
                                formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                                MainWinWrapper ww = new MainWinWrapper(dte);
                                formProjectQtSettings.ShowDialog(ww);
                            }
                            else
                                MessageBox.Show(SR.GetString("NoProjectOpened"));
                            break;
                        case Res.ChangeProjectQtVersionFullCommand:
                            handled = true;
                            dte = _applicationObject;
                            pro = HelperFunctions.GetSelectedProject(dte);
                            if (pro != null && HelperFunctions.IsQMakeProject(pro))
                            {
                                if (formChangeQtVersion == null)
                                    formChangeQtVersion = new FormChangeQtVersion();
                                formChangeQtVersion.UpdateContent(ChangeFor.Project);
                                MainWinWrapper ww = new MainWinWrapper(dte);
                                if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                                {
                                    string qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                                    QtVersionManager vm = QtVersionManager.The();
                                    string qtPath = vm.GetInstallPath(qtVersion);
                                    HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + qtPath + "\\bin;$(PATH)", true);
                                }
                            }
                            break;
                        case Res.VSQtOptionsFullCommand:
                            handled = true;
                            if (formQtVersions == null)
                            {
                                formQtVersions = new FormVSQtSettings();
                                formQtVersions.LoadSettings();
                            }
                            formQtVersions.StartPosition = FormStartPosition.CenterParent;
                            MainWinWrapper mww = new MainWinWrapper(_applicationObject);
                            if (formQtVersions.ShowDialog(mww) == DialogResult.OK)
                                formQtVersions.SaveSettings();
                            break;
                        case Res.CreateNewTranslationFileFullCommand:
                            handled = true;
                            pro = HelperFunctions.GetSelectedQtProject(_applicationObject);
                            Translation.CreateNewTranslationFile(pro);
                            break;
                        case Res.CommandBarName + ".Connect.lupdate":
                            handled = true;
                            Translation.RunlUpdate(HelperFunctions.GetSelectedFiles(_applicationObject),
                                HelperFunctions.GetSelectedQtProject(_applicationObject));
                            break;
                        case Res.CommandBarName + ".Connect.lrelease":
                            handled = true;
                            Translation.RunlRelease(HelperFunctions.GetSelectedFiles(_applicationObject));
                            break;
                        case Res.lupdateProjectFullCommand:
                            handled = true;
                            pro = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                            Translation.RunlUpdate(pro);
                            break;
                        case Res.lreleaseProjectFullCommand:
                            handled = true;
                            pro = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                            Translation.RunlRelease(pro);
                            break;
                        case Res.lupdateSolutionFullCommand:
                            handled = true;
                            Translation.RunlUpdate(Connect._applicationObject.Solution);
                            break;
                        case Res.lreleaseSolutionFullCommand:
                            handled = true;
                            Translation.RunlRelease(Connect._applicationObject.Solution);
                            break;
                        case Res.ConvertToQtFullCommand:
                        case Res.ConvertToQMakeFullCommand:
                            if (MessageBox.Show(SR.GetString("ConvertConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                handled = true;
                                dte = _applicationObject;
                                pro = HelperFunctions.GetSelectedProject(dte);
                                HelperFunctions.ToggleProjectKind(pro);
                            }
                            break;
                    }
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
            }
        }
Beispiel #2
0
        public void Exec(string commandName,
                         EnvDTE.vsCommandExecOption executeOption,
                         ref object varIn,
                         ref object varOut,
                         ref bool handled)
        {
            try
            {
                handled = false;
                if (executeOption == EnvDTE.vsCommandExecOption.vsCommandExecOptionDoDefault)
                {
                    switch (commandName)
                    {
                    case Res.LaunchDesignerFullCommand:
                        handled = true;
                        extLoader.loadDesigner(null);
                        break;

                    case Res.LaunchLinguistFullCommand:
                        handled = true;
                        ExtLoader.loadLinguist(null);
                        break;

                    case Res.LaunchAssistantFullCommand:
                        handled = true;
                        ExtLoader.loadAssistant();
                        break;

                    case Res.ImportProFileFullCommand:
                        handled = true;
                        ExtLoader.ImportProFile();
                        break;

                    case Res.ImportPriFileFullCommand:
                        handled = true;
                        ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(_applicationObject));
                        break;

                    case Res.ExportPriFileFullCommand:
                        handled = true;
                        ExtLoader.ExportPriFile();
                        break;

                    case Res.ExportProFileFullCommand:
                        handled = true;
                        ExtLoader.ExportProFile();
                        break;

                    case Res.ChangeSolutionQtVersionFullCommand:
                        QtVersionManager vManager = QtVersionManager.The();
                        if (formChangeQtVersion == null)
                        {
                            formChangeQtVersion = new FormChangeQtVersion();
                        }
                        formChangeQtVersion.UpdateContent(ChangeFor.Solution);
                        if (formChangeQtVersion.ShowDialog() == DialogResult.OK)
                        {
                            string newQtVersion = formChangeQtVersion.GetSelectedQtVersion();
                            if (newQtVersion != null)
                            {
                                string currentPlatform = null;
                                try
                                {
                                    SolutionConfiguration  config  = _applicationObject.Solution.SolutionBuild.ActiveConfiguration;
                                    SolutionConfiguration2 config2 = config as SolutionConfiguration2;
                                    currentPlatform = config2.PlatformName;
                                }
                                catch
                                {
                                }
                                if (string.IsNullOrEmpty(currentPlatform))
                                {
                                    return;
                                }

                                vManager.SetPlatform(currentPlatform);

                                foreach (Project project in HelperFunctions.ProjectsInSolution(_applicationObject))
                                {
                                    if (HelperFunctions.IsQt4Project(project))
                                    {
                                        string OldQtVersion = vManager.GetProjectQtVersion(project, currentPlatform);
                                        if (OldQtVersion == null)
                                        {
                                            OldQtVersion = vManager.GetDefaultVersion();
                                        }

                                        QtProject qtProject         = QtProject.Create(project);
                                        bool      newProjectCreated = false;
                                        qtProject.ChangeQtVersion(OldQtVersion, newQtVersion, ref newProjectCreated);
                                    }
                                }
                                vManager.SaveSolutionQtVersion(_applicationObject.Solution, newQtVersion);
                            }
                        }
                        break;

                    case Res.ProjectQtSettingsFullCommand:
                        handled = true;
                        EnvDTE.DTE dte = _applicationObject;
                        Project    pro = HelperFunctions.GetSelectedQtProject(dte);
                        if (pro != null)
                        {
                            if (formProjectQtSettings == null)
                            {
                                formProjectQtSettings = new FormProjectQtSettings();
                            }
                            formProjectQtSettings.SetProject(pro);
                            formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                            MainWinWrapper ww = new MainWinWrapper(dte);
                            formProjectQtSettings.ShowDialog(ww);
                        }
                        else
                        {
                            MessageBox.Show(SR.GetString("NoProjectOpened"));
                        }
                        break;

                    case Res.ChangeProjectQtVersionFullCommand:
                        handled = true;
                        dte     = _applicationObject;
                        pro     = HelperFunctions.GetSelectedProject(dte);
                        if (pro != null && HelperFunctions.IsQMakeProject(pro))
                        {
                            if (formChangeQtVersion == null)
                            {
                                formChangeQtVersion = new FormChangeQtVersion();
                            }
                            formChangeQtVersion.UpdateContent(ChangeFor.Project);
                            MainWinWrapper ww = new MainWinWrapper(dte);
                            if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                            {
                                string           qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                                QtVersionManager vm        = QtVersionManager.The();
                                string           qtPath    = vm.GetInstallPath(qtVersion);
                                HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + qtPath + "\\bin;$(PATH)", true);
                            }
                        }
                        break;

                    case Res.VSQtOptionsFullCommand:
                        handled = true;
                        if (formQtVersions == null)
                        {
                            formQtVersions = new FormVSQtSettings();
                            formQtVersions.LoadSettings();
                        }
                        formQtVersions.StartPosition = FormStartPosition.CenterParent;
                        MainWinWrapper mww = new MainWinWrapper(_applicationObject);
                        if (formQtVersions.ShowDialog(mww) == DialogResult.OK)
                        {
                            formQtVersions.SaveSettings();
                        }
                        break;

                    case Res.CreateNewTranslationFileFullCommand:
                        handled = true;
                        pro     = HelperFunctions.GetSelectedQtProject(_applicationObject);
                        Translation.CreateNewTranslationFile(pro);
                        break;

                    case Res.CommandBarName + ".Connect.lupdate":
                        handled = true;
                        Translation.RunlUpdate(HelperFunctions.GetSelectedFiles(_applicationObject),
                                               HelperFunctions.GetSelectedQtProject(_applicationObject));
                        break;

                    case Res.CommandBarName + ".Connect.lrelease":
                        handled = true;
                        Translation.RunlRelease(HelperFunctions.GetSelectedFiles(_applicationObject));
                        break;

                    case Res.lupdateProjectFullCommand:
                        handled = true;
                        pro     = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                        Translation.RunlUpdate(pro);
                        break;

                    case Res.lreleaseProjectFullCommand:
                        handled = true;
                        pro     = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                        Translation.RunlRelease(pro);
                        break;

                    case Res.lupdateSolutionFullCommand:
                        handled = true;
                        Translation.RunlUpdate(Connect._applicationObject.Solution);
                        break;

                    case Res.lreleaseSolutionFullCommand:
                        handled = true;
                        Translation.RunlRelease(Connect._applicationObject.Solution);
                        break;

                    case Res.ConvertToQtFullCommand:
                    case Res.ConvertToQMakeFullCommand:
                        if (MessageBox.Show(SR.GetString("ConvertConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            handled = true;
                            dte     = _applicationObject;
                            pro     = HelperFunctions.GetSelectedProject(dte);
                            HelperFunctions.ToggleProjectKind(pro);
                        }
                        break;
                    }
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
            }
        }