public override bool Initialize(IPluginHost host) { m_host = host; PluginTranslate.Init(this, KeePass.Program.Translation.Properties.Iso6391Code); Tools.DefaultCaption = PluginTranslate.PluginName; Tools.PluginURL = "https://github.com/rookiestyle/coloredpassword/"; m_menu = new ToolStripMenuItem(Tools.DefaultCaption + "..."); m_menu.Image = SmallIcon; m_menu.Click += (o, e) => Tools.ShowOptions(); m_host.MainWindow.ToolsMenu.DropDownItems.Add(m_menu); Tools.OptionsFormShown += OptionsShown; Tools.OptionsFormClosed += OptionsClosed; ColorConfig.Read(); m_lvEntries = (ListView)Tools.GetControl("m_lvEntries"); if (m_lvEntries != null) { PluginDebug.AddSuccess("m_lvEntries found", 0); m_host.MainWindow.FormLoadPost += MainWindow_FormLoadPost; } else { PluginDebug.AddError("m_lvEntries not found", 0); } ColorPasswords(ColorConfig.Active); GlobalWindowManager.WindowAdded += OnWindowAdded; SinglePwDisplay.Enabled = ColorConfig.SinglePwDisplayActive; return(true); }
//Show error message if TypeOverride is not possible private void OnKeyPromptFormShown(object sender, EventArgs e) { if (OverridePossible || !ColorConfig.FirstRun || !ColorConfig.Active) { return; } (sender as Form).Shown -= OnKeyPromptFormShown; Tools.ShowError(string.Format(PluginTranslate.Error, typeof(SecureTextBoxEx).BaseType.Name)); ColorConfig.FirstRun = false; ColorConfig.Write(); }
private void OptionsClosed(object sender, Tools.OptionsFormsEventArgs e) { ColorConfig.Testmode = false; if (e.form.DialogResult != DialogResult.OK) { return; } bool shown; Options o = (Options)Tools.GetPluginFromOptions(this, out shown); PluginDebug.AddInfo("Plugin options window closed, plugin options shown: " + shown.ToString(), 0); if (!shown) { return; } ColorPasswords(false); ColorConfig.Active = o.cgActive.Checked; ColorConfig.ForeColorDefault = o.bForeColorDefault.BackColor; ColorConfig.BackColorDefault = o.bBackColorDefault.BackColor; ColorConfig.ForeColorDigit = o.bForeColorDigit.BackColor; ColorConfig.BackColorDigit = o.bBackColorDigit.BackColor; ColorConfig.ForeColorSpecial = o.bForeColorSpecial.BackColor; ColorConfig.BackColorSpecial = o.bBackColorSpecial.BackColor; ColorConfig.LowercaseDifferent = o.cbLowercase.Checked; ColorConfig.ForeColorLower = o.bForeColorLower.BackColor; ColorConfig.BackColorLower = o.bBackColorLower.BackColor; ColorConfig.ColorEntryView = o.cbColorEntryView.Checked; ColorConfig.ListViewKeepBackgroundColor = o.cbColorEntryViewKeepBackgroundColor.Checked; ColorConfig.SyncColorsWithPrintForm = o.cbSyncColorsWithPrintForm.Checked; SinglePwDisplay.Enabled = ColorConfig.SinglePwDisplayActive = o.cbSinglePwDisplay.Checked; ColorConfig.ColorPwGen = o.cbColorPwGen.Checked; ColorConfig.Write(); if (ColorConfig.Active) { ColorPasswords(ColorConfig.Active); } }