private void BindParentWndProcHook() { if (_parentWinFormsWndProcHook != null) { return; } WithForm(delegate(Form form) { _parentWinFormsWndProcHook = new WndProcHook(form); _parentWinFormsWndProcHook.WndProcMessage += ParentFormOnWndProcMessage; }); }
private void OptionsForm_Closed(object sender, Tools.OptionsFormsEventArgs e) { if (e.form.DialogResult != DialogResult.OK) { return; } bool shown; Options options = (Options)Tools.GetPluginFromOptions(this, out shown); if (!shown) { return; } bool bPWEnter = options.cbPWHotkey.SelectedIndex == 1; if (Config.PWEnter && (bPWEnter != Config.PWEnter)) { WndProcHook.RemoveHandler(m_host.MainWindow); } Config.PWEnter = bPWEnter; if (Config.PWEnter) { WndProcHook.AddHandler(m_host.MainWindow, WndProcHandler); } HotkeysDeactivate(); Config.AATHotkey = options.AATHotkey; Config.PWOnlyHotkey = options.PWOnlyHotkey; Config.UsernameOnlyHotkey = options.UsernameOnlyHotkey; Config.UsernameOnlyEnter = options.UsernameOnlyEnter; Config.ColumnsSortable = options.cbColumnsSortable.Checked; Config.ColumnsRememberSorting = options.cbColumnsRememberSort.Checked; Config.AddDBColumn = options.cbDBColumn.Checked; Config.SpecialColumns = options.cbSpecialColumns.Checked; Config.SpecialColumnsRespectPWEnter = options.cbSpecialColumnsRespectPWEnter.Checked; Config.KeepATOpen = options.cbKeepATOpen.Checked; Config.ExcludeExpiredGroups = options.cbExcludeExpiredGroups.Checked; Config.SearchAsYouType = options.cbSearchAsYouType.Checked; if ((Config.AATHotkey != Keys.None) || (Config.PWOnlyHotkey != Keys.None) || (Config.UsernameOnlyHotkey != Keys.None)) { HotkeysActivate(); } }
public override bool Initialize(IPluginHost host) { Terminate(); m_host = host; PluginTranslate.Init(this, KeePass.Program.Translation.Properties.Iso6391Code); Tools.DefaultCaption = PluginTranslate.PluginName; Tools.PluginURL = "https://github.com/rookiestyle/alternateautotype/"; SprEngine.FilterPlaceholderHints.Add(Config.Placeholder); AutoType.FilterCompilePre += AutoType_FilterCompilePre; HotkeysActivate(); ToolStripItemCollection tsMenu = m_host.MainWindow.ToolsMenu.DropDownItems; m_menuItem = new ToolStripMenuItem(); m_menuItem.Image = SmallIcon; m_menuItem.Text = PluginTranslate.PluginName + "..."; m_menuItem.Click += (o, e) => Tools.ShowOptions(); tsMenu.Add(m_menuItem); GlobalWindowManager.WindowAdded += OnWindowAdded; GlobalWindowManager.WindowRemoved += OnWindowRemoved; Tools.OptionsFormShown += OptionsFormShown; Tools.OptionsFormClosed += OptionsForm_Closed; if (Config.PWEnter) { WndProcHook.AddHandler(m_host.MainWindow, WndProcHandler); } m_miProcessItemSelection = typeof(AutoTypeCtxForm).GetMethod("ProcessItemSelection", BindingFlags.NonPublic | BindingFlags.Instance); m_aww = new AutotypeWindowWatcher(SmallIcon); m_aww.Enable(); return(true); }
/// <summary> /// Initializes the <see href="BDHeroGUI.Components.DiscMenu"/> for use. /// </summary> /// <param name="form"> /// Windows Forms control (typically a <see href="Form"/>) to listen for <see href="Form.WndProc"/> events on. /// </param> /// <param name="detector"> /// Drive detector. /// </param> /// <exception cref="InvalidOperationException">Thrown if this method is called more than once.</exception> public void Initialize(Form form, IDriveDetector detector) { if (_isInitialized) { throw new InvalidOperationException("DiscMenu has already been initialized"); } var hook = new WndProcHook(form); hook.WndProcMessage += WndProc; _detector = detector; _detector.DeviceArrived += OnDeviceArrived; _detector.DeviceRemoved += OnDeviceRemoved; DropDownOpened += OnDropDownOpened; DropDownClosed += OnDropDownClosed; Refresh(); _isInitialized = true; }
public override void Terminate() { if (m_host == null) { return; } m_aww.Disable(); WndProcHook.RemoveHandler(m_host.MainWindow); HotkeysDeactivate(); SprEngine.FilterPlaceholderHints.Remove(Config.Placeholder); AutoType.FilterCompilePre -= this.AutoType_FilterCompilePre; m_host.MainWindow.ToolsMenu.DropDownItems.Remove(m_menuItem); Tools.OptionsFormShown -= OptionsFormShown; Tools.OptionsFormClosed -= ConfigWrite; GlobalWindowManager.WindowAdded -= OnWindowAdded; GlobalWindowManager.WindowRemoved -= OnWindowRemoved; PluginDebug.SaveOrShow(); m_host = null; }
public void SetUpFixture() { _form = new WndProcHookTestForm(); _hook = new WndProcHook(_form); }