public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry, CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings) { KeePassRPCPlugin = keePassRPCPlugin; _entry = entry; InitializeComponent(); _pwEntryForm = pwEntryForm; _strings = strings; string json = strings.ReadSafe("KPRPC JSON"); if (string.IsNullOrEmpty(json)) { _conf = new EntryConfig(); } else { try { _conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json); } catch (Exception) { MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KeePassRPC JSON config' advanced string. Please ask for help on http://keefox.org/help/forum if you're not sure how to fix this.", "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public override bool Initialize(IPluginHost host) { Terminate(); if (host == null) { return(false); } m_host = host; // Find the main controls m_toolMain = (CustomToolStripEx)Util.FindControlRecursive(m_host.MainWindow, m_ctseName); m_lvEntries = (CustomListViewEx)Util.FindControlRecursive(m_host.MainWindow, m_clveName); // TODO: do we really need this? m_lvEntries.ListViewItemSorter = new CompareByIndex(m_lvEntries); //m_tsmiMenuView = (ToolStripMenuItem)Util.FindControlRecursive(m_host.MainWindow, m_tsmiName); //m_tvGroups = (CustomTreeViewEx)Util.FindControlRecursive(m_host.MainWindow, m_ctveName); //m_csceSplitVertical = (CustomSplitContainerEx)Util.FindControlRecursive(m_host.MainWindow, m_csceName); statusToolbar = new StatusToolbar(); inlineEditing = new InlineEditing(); entryRichEditor = new EntryRichEditor(); return(true); }
public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry, CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings) { KeePassRPCPlugin = keePassRPCPlugin; _entry = entry; InitializeComponent(); _pwEntryForm = pwEntryForm; _strings = strings; _conf = entry.GetKPRPCConfig(strings); }
public KeeEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry, CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings) { KeePassRPCPlugin = keePassRPCPlugin; _entry = entry; InitializeComponent(); _pwEntryForm = pwEntryForm; _strings = strings; _dbConf = KeePassRPCPlugin._host.Database.GetKPRPCConfig(); _conf = entry.GetKPRPCConfig(strings, _dbConf.DefaultMatchAccuracy); }
/// <summary> /// The <c>Initialize</c> function is called by KeePass when /// you should initialize your plugin (create menu items, etc.). /// </summary> /// <param name="host">Plugin host interface. By using this /// interface, you can access the KeePass main window and the /// currently opened database.</param> /// <returns>You must return <c>true</c> in order to signal /// successful initialization. If you return <c>false</c>, /// KeePass unloads your plugin (without calling the /// <c>Terminate</c> function of your plugin).</returns> public override bool Initialize(IPluginHost host) { Debug.Assert(host != null); if (host == null) { return(false); } m_host = host; //m_docMgr = host.MainWindow.DocumentManager; // Get a reference to the 'Tools' menu item container m_tsMenu = m_host.MainWindow.ToolsMenu.DropDownItems; // Add a separator at the bottom ToolStripSeparator tsSeparator = new ToolStripSeparator(); m_tsMenu.Add(tsSeparator); m_tsPopup = new ToolStripMenuItem(); m_tsPopup.Text = "KPEnhancedListview"; //m_tsMenu.ToolTipText = tbToolTip; m_tsMenu.Add(m_tsPopup); // We want a notification when the user tried to save the current database m_host.MainWindow.FileSaved += OnFileSaved; // Find the listview control //m_toolMain = (CustomToolStripEx)Util.FindControlRecursive(m_host.MainWindow, m_ctseName); m_lvEntries = (CustomListViewEx)Util.FindControlRecursive(m_host.MainWindow, m_clveName); //m_tsmiMenuView = (ToolStripMenuItem)Util.FindControlRecursive(m_host.MainWindow, m_tsmiName); //m_tvGroups = (CustomTreeViewEx)Util.FindControlRecursive(m_host.MainWindow, m_ctveName); //m_csceSplitVertical = (CustomSplitContainerEx)Util.FindControlRecursive(m_host.MainWindow, m_csceName); // Initialize Sub Plugins KPELInlineEditing = new KPEnhancedListviewInlineEditing(); KPELAddEntry = new KPEnhancedListviewAddEntry(); KPELOpenDirecotory = new KPEnhancedListviewOpenGroup(); KPELEditableNotes = new KPEnhancedListviewEditableNotes(); // Add About dialog // Add About dialog ToolStripMenuItem m_tbItem = null; m_tbItem = new ToolStripMenuItem(); m_tbItem.Text = "About"; m_tbItem.Image = Properties.Resources.B16x16_Help; m_tbItem.Click += OpenAbout; m_tsPopup.DropDownItems.Add(m_tbItem); return(true); // Initialization successful }
void editEntryFormShown(object sender, EventArgs e) { PwEntryForm form = sender as PwEntryForm; PwEntry entry = null; TabControl mainTabControl = null; CustomListViewEx advancedListView = null; ProtectedStringDictionary strings = null; //This might not work, but might as well use the feature if possible. try { // reflection doesn't seem to be needed for 2.10 and above entry = form.EntryRef; strings = form.EntryStrings; Control[] cs = form.Controls.Find("m_tabMain", true); if (cs.Length == 0) { return; } mainTabControl = cs[0] as TabControl; Control[] cs2 = form.Controls.Find("m_lvStrings", true); if (cs2.Length == 0) { return; } advancedListView = cs2[0] as CustomListViewEx; } catch { // that's life, just move on. return; } if (entry == null) { return; } lock (_lockRPCClientManagers) { //TODO2: Only consider managers of client types that have at least one valid client already authorised foreach (KeePassRPCClientManager manager in _RPCClientManagers.Values) { if (manager.Name != "Null") { manager.AttachToEntryDialog(this, entry, mainTabControl, form, advancedListView, strings); } } } }
void editEntryFormShown(object sender, EventArgs e) { PwEntryForm form = sender as PwEntryForm; PwEntry entry = null; TabControl mainTabControl = null; CustomListViewEx advancedListView = null; ProtectedStringDictionary strings = null; //This might not work, but might as well use the feature if possible. try { // reflection doesn't seem to be needed for 2.10 and above entry = form.EntryRef; strings = form.EntryStrings; Control[] cs = form.Controls.Find("m_tabMain", true); if (cs.Length == 0) { return; } mainTabControl = cs[0] as TabControl; Control[] cs2 = form.Controls.Find("m_lvStrings", true); if (cs2.Length == 0) { return; } advancedListView = cs2[0] as CustomListViewEx; } catch { // that's life, just move on. return; } if (entry == null) { return; } lock (_lockRPCClientManagers) { _lockRPCClientManagers.HeldBy = Thread.CurrentThread.ManagedThreadId; _RPCClientManagers["general"].AttachToEntryDialog(this, entry, mainTabControl, form, advancedListView, strings); } }
/// <summary> /// Show and enable Update button if possible /// Definiton of 'possible': /// - Update button can be added to UpdateCheckForm /// - At least one plugin can be updated /// - At least one updateable plugin is selected /// </summary> /// <param name="form">Reference to UpdateCheckForm</param> /// <param name="enable">True, if Update button shall be enabled</param> /// <returns>True, if successful</returns> private bool ShowUpdateButton(Form form, bool enable) { Button bUpdate = Tools.GetControl("EUCUpdateButton", form) as Button; if (bUpdate == null) { try { Button bClose = Tools.GetControl("m_btnClose", form) as Button; bUpdate = new Button(); bUpdate.Text = PluginTranslate.PluginUpdateSelected; bUpdate.Left = 0; bUpdate.Top = bClose.Top; bUpdate.Height = bClose.Height; bUpdate.AutoSize = true; bUpdate.Name = "EUCUpdateButton"; bUpdate.Click += bUpdatePlugins_Click; bClose.Parent.Controls.Add(bUpdate); if (PluginUpdateHandler.Shieldify) { bUpdate.Width += DpiUtil.ScaleIntX(16); UIUtil.SetShield(bUpdate, true); } bUpdate.Left = bClose.Left - bUpdate.Width - 15; } catch (Exception) { } } bUpdate = Tools.GetControl("EUCUpdateButton", form) as Button; if (bUpdate == null) { foreach (PluginUpdate upd in PluginUpdateHandler.Plugins) { upd.Selected = false; } CustomListViewEx lvPlugins = (CustomListViewEx)Tools.GetControl("m_lvInfo", form); lvPlugins.OwnerDraw = false; return(false); } bUpdate.Enabled = enable; return(true); }
private void lv_Websites_ColumnClick(object sender, ColumnClickEventArgs e) { // arrows for showing sort const string ascArrow = "▲ "; const string descArrow = "▼ "; CustomListViewEx lv = (CustomListViewEx)sender; ListSorter sorter = (ListSorter)lv.ListViewItemSorter; ColumnHeader head = lv.Columns[sorter.Column]; // remove arrow if (head.Text.StartsWith(ascArrow) || head.Text.StartsWith(descArrow)) { head.Text = head.Text.Substring(2, head.Text.Length - 2); } head = lv.Columns[e.Column]; if (sorter.Column == e.Column) { if (sorter.Order == SortOrder.Ascending) { sorter.Order = SortOrder.Descending; head.Text = descArrow + head.Text; } else { sorter.Order = SortOrder.Ascending; head.Text = ascArrow + head.Text; } } else { sorter.Order = SortOrder.Ascending; sorter.Column = e.Column; head.Text = ascArrow + head.Text; } lv.ListViewItemSorter = sorter; lv.Sort(); }
internal static List <Delegate> GetItemActivateHandlers(CustomListViewEx lvPlugins) { List <Delegate> lResult = new List <Delegate>(); FieldInfo fi = GetEventField(EVENTNAME_ItemActivate, tListView); if (fi == null) { return(lResult); } if (fi.IsStatic) //Unix (Mono) { EventHandlerList static_event_handlers = GetStaticEventHandlerList(lvPlugins); object idx = fi.GetValue(lvPlugins); Delegate eh = static_event_handlers[idx]; if (eh != null) { Delegate[] dels = eh.GetInvocationList(); if (dels != null) { lResult.AddRange(dels); } } } else //Windows { EventInfo ei = tListView.GetEvent(EVENTNAME_ItemActivate, AllBindings); //Windows if (ei != null) { object val = fi.GetValue(lvPlugins); Delegate mdel = (val as Delegate); if (mdel != null) { lResult.AddRange(mdel.GetInvocationList()); } } } return(lResult); }
internal static void RemoveItemActivateEventHandlers(CustomListViewEx lvPlugins, List <Delegate> m_lEventHandlerItemActivate) { FieldInfo fi = GetEventField(EVENTNAME_ItemActivate, tListView); if (fi == null) { return; } EventInfo ei = tListView.GetEvent(EVENTNAME_ItemActivate, AllBindings); if (ei == null) { ei = fi.DeclaringType.GetEvent(fi.Name, AllBindings); } if (ei == null) { return; } foreach (Delegate del in m_lEventHandlerItemActivate) { ei.RemoveEventHandler(lvPlugins, del); } }
public override void AttachToEntryDialog(KeePassRPCExt plugin, PwEntry entry, TabControl mainTabControl, PwEntryForm form, CustomListViewEx advancedListView, ProtectedStringDictionary strings) { KeeFoxEntryUserControl entryControl = new KeeFoxEntryUserControl(plugin, entry, advancedListView, form, strings); TabPage keefoxTabPage = new TabPage("KeeFox"); entryControl.Dock = DockStyle.Fill; keefoxTabPage.Controls.Add(entryControl); if (mainTabControl.ImageList == null) { mainTabControl.ImageList = new ImageList(); } int imageIndex = mainTabControl.ImageList.Images.Add(global::KeePassRPC.Properties.Resources.KeeFox16, Color.Transparent); keefoxTabPage.ImageIndex = imageIndex; mainTabControl.TabPages.Add(keefoxTabPage); }
public virtual void AttachToEntryDialog(KeePassRPCExt plugin, PwEntry entry, TabControl mainTabControl, PwEntryForm form, CustomListViewEx advancedListView, ProtectedStringDictionary strings) { return; }
public override void AttachToEntryDialog(KeePassRPCExt plugin, PwEntry entry, TabControl mainTabControl, PwEntryForm form, CustomListViewEx advancedListView, ProtectedStringDictionary strings) { UserControl entryControl; try { string qualifiedName = typeof(KeePass.Util.AutoType).AssemblyQualifiedName .Replace("KeePass.Util.AutoType", "KeePass.Util.MultipleValues.MultipleValuesEx"); System.Type mvType = System.Type.GetType(qualifiedName); PropertyInfo prop = mvType.GetProperty("CueString", BindingFlags.Public | BindingFlags.Static); string mvString = (string)prop.GetValue(null, null); string json = strings.ReadSafe("KPRPC JSON"); if (!string.IsNullOrEmpty(json) && mvString == json) { entryControl = new KeeMultiEntryUserControl(); } else { entryControl = new KeeEntryUserControl(plugin, entry, advancedListView, form, strings); } } catch { // Assume we're running in an older version of KeePass that can't edit multiple entries entryControl = new KeeEntryUserControl(plugin, entry, advancedListView, form, strings); } TabPage keeTabPage = new TabPage("Kee"); entryControl.Dock = DockStyle.Fill; keeTabPage.Controls.Add(entryControl); if (mainTabControl.ImageList == null) { mainTabControl.ImageList = new ImageList(); } int imageIndex = mainTabControl.ImageList.Images.Add(global::KeePassRPC.Properties.Resources.KPRPC64, Color.Transparent); keeTabPage.ImageIndex = imageIndex; mainTabControl.TabPages.Add(keeTabPage); }
private void OnUpdateCheckFormShown(object sender, EventArgs e) { m_lEventHandlerItemActivate = null; PluginDebug.AddSuccess("OUCFS 1", 0); if (!PluginConfig.Active || !PluginConfig.OneClickUpdate) { return; } PluginDebug.AddSuccess("OUCFS 2", 0); CustomListViewEx lvPlugins = (CustomListViewEx)Tools.GetControl("m_lvInfo", sender as UpdateCheckForm); if (lvPlugins == null) { PluginDebug.AddError("m_lvInfo not found", 0); return; } else { PluginDebug.AddSuccess("m_lvInfo found", 0); } PluginUpdateHandler.LoadPlugins(false); if (PluginUpdateHandler.Plugins.Count == 0) { return; } SetPluginSelectionStatus(false); bool bColumnAdded = false; m_lEventHandlerItemActivate = EventHelper.GetItemActivateHandlers(lvPlugins); if (m_lEventHandlerItemActivate.Count > 0) { EventHelper.RemoveItemActivateEventHandlers(lvPlugins, m_lEventHandlerItemActivate); lvPlugins.ItemActivate += LvPlugins_ItemActivate; } //https://github.com/mono/mono/issues/17747 //Do NOT use ListView.SmallImageList if (m_ImgApply == null) { m_ImgApply = (Image)KeePass.Program.Resources.GetObject("B16x16_Apply"); } if (m_ImgUnselected == null) { m_ImgUnselected = m_ImgApply == null ? null : UIUtil.CreateGrayImage(m_ImgApply); } foreach (ListViewItem item in lvPlugins.Items) { PluginDebug.AddInfo("Check plugin update status", 0, item.SubItems[0].Text, item.SubItems[1].Text); if (!item.SubItems[1].Text.Contains(KeePass.Resources.KPRes.NewVersionAvailable)) { continue; } foreach (PluginUpdate upd in PluginUpdateHandler.Plugins) { if (item.SubItems[0].Text != upd.Title) { continue; } if (upd.UpdateMode == UpdateOtherPluginMode.Unknown) { continue; } if (!bColumnAdded) { lvPlugins.Columns.Add(PluginTranslate.PluginUpdate); bColumnAdded = true; } ListViewItem.ListViewSubItem lvsiUpdate = new ListViewItem.ListViewSubItem(item, PluginTranslate.PluginUpdate); lvsiUpdate.Tag = upd; item.SubItems.Add(lvsiUpdate); upd.Selected = true; try { upd.VersionAvailable = new Version(item.SubItems[3].Text); } catch (Exception ex) { PluginDebug.AddError("Could not parse new version", 0, upd.Name, item.SubItems[3].Text, ex.Message); } break; } } if (bColumnAdded) { UIUtil.ResizeColumns(lvPlugins, new int[] { 3, 3, 2, 2, 1 }, true); lvPlugins.MouseClick += OnUpdateCheckFormPluginMouseClick; lvPlugins.OwnerDraw = true; lvPlugins.DrawSubItem += LvPlugins_DrawSubItem; lvPlugins.DrawColumnHeader += LvPlugins_DrawColumnHeader; ShowUpdateButton(sender as Form, true); } if (m_lEventHandlerItemActivate.Count == 0) { if (lvPlugins.ContextMenuStrip == null) { lvPlugins.ContextMenuStrip = new ContextMenuStrip(); string sMenuText = KeePass.Resources.KPRes.PluginsDesc; try { sMenuText = Tools.GetControl("m_linkPlugins", sender as UpdateCheckForm).Text; } catch { } lvPlugins.ContextMenuStrip.Items.Add(new ToolStripMenuItem(sMenuText, null, OnReleasePageClick)); lvPlugins.ContextMenuStrip.Opening += ContextMenuStrip_Opening; } else { PluginDebug.AddWarning("m_lvEntries.ContextMenuStrip already defined, special handling for added 'go to release page' to be defined", 0); } } }
public CompareByIndex(CustomListViewEx listView) { this._listView = listView; }