Ejemplo n.º 1
0
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            this.projectDir = replacementsDictionary["$destinationdirectory$"];
            try
            {
                EnvDTE80.DTE2 dte = null;
                VsTheme vsTheme = VsTheme.Unknown;
                try
                {
                    dte = automationObject as EnvDTE80.DTE2;
                }
                catch { }
                if (dte != null)
                {
                    ThemeManager tManager = new ThemeManager(dte);
                    vsTheme = tManager.GetCurrentTheme();
                }
                ConfigureForm form = new ConfigureForm(vsTheme,replacementsDictionary["$type$"]);
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    bool cancel = true;

                    this.selectedVersions = form.SelectedVersions;
                    for (int i = CorelVersionInfo.MinVersion; i < CorelVersionInfo.MaxVersion; i++)
                    {

                        replacementsDictionary.Add("$corel" + i.ToString() + "$", "0");

                    }
                    for (int i = 0; i <selectedVersions.Count; i++)
                    {
                        CorelVersionInfo corel = selectedVersions[i];
                        if (corel.CorelInstallationNotFound)
                        {
                            System.Windows.Forms.MessageBox.Show(string.Format("{0} not found", corel.CorelFullName));

                        }
                        else
                        {
                            cancel = false;
                            string corelAddonsPath = "";
                            if (corel.Corel64Bit == CorelVersionInfo.CorelIs64Bit.Corel32)
                                corel.CorelAddonsPath(out corelAddonsPath);
                            else
                                corel.CorelAddonsPath64(out corelAddonsPath);
                            replacementsDictionary["$corel" + corel.CorelVersion.ToString() + "$"] = "1";

                            replacementsDictionary.Add("$CorelAddonsPath" + corel.CorelVersion + "$", corelAddonsPath);

                            replacementsDictionary.Add("$CorelProgramPath" + corel.CorelVersion + "$", corel.CorelExePath);

                        }
                    }

                    if (cancel)
                    {
                        System.Windows.Forms.MessageBox.Show("Operation is canceled!");

                        throw new WizardCancelledException();

                    }

                    replacementsDictionary.Add("$GuidA$", Guid.NewGuid().ToString());
                    replacementsDictionary.Add("$GuidB$", Guid.NewGuid().ToString());
                    replacementsDictionary.Add("$GuidC$", Guid.NewGuid().ToString());
                    replacementsDictionary.Add("$Caption$", form.DockerCaption);

                    finish = true;

                }
                else
                {
                    throw new WizardCancelledException();
                }
            }
            catch(WizardCancelledException)
            {
                finish = false;

            }
            catch (Exception)
            {
                finish = false;

            }
        }
Ejemplo n.º 2
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            this.projectDir = replacementsDictionary["$destinationdirectory$"];

            try
            {
                EnvDTE80.DTE2 dte     = null;
                VsTheme       vsTheme = VsTheme.Unknown;
                try
                {
                    dte = automationObject as EnvDTE80.DTE2;
                }
                catch { }
                if (dte != null)
                {
                    ThemeManager tManager = new ThemeManager(dte);
                    vsTheme = tManager.GetCurrentTheme();
                }
                ConfigureForm form = new ConfigureForm(vsTheme, replacementsDictionary["$type$"]);
                if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    bool cancel = true;

                    this.selectedVersions = form.SelectedVersions;
                    DirectoryInfo dir;
                    string        targetFolder = "";
                    if (form.GlobalTargets)
                    {
                        replacementsDictionary.Add("$targetvar$", "$([System.Environment]::GetEnvironmentVariable('localappdata'))\\bonus630\\");
                        dir = new DirectoryInfo(System.Environment.GetEnvironmentVariable("localappdata") + "\\bonus630");
                        if (!dir.Exists)
                        {
                            dir.Create();
                        }
                        targetFolder = dir.FullName;
                    }
                    else
                    {
                        replacementsDictionary.Add("$targetvar$", "$(SolutionDir)");
                        dir = new DirectoryInfo(this.projectDir);
                        if (dir.Exists)
                        {
                            targetFolder = dir.Parent.FullName;
                        }
                    }

                    if (!string.IsNullOrEmpty(targetFolder))
                    {
                        TargetsCreator targetsCreator = new TargetsCreator();
                        targetsCreator.WriteTargetsFile(targetFolder);
                    }
                    for (int i = CorelVersionInfo.MinVersion; i < CorelVersionInfo.MaxVersion; i++)
                    {
                        replacementsDictionary.Add("$corel" + i.ToString() + "$", "");
                    }
                    foreach (var item in ProjectTypeGuid)
                    {
                        replacementsDictionary.Add(item.Key, item.Value);
                    }
                    for (int i = CorelVersionInfo.MinVersion; i < CorelVersionInfo.MaxVersion; i++)
                    {
                        CorelVersionInfo corel = new CorelVersionInfo(i);
                        //CorelVersionInfo corel = selectedVersions[i];
                        //string corelAddonsPath = "";
                        //if (corel.Corel64Bit == CorelVersionInfo.CorelIs64Bit.Corel32)
                        //    corel.CorelAddonsPath(out corelAddonsPath);
                        //else
                        //    corel.CorelAddonsPath64(out corelAddonsPath);

                        string projectKind = replacementsDictionary["$lang$"];
                        if (projectKind.Equals("cs"))
                        {
                            replacementsDictionary["$corel" + corel.CorelVersion.ToString() + "$"] = Helper.buildConfigurationCS(corel);
                        }
                        else if (projectKind.Equals("vb"))
                        {
                            replacementsDictionary["$corel" + corel.CorelVersion.ToString() + "$"] = Helper.buildConfigurationVB(corel);
                        }
                        else
                        {
                            throw new WizardCancelledException();
                        }
                        if (!corel.CorelInstallationNotFound)
                        {
                            cancel = false;
                        }
                        //if (corel.CorelInstallationNotFound)
                        //{
                        //    System.Windows.Forms.MessageBox.Show(string.Format("{0} not found", corel.CorelFullName));
                        //}
                        //else
                        //{
                        //    cancel = false;
                        //}
                    }

                    if (cancel)
                    {
                        //System.Windows.Forms.MessageBox.Show("Operation is canceled!");

                        throw new WizardCancelledException("Operation is canceled!");
                    }



                    replacementsDictionary.Add("$GuidA$", Guid.NewGuid().ToString());
                    replacementsDictionary.Add("$GuidB$", Guid.NewGuid().ToString());
                    replacementsDictionary.Add("$GuidC$", Guid.NewGuid().ToString());
                    replacementsDictionary.Add("$Caption$", form.DockerCaption);

                    finish = true;
                }
                else
                {
                    finish = false;
                    throw new WizardCancelledException();
                }
            }
            catch (WizardCancelledException)
            {
                finish = false;
            }
            catch (Exception)
            {
                finish = false;
            }
        }