public void Run() { var ChHandler = new CharacterHandler(); foreach (var entry in Logs.GetLogEntries()) { entry.Accept(ChHandler); } if (ChHandler.Cmdrs.Count < 1) { // TODO: Play the game a bit return; } else if (ChHandler.Cmdrs.Count == 1) { State.CurrentState.EliteCmdrName = ChHandler.Cmdrs.First(); State.Persist(); return; } Form = new ChooseCmdrForm(); foreach (var cmdr in ChHandler.Cmdrs) { Form.AddCmdr(cmdr); } Form.CommanderChosen += HandleCommanderChosen; Form.ShowDialog(); }
protected void SaveDataAndClose() { // Show post status form to indicate we are doing something var post = new PostForm(); post.Loading = true; post.Load += async(object sender, EventArgs args) => { // If there was an Inara Correction, save that to history first if (inaraCorrection != null) { state.AddHistory(inaraCorrection); } // If there were updates to post to Inara, post them if (!deltas.IsZero) { await api.PostMaterialsSheet(result); // Save to History state.AddHistory(deltas); } // Update Post Timestamp state.UpdateLastPostToCurrent(); // Persist the state state.Persist(); // Update post status form to indicate we are finished post.Loading = false; }; post.ShowDialog(); }
public static void HandleUpgrade() { var old = Filesystem.OldStateFile; if (File.Exists(old)) { PersistentState state = new PersistentState(old); if (!state.HasEliteCmdrName()) { CheapHackController hack = new CheapHackController( new EliteJournalParser(Filesystem.GuessJournalPath()), state); hack.Run(); if (!state.HasEliteCmdrName()) { MessageBox.Show("Picard is exiting without saving."); Application.Exit(); return; } } state.StateFile = Filesystem.GetStatePath( state.CurrentState.EliteCmdrName); state.Persist(); File.Delete(old); MessageBox.Show("Your Picard state file has been upgraded.", "Multi-Commander Support!!"); } }
protected async void OnTryAuthentication(object sender, EventArgs e) { // Disable Inputs and show "logging in" form.SetLoginState(); // Attempt Authentication with InaraAPI if (await api.Authenticate(form.User, form.Pass)) { // Successful; update credentials and close the form state.UpdateInaraCreds( form.User, form.Pass, api.cmdrName); state.Persist(); form.Close(); } else { // Failure; enable inputs and show error form.ErrorLabel = api.lastError; form.SetUserInputState(); } }
/// <summary> /// Handle user-requested close and save /// </summary> /// <param name="sender">Ignored</param> /// <param name="e">e.Cancel can be used to prevent window close</param> protected void OnCloseAndSave(object sender, CancelEventArgs e) { if (InitialMats.IsZero) { // If the data is all zero, that is a little unusual. // Warn the user that it is going to save all zeroes. if (!form.IsUserOKWithNoMats()) { // If they don't click OK, cancel the window close e.Cancel = true; return; } } // Either mats are not empty or the user is OK with it... save! state.AddHistory(InitialMats); // Update Post Timestamp state.UpdateLastPostToCurrent(); // Persist the State state.Persist(); }