public CommandInputForm(ICommandProvider commandProvider, ICommandHistory history) { InitializeComponent(); Width = Screen.PrimaryScreen.Bounds.Width; Font = new Font(Gentium.FontFamily, 30, FontStyle.Regular); DoubleBuffered = true; SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); _commandProvider = commandProvider; _commandHistory = history; _historicCommand = _commandHistory.GetEnumerator(); _backBrush = new SolidBrush(BackColor); _foreBrush = new SolidBrush(Color.FromArgb(255, 10, 40)); _dropDownForm = new DropDownForm(); _dropDownForm.Font = Font; _dropDownForm.Top = Bottom; _mouseHook = new MouseHook(); _mouseHook.MouseMove += new MouseMoveEventHandler(OnMouseMove); _mouseHook.MouseClick += new MouseClickEventHandler(Cancel); _inputTextBox.TextChanged += delegate { OnInputChanged(); }; _inputTextBox.SelectionChanged += delegate { OnInputChanged(); }; MakeForeground(); }
void OnFormClose(object sender, FormClosedEventArgs e) { if (_dropDownForm != null) { _dropDownForm.Close(); _dropDownForm.Dispose(); _dropDownForm = null; } if (_mouseHook != null) { _mouseHook.MouseMove -= new MouseMoveEventHandler(OnMouseMove); _mouseHook.MouseClick -= new MouseClickEventHandler(Cancel); _mouseHook.Dispose(); _mouseHook = null; } }