private void ButtonDownload_Click(object sender, EventArgs e) { switch (CurrentState) { case State.Idle: CurrentState = State.RTPatch; _nextState = NextState.Download; RTPatcher.Run(ComboBoxLanguages.SelectedItem as Language); break; case State.Download: ButtonDownload.Text = StringLoader.GetText("button_cancelling"); Downloader.Cancel(); break; case State.Patch: ButtonDownload.Text = StringLoader.GetText("button_cancelling"); Patcher.Cancel(); break; case State.RTPatch: ButtonDownload.Text = StringLoader.GetText("button_cancelling"); RTPatcher.Cancel(); break; } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason.In(CloseReason.ApplicationExitCall, CloseReason.WindowsShutDown)) { Logger.Info($"{Text} closing abnormally. Reason=[{e.CloseReason.ToString()}]"); CurrentState = State.Idle; RTPatcher.Cancel(); Downloader.Cancel(); Patcher.Cancel(); GameStarter.Cancel(); } else if (!CurrentState.In(State.Idle, State.RegionNotInstalled)) { MsgBox.Error(StringLoader.GetText("exception_cannot_close", AssemblyAccessor.Title)); e.Cancel = true; } else { Logger.Info($"{Text} closing. Reason=[{e.CloseReason.ToString()}]"); } }