private void SetupTOTP_Load(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); Text = Localization.Strings.Setup + " - " + Localization.Strings.TrayTOTPPlugin; //Set form's name using constants. if (_plugin.TOTPEntryValidator.HasSeed(_entry)) //Checks the the totp settings exists. { string[] settings = _plugin.TOTPEntryValidator.SettingsGet(_entry); //Gets the the existing totp settings. bool validInterval; bool validLength; bool validUrl; _plugin.TOTPEntryValidator.SettingsValidate(_entry, out validInterval, out validLength, out validUrl); //Validates the settings value. if (validInterval) { NumericIntervalSetup.Value = Convert.ToDecimal(settings[0]); //Checks if interval is valid and sets interval numeric to the setting value. } if (validLength) //Checks if length is valid. { // Select the correct radio button RadioButtonLength6Setup.Checked = settings[1] == "6"; RadioButtonLength7Setup.Checked = settings[1] == "7"; RadioButtonLength8Setup.Checked = settings[1] == "8"; RadioButtonSteamFormatSetup.Checked = settings[1] == "S"; } if (validUrl) { ComboBoxTimeCorrectionSetup.Text = settings[2]; //Checks if url is valid and sets time correction textbox to the setting value. } DeleteSetupButton.Visible = true; //Shows the back button. HelpProviderSetup.SetHelpString(DeleteSetupButton, Localization.Strings.SetupDelete); } else { DeleteSetupButton.Visible = false; //Hides the back button. } if (_plugin.TOTPEntryValidator.HasSeed(_entry)) { TextBoxSeedSetup.Text = _plugin.TOTPEntryValidator.SeedGet(_entry).ReadString(); //Checks if the seed exists and sets seed textbox to the seed value. } ComboBoxTimeCorrectionSetup.Items.AddRange(_plugin.TimeCorrections.ToComboBox()); //Gets existings time corrections and adds them in the combobox. HelpProviderSetup.SetHelpString(FinishSetupButton, Localization.Strings.SetupFinish); ErrorProviderSetup.SetError(TextBoxSeedSetup, string.Empty); ErrorProviderSetup.SetError(NumericIntervalSetup, string.Empty); ErrorProviderSetup.SetError(RadioButtonLength8Setup, string.Empty); ErrorProviderSetup.SetError(ComboBoxTimeCorrectionSetup, string.Empty); }
private void SetupTOTP_Load(object sender, EventArgs e) { Text = TrayTOTP_Plugin_Localization.strSetup + TrayTOTP_Plugin_Localization.strSpaceDashSpace + TrayTOTP_Plugin_Localization.strTrayTOTPPlugin; //Set form's name using constants. if (_plugin.SettingsCheck(entry) || _plugin.SeedCheck(entry)) //Checks the the totp settings exists. { string[] Settings = _plugin.SettingsGet(entry); //Gets the the existing totp settings. bool ValidInterval = false; bool ValidLength = false; bool ValidUrl = false; _plugin.SettingsValidate(entry, out ValidInterval, out ValidLength, out ValidUrl); //Validates the settings value. if (ValidInterval) { NumericIntervalSetup.Value = Convert.ToDecimal(Settings[0]); //Checks if interval is valid and sets interval numeric to the setting value. } if (ValidLength) //Checks if length is valid. { RadioButtonLength6Setup.Checked = Settings[1] == "6"; //Sets length radio 6 to checked if the setting value is 6. RadioButtonLength8Setup.Checked = Settings[1] == "8"; //Sets length radio 8 to checked if the setting value is 8. RadioButtonSteamFormatSetup.Checked = Settings[1] == "S"; //Sets format Steam to checked if the setting value is S. } if (ValidUrl) { ComboBoxTimeCorrectionSetup.Text = Settings[2]; //Checks if url is valid and sets time correction textbox to the setting value. } DeleteSetupButton.Visible = true; //Shows the back button. HelpProviderSetup.SetHelpString(DeleteSetupButton, SetupTOTP_Localization.SetupDelete); } else { DeleteSetupButton.Visible = false; //Hides the back button. } if (_plugin.SeedCheck(entry)) { TextBoxSeedSetup.Text = _plugin.SeedGet(entry).ReadString(); //Checks if the seed exists and sets seed textbox to the seed value. } ComboBoxTimeCorrectionSetup.Items.AddRange(_plugin.TimeCorrections.ToComboBox()); //Gets existings time corrections and adds them in the combobox. HelpProviderSetup.SetHelpString(FinishSetupButton, SetupTOTP_Localization.SetupFinnish); ErrorProviderSetup.SetError(TextBoxSeedSetup, string.Empty); ErrorProviderSetup.SetError(NumericIntervalSetup, string.Empty); ErrorProviderSetup.SetError(RadioButtonLength8Setup, string.Empty); ErrorProviderSetup.SetError(ComboBoxTimeCorrectionSetup, string.Empty); }