private void ConfigRoot_Load(object sender, EventArgs e) { var ver = ((System.Reflection.AssemblyFileVersionAttribute) typeof(ConfigRoot).Assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyFileVersionAttribute), true).GetValue(0)).Version; var idx = ver.IndexOf('.', ver.IndexOf('.', ver.IndexOf('.') + 1) + 1); this.lblVersion.Text = "Version " + ver.Substring(0, idx); // Load up the config. Config config; try { config = new Config(this.ConfigForKeePass); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); MessageBox.Show(this, String.Format("Unable to load Readable Passphrase Config.{0}A default configuration will be used instead.{0}{0}{1}{0}{2}", Environment.NewLine, ex.Message, ex.InnerException != null ? ex.InnerException.Message : ""), "Readable Passphrase", MessageBoxButtons.OK, MessageBoxIcon.Error); config = new Config(); } // Load the dictionary so we can display the number of words in the config window. var dict = PassphraseGenerator.LoadDictionary(config); this._Generator.SetDictionary(dict); // "Data Bind" this.ConfigObjectToForm(config); this.lblStatus.Text = ""; }
private void chkCustomDictionary_CheckedChanged(object sender, EventArgs e) { // If true, enable the textbox and browse button. this.btnBrowse.Enabled = this.chkCustomDictionary.Checked; this.txtDictionaryPath.Enabled = this.chkCustomDictionary.Checked; this.lnkDictionaryHelp.Visible = this.chkCustomDictionary.Checked; var conf = this.FormToConfigObject(); if (conf != null) { // TODO: error handling. var dict = PassphraseGenerator.LoadDictionary(conf); this._Generator.SetDictionary(dict); this.UpdateCombinations(conf); this.lblStatus.Text = String.Format("Successfully loaded dictionary '{0}'.", System.IO.Path.GetFileName(this.ofdCustomDictionary.FileName)); } if (this.chkCustomDictionary.Checked && System.IO.File.Exists(this.txtDictionaryPath.Text)) { this.lblStatus.Text = String.Format("Successfully loaded dictionary '{0}'.", System.IO.Path.GetFileName(this.txtDictionaryPath.Text)); } else { this.lblStatus.Text = "Using default dictionary."; } }
public override bool Initialize(IPluginHost host) { if (host == null) { throw new ArgumentNullException("host"); } this._Host = host; this._Generator = new PassphraseGenerator(host); this._Host.PwGeneratorPool.Add(this._Generator); return(true); }
public override void Terminate() { if (this._Host != null) { if (this._Generator != null) { this._Host.PwGeneratorPool.Remove(this._Generator.Uuid); } this._Host = null; } if (this._Generator != null) { this._Generator.Dispose(); this._Generator = null; } }
private void btnBrowse_Click(object sender, EventArgs e) { if (this.ofdCustomDictionary.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { this.txtDictionaryPath.Text = this.ofdCustomDictionary.FileName; var conf = this.FormToConfigObject(); if (conf != null) { // TODO: error handling. var dict = PassphraseGenerator.LoadDictionary(conf); this._Generator.SetDictionary(dict); this.UpdateCombinations(conf); this.lblStatus.Text = String.Format("Successfully loaded dictionary '{0}'.", System.IO.Path.GetFileName(this.ofdCustomDictionary.FileName)); } } }