Exemplo n.º 1
0
        public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            var source = new ParameterSource(replacementsDictionary);
            var doc    = Helpers.LoadWizardXml(replacementsDictionary);
            var ns     = Helpers.WizardNamespace;

            var model = new ProjectWizardPageModel(source, doc.Root.Elements(ns + "Options").FirstOrDefault());

            if (model.SupportsAppName)
            {
                model.AppName = replacementsDictionary["$projectname$"];
            }
            if (model.RequiresInput)
            {
                var panel  = new ProjectWizardPageView(model);
                var dialog = new BaseDialog {
                    Content = panel, Title = model.Title, ClientSize = new Size(-1, 400), Style = "themed"
                };
                if (!dialog.ShowModal(Helpers.MainWindow))
                {
                    throw new WizardBackoutException();
                }
            }
        }
Exemplo n.º 2
0
        public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            var source = new ParameterSource(replacementsDictionary);

            var model = new ProjectWizardPageModel(source);

            if (model.SupportsAppName)
            {
                model.AppName = replacementsDictionary["$projectname$"];
            }
            if (model.RequiresInput)
            {
                var panel  = new ProjectWizardPageView(model);
                var dialog = new BaseDialog {
                    Content = panel, Title = model.Title, ClientSize = new Size(-1, 400), Style = "eto.vstheme"
                };
                if (!dialog.ShowModal(Helpers.MainWindow))
                {
                    throw new WizardBackoutException();
                }

                // super hack: Due to a bug in VS we cannot use item templates without it crashing..
                // see Microsoft.VisualStudio.TemplateEngine.Wizard.TemplateEngineWizard.PostInvocationTelemetry
                // for details on why it doesn't work...
                if (customParams[0] is string str && !str.Contains("~PC"))
                {
                    str             = str.Replace("~IC", "~PC");
                    customParams[0] = str;
                }
            }
        }
Exemplo n.º 3
0
        public ProjectWizardPage(ProjectWizard wizard)
        {
            this.Wizard = wizard;
            var source = new ParameterSource(wizard);

            source.ParameterChanged += (name, value) =>
            {
                if (name == "AppName")
                {
                    source.SetParameter("ProjectName", value);
                    Validate();
                }
            };
            this.model = new ProjectWizardPageModel(source, null);
            Validate();
        }
Exemplo n.º 4
0
        public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            var source = new ParameterSource(replacementsDictionary);
            var model  = new ProjectWizardPageModel(source);

            model.AppName = replacementsDictionary["$projectname$"];
            if (model.RequiresInput)
            {
                var panel  = new ProjectWizardPageView(model);
                var dialog = new BaseDialog {
                    Content = panel, Title = model.Title
                };
                if (!dialog.ShowModal(Helpers.MainWindow))
                {
                    throw new WizardBackoutException();
                }
            }
        }
Exemplo n.º 5
0
        public override void ItemsCreated(System.Collections.Generic.IEnumerable <IWorkspaceFileObject> items)
        {
            base.ItemsCreated(items);

#if OLD
            var model = new ProjectWizardPageModel(new ParameterSource(this), null);

            // hard coded as we can't get at any custom data out of the template..
            // at least try to be a little generic here..
            string fileName  = null;
            string extension = null;
            if (model.UseXeto)
            {
                extension = ".xeto";
            }
            else if (model.UseJeto)
            {
                extension = ".jeto";
            }
            else if (model.UseCodePreview)
            {
                extension = ".eto.cs";
            }
            else
            {
                fileName = model.IsLibrary ? "MyPanel.cs" : "MainForm.cs";
            }

            IEnumerable <Project> projects = items.OfType <Solution>().SelectMany(r => r.GetAllProjects()).ToList();
            if (!projects.Any())
            {
                projects = items.OfType <Project>();
            }

            /*
             * var item = items.SelectMany(r => r.GetItemFiles(false)).FirstOrDefault(r =>
             *      {
             *              if (extension != null && r.FileName.EndsWith(extension, StringComparison.OrdinalIgnoreCase))
             *                      return true;
             *              if (fileName != null && r.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase))
             *                      return true;
             *              return false;
             *
             *      });
             * if (item != null)
             * {
             *
             *      IdeApp.Workbench.OpenDocument(item);
             * }*/
            foreach (var proj in projects)
            {
                var item = proj.Files.FirstOrDefault(r => {
                    if (extension != null && r.FilePath.FileName.EndsWith(extension, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    if (fileName != null && r.FilePath.FileName.Equals(fileName, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    return(false);
                });
                if (item != null)
                {
                    IdeApp.Workbench.OpenDocument(item.FilePath, proj);
                }
            }
#endif
        }