/// <summary> /// Gets the form values from the wizard, and set them into the base private fields. /// </summary> /// <param name="form">The wizard form.</param> private void GetFormValues(ItemTemplatesWinFormsWizard form) { _selectedModel = form.SelectedModel; _selectedEntity = form.SelectedEntity; _detailEntity = form.SelectedDetailEntity; _GuiType = form.GuiType; _constraintName = form.ConstraintName; _dataAccessTechnology = form.DataAccessTechnology; }
/// <summary> /// Runs custom wizard logic at the beginning of a template wizard run. /// </summary> /// <param name="automationObject">The automation object being used by the template wizard.</param> /// <param name="replacementsDictionary">The list of standard parameters to be replaced.</param> /// <param name="runKind">A <see cref="T:Microsoft.VisualStudio.TemplateWizard.WizardRunKind" /> indicating the type of wizard run.</param> /// <param name="customParams">The custom parameters with which to perform parameter replacement in the project.</param> public void RunStarted(Object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, Object[] customParams) { try { dte = automationObject as DTE; Array activeProjects = (Array)dte.ActiveSolutionProjects; Project activeProj = (Project)activeProjects.GetValue(0); _projectPath = System.IO.Path.GetDirectoryName(activeProj.FullName); _projectNamespace = activeProj.Properties.Item("DefaultNamespace").Value.ToString(); _NetFxVersion = replacementsDictionary["$targetframeworkversion$"]; _itemTemplateTempPath = customParams[0].ToString().Substring(0, customParams[0].ToString().LastIndexOf("\\")); ItemTemplatesWinFormsWizard form = new ItemTemplatesWinFormsWizard(_language, dte, _projectType); form.StartPosition = FormStartPosition.CenterScreen; DialogResult result = form.ShowDialog(); wizardFinished = result == System.Windows.Forms.DialogResult.OK ? true : false; if (wizardFinished) { GetFormValues(form); string providerConnectionString = ItemTemplateUtilities.GetProviderConnectionString(_selectedModel, dte, true); if (!string.IsNullOrEmpty(providerConnectionString)) { _connectionString = providerConnectionString; _connectionName = ItemTemplateUtilities.GetConnectionStringName(_selectedModel, dte, true); _connection = new MySqlConnection(_connectionString); } } } catch (WizardCancelledException wce) { throw wce; } catch (Exception e) { SendToGeneralOutputWindow(string.Format("An error occurred: {0}\n\n {1}", e.Message, e.StackTrace)); } }