Ejemplo n.º 1
0
		public void Execute(object Application, int hwndOwner, 
			ref object[] ContextParams, ref object[] CustomParams, ref EnvDTE.wizardResult retval)
		{
			// TODO: Add magic here
			IWizardExtension[] extensions = LoadExtensions(CustomParams);

			foreach(IWizardExtension extension in extensions)
			{
				extension.Init(this);
			}

			try
			{
				dteInstance = (DTE) Application;
				owner = hwndOwner;

				projectName = (String) ContextParams[1];
				localProjectPath = (String) ContextParams[2];
				installationDirectory = (String) ContextParams[3];
				exclusive = (bool) ContextParams[4];
				solutionName = (String) ContextParams[5];

				context = new ExtensionContext(dteInstance, projectName, localProjectPath, installationDirectory, solutionName);

				if (exclusive)
				{
					vsPromptResult promptResult = dteInstance.ItemOperations.PromptToSave;

					if (promptResult == vsPromptResult.vsPromptResultCancelled)
					{
						retval = wizardResult.wizardResultCancel;
						return;
					}
				}

				using(WizardDialog dlg = new WizardDialog(context))
				{
					dlg.WizardTitle = WizardTitle;
					
					AddPanels(dlg);

					WizardUIEventHandler eventHandler = (WizardUIEventHandler) eventList[AddPanelsEventKey];
					
					if (eventHandler != null)
					{
						eventHandler(this, dlg, context);
					}

					dlg.ShowDialog(this);
					retval = dlg.WizardResult;

					if (retval == wizardResult.wizardResultSuccess)
					{
						CreateProject(dlg);
					}
					else
					{
						retval = wizardResult.wizardResultCancel;
						return;
					}
				}
			}
			catch(Exception ex)
			{
				String message = ex.GetType().Name + "\r\n\r\n" + ex.Message + "\r\n\r\n" + ex.StackTrace;
				
				MessageBox.Show(this, "Exception during project creation. \r\n" + message, 
					"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				
				throw;
			}
			finally
			{
				foreach(IWizardExtension extension in extensions)
				{
					extension.Terminate(this);
				}
			}
		}