public async Task <XmlHistory> Command_Patch() { State.Value = LaunchManagerState.IsPatching; var history = new XmlHistory { Success = false }; try { var progObj = new ProgressObject(); using (var logForm = new LogForm(progObj) { Icon = _home.Icon }) { logForm.Show(); try { var patches = GroupPatches(Instructions).ToList(); history.Files = patches.Select(XmlFileHistory.FromInstrGroup).ToList(); _historySerializer.Serialize(history, _pathHistoryXml); await Task.Run(() => ApplyInstructions(patches, progObj)); history.Success = true; } catch (PatchingProcessException ex) { Command_Display_Patching_Error(ex); } if (!history.Success) { PatchingHelper.RestorePatchedFiles(AppInfo, history.Files); } logForm.Close(); } } catch (Exception ex) { Command_Display_Error("Patch the game", ex: ex); } finally { State.Value = LaunchManagerState.Idle; if (Preferences.OpenLogAfterPatch) { Process.Start(_pathLogFile); } } return(history); }
public async Task<XmlHistory> Command_Patch() { State.Value = LaunchManagerState.IsPatching; var history = new XmlHistory { Success = false }; try { var progObj = new ProgressObject(); using (var logForm = new LogForm(progObj) { Icon = _home.Icon }) { logForm.Show(); try { var patches = GroupPatches(Instructions).ToList(); history.Files = patches.Select(XmlFileHistory.FromInstrGroup).ToList(); _historySerializer.Serialize(history, _pathHistoryXml); await Task.Run(() => ApplyInstructions(patches, progObj)); history.Success = true; } catch (PatchingProcessException ex) { Command_Display_Patching_Error(ex); } if (!history.Success) { PatchingHelper.RestorePatchedFiles(AppInfo, history.Files); } logForm.Close(); } } catch (Exception ex) { Command_Display_Error("Patch the game", ex: ex); } finally { State.Value = LaunchManagerState.Idle; if (Preferences.OpenLogAfterPatch) { Process.Start(_pathLogFile); } } return history; }
private static void CloseForm(LogForm logForm) { logForm?.Close(); logForm?.Dispose(); }