private void buttonExtCAPI_Click(object sender, EventArgs e) { if (buttonExtCAPI.Text == "Login") { try { capi.LoginAs(textBoxBorderCmdr.Text, textBoxBorderCompanionLogin.Text.Trim(), textBoxBorderCompanionPassword.Text.Trim()); } catch (Exception ex) { ExtendedControls.MessageBoxTheme.Show(this, "Failed to login to Frontier Companion API:" + Environment.NewLine + ex.Message, "Companion API Login", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (buttonExtCAPI.Text == "Clear") { if (ExtendedControls.MessageBoxTheme.Show(this, "Confirm you wish to delete the credentials stored for this commander", "Companion API Clear Credentials", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { capi.Logout(); CompanionCredentials.DeleteCredentials(textBoxBorderCmdr.Text); } } else { try { capi.Confirm(textBoxBorderCompanionLogin.Text.Trim()); } catch (Exception ex) { ExtendedControls.MessageBoxTheme.Show(this, "Confirm Failed:" + Environment.NewLine + ex.Message, "Companion API Login", MessageBoxButtons.OK, MessageBoxIcon.Error); } } UpdateCAPIState(); }
void UpdateCAPIState() { buttonExtCAPI.Text = "Login".Tx(this); // default state.. information needed. labelCAPIState.Text = "No Credentials".Tx(this); labelCAPILogin.Text = "Login ID:".Tx(this); textBoxBorderCompanionLogin.Visible = textBoxBorderCompanionPassword.Visible = labelCAPILogin.Visible = labelCAPIPassword.Visible = true; toolTip.SetToolTip(textBoxBorderCompanionLogin, "Enter your Frontier ID, which is the email you registered with Frontier. Does not work for Steam installs".Tx(this, "TTCAPI")); buttonExtCAPI.Enabled = false; checkBoxCAPIEnable.Visible = false; if (textBoxBorderCmdr.Text.Length > 0) { bool isdisabled; CompanionCredentials.State s = CompanionCredentials.CredentialState(textBoxBorderCmdr.Text, out isdisabled); if (s == CompanionCredentials.State.CONFIRMED) { labelCAPIState.Text = "Confirmed Credentials".Tx(this, "CC"); textBoxBorderCompanionLogin.Visible = labelCAPILogin.Visible = textBoxBorderCompanionPassword.Visible = labelCAPIPassword.Visible = false; textBoxBorderCompanionLogin.Text = textBoxBorderCompanionPassword.Text = ""; buttonExtCAPI.Text = "Clear".Tx(this); buttonExtCAPI.Enabled = true; checkBoxCAPIEnable.Location = labelCAPILogin.Location; checkBoxCAPIEnable.Visible = true; checkBoxCAPIEnable.Checked = !isdisabled; } else if (s == CompanionCredentials.State.NEEDS_CONFIRMATION) { labelCAPIState.Text = "Require Confirmation".Tx(this, "RC"); labelCAPILogin.Text = "Confirm Code:".Tx(this, "CFC"); textBoxBorderCompanionPassword.Visible = labelCAPIPassword.Visible = false; textBoxBorderCompanionLogin.Text = textBoxBorderCompanionPassword.Text = ""; buttonExtCAPI.Text = "Clear".Tx(this); // default state is clear/abort buttonExtCAPI.Enabled = true; toolTip.SetToolTip(textBoxBorderCompanionLogin, "Enter the confirmation code you just received via email from Frontier".Tx(this, "ConfirmCode")); if (capi.NeedLogin) { try { capi.LoginAs(textBoxBorderCmdr.Text); } catch (Exception ex) { ExtendedControls.MessageBoxTheme.Show(this, string.Format(("Login Failed: " + Environment.NewLine + "{0}").Tx(this, "LIF"), ex.Message), "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
public FormCAPI() { InitializeComponent(); buttonStoredLogin.Enabled = false; if (CompanionCredentials.CredentialState(EDCommander.Current.Name) == CompanionCredentials.State.NEEDS_CONFIRMATION) { setUpConfirm(); } else if (CompanionCredentials.CredentialState(EDCommander.Current.Name) == CompanionCredentials.State.CONFIRMED) { setUpLoggedIn("Credentials ready"); buttonStoredLogin.Enabled = true; buttonLogin.Enabled = false; } }
void UpdateCAPIState() { buttonExtCAPI.Text = "Login"; // default state.. information needed. labelCAPIState.Text = "No Credentials"; labelCAPILogin.Text = "Login ID:"; textBoxBorderCompanionLogin.Visible = textBoxBorderCompanionPassword.Visible = labelCAPILogin.Visible = labelCAPIPassword.Visible = true; toolTip1.SetToolTip(textBoxBorderCompanionLogin, "Enter you Frontier ID, which is the email you registered with Frontier. Does not work for Steam installs"); buttonExtCAPI.Enabled = false; if (textBoxBorderCmdr.Text.Length > 0) { CompanionCredentials.State s = CompanionCredentials.CredentialState(textBoxBorderCmdr.Text); if (s == CompanionCredentials.State.CONFIRMED) { labelCAPIState.Text = "Confirmed Credentials"; textBoxBorderCompanionLogin.Visible = labelCAPILogin.Visible = textBoxBorderCompanionPassword.Visible = labelCAPIPassword.Visible = false; textBoxBorderCompanionLogin.Text = textBoxBorderCompanionPassword.Text = ""; buttonExtCAPI.Text = "Clear"; buttonExtCAPI.Enabled = true; } else if (s == CompanionCredentials.State.NEEDS_CONFIRMATION) { labelCAPIState.Text = "Require Confirmation"; labelCAPILogin.Text = "Confirm Code:"; textBoxBorderCompanionPassword.Visible = labelCAPIPassword.Visible = false; textBoxBorderCompanionLogin.Text = textBoxBorderCompanionPassword.Text = ""; buttonExtCAPI.Text = "Clear"; // default state is clear/abort buttonExtCAPI.Enabled = true; toolTip1.SetToolTip(textBoxBorderCompanionLogin, "Enter the confirmation code you just received via email from Frontier"); if (capi.NeedLogin) { try { capi.LoginAs(textBoxBorderCmdr.Text); } catch (Exception ex) { ExtendedControls.MessageBoxTheme.Show(this, "Login Failed:" + Environment.NewLine + ex.Message, "Companion API Login", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void checkBoxCAPIEnable_CheckedChanged(object sender, EventArgs e) { CompanionCredentials.SetDisabled(textBoxBorderCmdr.Text, !checkBoxCAPIEnable.Checked); // rewrites the file with the disabled state }
private void button1_Click(object sender, EventArgs e) { CompanionCredentials.DeleteCredentials(EDCommander.Current.Name); capi.Logout(); }