private QuickSearchControl addQuickSearchControl(IPluginHost host) { QuickSearchControl myControl = new QuickSearchControl(); //myControl.Enabled = false; ToolStripControlHost myToolStripControlHost = new ToolStripControlHost(myControl); myToolStripControlHost.AutoSize = true; Control.ControlCollection mainWindowControls = host.MainWindow.Controls; CustomToolStripEx toolStrip = (CustomToolStripEx)mainWindowControls["m_toolMain"]; toolStrip.Items.Add(myToolStripControlHost); //host.MainWindow.FileOpened += new EventHandler<FileOpenedEventArgs>(MainWindow_FileOpened); var mainForm = host.MainWindow; mainForm.KeyPreview = true; mainForm.KeyDown += (sender, args) => { if (args.KeyData == (Keys.Shift | Keys.Control | Keys.F)) { myControl.comboBoxSearch.Focus(); } }; //host.MainWindow.Shown += delegate(object o, EventArgs e) { myControl.ParentForm.ActiveControl = myControl.comboBoxSearch; }; //myControl.comboBox.TextChanged += new EventHandler(comboBox1_TextChanged); return(myControl); }
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); }
/// <summary> /// Removes the builtin "QuickFind" ComboBox /// </summary> /// <param name="host"></param> private static void removeBuiltinQuickFind(IPluginHost host) { Control.ControlCollection mainWindowControls = host.MainWindow.Controls; CustomToolStripEx toolStrip = (CustomToolStripEx)mainWindowControls["m_toolMain"]; ToolStripItem comboBox = toolStrip.Items["m_tbQuickFind"]; //Debug.Assert(comboBox != null); if (comboBox != null) { comboBox.Visible = false; //toolStrip.Items.Remove(comboBox); comboBox.Enabled = false; } }
//void MainWindow_FileOpened(object sender, FileOpenedEventArgs e) //{ // myControl.ParentForm.ActiveControl = myControl.comboBoxSearch; }; //} //static void comboBox1_TextChanged(object sender, EventArgs e) //{ // foreach (PwEntry entry in host.Database.RootGroup.Entries) // { // foreach (KeyValuePair<string,ProtectedString> kv in entry.Strings) // { // if (kv.Value.ReadString().Contains("uiedriaenn234aai")) // { // System.Diagnostics.Debug.WriteLine("gefunden"); // } // } // } //} void updateQuickFindControl() { Control.ControlCollection mainWindowControls = host.MainWindow.Controls; CustomToolStripEx toolStrip = (CustomToolStripEx)mainWindowControls["m_toolMain"]; ToolStripItem comboBox = toolStrip.Items["m_tbQuickFind"]; Binding binding = new Binding("Visible", Settings.Default, "ShowQuickFind"); ((ToolStripComboBox)comboBox).ComboBox.DataBindings.Add(binding); //if (Settings.Default.HideQuickFind) //{ // comboBox.Visible = false; //} //else //{ // comboBox.Visible = true; //} }
public override bool Initialize(IPluginHost host) { if (host == null) { return(false); } mfMainForm = host.MainWindow; mfMainForm.FileOpened += MainForm_FileOpened; //menu tool strip ToolStripMenuItem tsmiMenuToolStripEdit = (ToolStripMenuItem)mfMainForm.MainMenu.Items["m_menuEntry"]; //tool strip CustomToolStripEx tsmiToolStripEdit = (CustomToolStripEx)mfMainForm.Controls["m_toolMain"]; //item context menu Control[] lvEntries = mfMainForm.Controls.Find("m_lvEntries", true); //new window event GlobalWindowManager.WindowAdded += OnWindowAdded; //create menu item tsmiAddOpenIdEntry = new ToolStripMenuItem { Text = csAddOpenIdEntry, Image = new Bitmap(aKeePassOpenIdExtAssembly.GetManifestResourceStream("KeePassOpenId.Resources.New.png")), }; tsmiAddOpenIdEntry.Click += new EventHandler(OnEntryAdd); //add in our menu item to the menu tool strip if (tsmiMenuToolStripEdit != null) { //find the regular "Add Entry" item so we can put ours right after it for (int i = 0; i < tsmiMenuToolStripEdit.DropDownItems.Count; i++) { if (tsmiMenuToolStripEdit.DropDownItems[i] is ToolStripMenuItem) { //if (((ToolStripMenuItem)item).Name == "m_ctxEntryAdd") if (((ToolStripMenuItem)tsmiMenuToolStripEdit.DropDownItems[i]).Text == "&Add Entry...") { tsmiMenuToolStripEdit.DropDownItems.Insert(i + 1, tsmiAddOpenIdEntry); break; } } } } //add in our menu item to the tool strip if (tsmiToolStripEdit != null) { //find the regular "Add Entry" item so we can put ours right after it for (int i = 0; i < tsmiToolStripEdit.Items.Count; i++) { if (tsmiToolStripEdit.Items[i] is ToolStripSplitButton) { if (((ToolStripSplitButton)tsmiToolStripEdit.Items[i]).Name == "m_tbAddEntry") { ToolStripMenuItem tsmiAddOpenId = new ToolStripMenuItem { Text = csAddOpenIdEntry, Image = new Bitmap(aKeePassOpenIdExtAssembly.GetManifestResourceStream("KeePassOpenId.Resources.New.png")), }; tsmiAddOpenId.Click += new EventHandler(OnEntryAdd); ((ToolStripSplitButton)tsmiToolStripEdit.Items[i]).DropDownItems.Add(tsmiAddOpenId); break; } } } } //add in our menu item to the context menu if (lvEntries != null && lvEntries.Length == 1) { CustomContextMenuStripEx ccmsItemContextMenu = (CustomContextMenuStripEx)((CustomListViewEx)lvEntries[0]).ContextMenuStrip; //find the regular "Add Entry" item so we can put ours right after it for (int i = 0; i < ccmsItemContextMenu.Items.Count; i++) { if (ccmsItemContextMenu.Items[i] is ToolStripMenuItem) { if (((ToolStripMenuItem)ccmsItemContextMenu.Items[i]).Name == "m_ctxEntryAdd") { ToolStripMenuItem tsmiAddOpenId = new ToolStripMenuItem { Text = csAddOpenIdEntry, Image = new Bitmap(aKeePassOpenIdExtAssembly.GetManifestResourceStream("KeePassOpenId.Resources.New.png")), }; tsmiAddOpenId.Click += new EventHandler(OnEntryAdd); ccmsItemContextMenu.Items.Insert(i + 1, tsmiAddOpenId); ((ToolStripMenuItem)ccmsItemContextMenu.Items[i]).EnabledChanged += KeePassOpenIdExt_EnabledChanged; break; } } } } return(true); }