private void WizardWindow_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { WizardWindowVM oldWizardWindowVM = e.OldValue as WizardWindowVM; if (oldWizardWindowVM != null) { oldWizardWindowVM.WiazrdFinished -= wizardWindowVM_WiazrdFinished; } WizardWindowVM newWizardWindowVM = e.NewValue as WizardWindowVM; if (newWizardWindowVM != null) { newWizardWindowVM.WiazrdFinished += wizardWindowVM_WiazrdFinished; } }
protected override void Run() { try { this.launchAction = this.Command.Action; if (this.launchAction != LaunchAction.Install && this.launchAction != LaunchAction.Uninstall) { this.Log("This installer can only run in install or uninstall mode!"); this.Engine.Quit((int)ActionResult.NotExecuted); return; } if (!this.IsFullUiMode && !this.IsQuietUninstall) { this.Log("This installer can only run in full UI mode!"); this.Engine.Quit((int)ActionResult.NotExecuted); return; } this.Initialize(); this.detectCompleteHandle = new AutoResetEvent(false); this.applyCompleteHandle = new AutoResetEvent(false); this.InvokeDetect(); if (this.IsQuietUninstall) { this.Log("Installer is running in quiet uninstall mode"); this.Log("Waiting for detection to complete"); detectCompleteHandle.WaitOne(); this.InvokePlan(); this.Log("Waiting for execution to complete"); applyCompleteHandle.WaitOne(); } else { this.Log("Installer is running in full UI mode"); this.Log("Waiting for detection to complete"); detectCompleteHandle.WaitOne(); this.Log("Detection complete, ready to start UI"); this.uiThreadDispatcher = Dispatcher.CurrentDispatcher; this.Log("Setting SynchronizationContext"); SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(this.uiThreadDispatcher)); this.guiService = new GuiService(this, this.uiThreadDispatcher); this.uacService = new UacService(); this.Log("Initializing view model for main application window"); this.wizardWindowVM = new WizardWindowVM(this, this.guiService, this.uacService); this.Log("Initializing main application window"); this.wizardWindow = new WizardWindow() { DataContext = this.wizardWindowVM }; this.wizardWindow.Closed += (a, b) => this.uiThreadDispatcher.InvokeShutdown(); this.Log("Showing main application window"); this.wizardWindow.Show(); this.Log("Running Dispatcher"); Dispatcher.Run(); } this.Engine.Quit((int)this.ExitAction); } catch (Exception ex) { this.Log("An error occured while executing the Bootstrapper Application!" + Environment.NewLine + ex.ToString()); this.Engine.Quit((int)ActionResult.Failure); } }