private void SetLaunchAction(Display gui) { if (launchAction == LaunchAction.Install) // Install { Log($"What have I to do? : {launchAction}"); PlanPackageBegin += SetInstallPackagePlannedState; ApplyComplete += (o, e) => { ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure; MainViewModel.Instance.NavigateFromOffset(1); }; try { BootstrapperDispatcher.Invoke(() => { MainView view = new MainView(); view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown(); view.Show(); }); } catch (Exception ex) { LogExceptionWithInner(ex); } } else if (launchAction == LaunchAction.UpdateReplace) // Update { Log($"What have I to do? : {launchAction}"); PlanPackageBegin += SetUpdatePackagePlannedState; ApplyComplete += (o, e) => { ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure; UninstallViewModel.Instance.NavigateFromOffset(1); }; try { BootstrapperDispatcher.Invoke(() => { UninstallView view = new UninstallView(); view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown(); view.Show(); }); } catch (Exception ex) { LogExceptionWithInner(ex); } } else if (launchAction == LaunchAction.Repair) // Repair { Log($"What have I to do? : {launchAction}"); PlanPackageBegin += SetRepairPackagePlannedState; ApplyComplete += (o, e) => { ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure; UninstallViewModel.Instance.NavigateFromOffset(1); }; try { BootstrapperDispatcher.Invoke(() => { UninstallView view = new UninstallView(); view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown(); view.Show(); }); } catch (Exception ex) { LogExceptionWithInner(ex); } } else if (launchAction == LaunchAction.Uninstall) // Uninstall { Log($"What have I to do? : {launchAction}"); PlanPackageBegin += SetUninstallPackagePlannedState; ApplyComplete += (o, e) => { ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure; if (gui == Display.None || gui == Display.Embedded) { BootstrapperDispatcher.Invoke(() => Engine.Quit((int)ActionResult)); } else { UninstallViewModel.Instance.NavigateFromOffset(1); } }; if (gui == Display.None || gui == Display.Embedded) { Engine.Plan(LaunchAction.Uninstall); Engine.Apply(IntPtr.Zero); } else { try { BootstrapperDispatcher.Invoke(() => { UninstallView view = new UninstallView(); view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown(); view.Show(); }); } catch (Exception ex) { LogExceptionWithInner(ex); } } } }