public override void ProcessInput(object input, out State newState) { if (input.Equals(PrivateInput.GoToUpdateAvailable)) { newState = new UpdateAvailableState(this.manifest.VersionInfos[this.latestVersionIndex]); } else if (input.Equals(PrivateInput.GoToError)) { string errorMessage; if (this.exception is WebException) { errorMessage = Utility.WebExceptionToErrorMessage((WebException)this.exception); } else { errorMessage = PdnResources.GetString("Updates.CheckingState.GenericError"); } newState = new ErrorState(this.exception, errorMessage); } else if (input.Equals(PrivateInput.GoToDone)) { newState = new DoneState(); } else if (input.Equals(PrivateInput.GoToAborted)) { newState = new AbortedState(); } else { throw new ArgumentException(); } }
public override void ProcessInput(object input, out State newState) { if (input.Equals(PrivateInput.GoToUpdateAvailable)) { newState = new UpdateAvailableState(this.manifest.VersionInfos[this.latestVersionIndex]); } else if (input.Equals(PrivateInput.GoToError)) { string errorMessage; if (this.exception is WebException) { errorMessage = Utility.WebExceptionToErrorMessage((WebException)this.exception); } else { errorMessage = PdnResources.GetString("Updates.CheckingState.GenericError"); } newState = new ErrorState(this.exception, errorMessage); } else if (input.Equals(PrivateInput.GoToDone)) { newState = new DoneState(); } else if (input.Equals(PrivateInput.GoToAborted)) { newState = new AbortedState(); } else { throw new ArgumentException(); } }
private void ShowUpdatesDialog(bool calledFromExit) { if (!calledFromExit) { if (this.installOnExit && ShellUtil.IsActivityQueuedForRestart) { ShellUtil.IsActivityQueuedForRestart = false; } this.installOnExit = false; } IUpdatesMainFormSite site = this.host.FindMainForm(); if (site != null) { site.FormClosing -= new FormClosingEventHandler(this.OnMainFormFormClosing); } if (this.retryDialogTimer != null) { this.retryDialogTimer.Enabled = false; this.retryDialogTimer.Dispose(); this.retryDialogTimer = null; } bool flag = true; UpdateAvailableState currentState = this.stateMachineExecutor.CurrentState as UpdateAvailableState; if (currentState != null) { PdnVersionInfo newVersionInfo = currentState.NewVersionInfo; string friendlyName = newVersionInfo.FriendlyName; string infoUrl = newVersionInfo.InfoUrl; switch (this.AskInstallNowOrOnExit(this.host.UISite.Win32Window, friendlyName, infoUrl)) { case DialogResult.Yes: this.stateMachineExecutor.ProcessInput(UpdatesAction.Continue); flag = true; goto Label_0134; case DialogResult.OK: { this.stateMachineExecutor.ProcessInput(UpdatesAction.Continue); flag = false; this.installOnExit = true; ShellUtil.IsActivityQueuedForRestart = true; IUpdatesMainFormSite site2 = this.host.FindMainForm(); if (site2 != null) { site2.FormClosing += new FormClosingEventHandler(this.OnMainFormFormClosing); } else { flag = true; } goto Label_0134; } } this.stateMachineExecutor.ProcessInput(UpdatesAction.Cancel); flag = false; this.DisposeUpdates(); } Label_0134: if (flag) { IWin32Window window; if (this.updatesDialog != null) { this.updatesDialog.Close(); this.updatesDialog = null; } this.updatesDialog = new UpdatesDialog(); this.updatesDialog.InstallingOnExit = calledFromExit; this.updatesDialog.UpdatesStateMachine = this.stateMachineExecutor; if (!this.stateMachineExecutor.IsStarted) { this.stateMachineExecutor.Start(); } try { IntPtr handle = this.host.UISite.Win32Window.Handle; window = this.host.UISite.Win32Window; } catch (Exception) { window = null; } this.updatesDialog.StartPosition = calledFromExit ? FormStartPosition.CenterScreen : this.updatesDialog.StartPosition; this.updatesDialog.ShowInTaskbar = calledFromExit; this.updatesDialog.Shown += (s, e) => UIUtil.FlashForm(this.updatesDialog); this.updatesDialog.ShowDialog(window); DialogResult dialogResult = this.updatesDialog.DialogResult; this.updatesDialog.Dispose(); this.updatesDialog = null; if (((this.stateMachineExecutor != null) && (dialogResult == DialogResult.Yes)) && (this.stateMachineExecutor.CurrentState is ReadyToInstallState)) { this.stateMachineExecutor.ProcessInput(UpdatesAction.Continue); while (!this.calledFinish) { Application.DoEvents(); Thread.Sleep(10); } } } }