Пример #1
0
        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();
        }
Пример #2
0
        void ClearInputHooks()
        {
            _keyboardHook.Dispose();
            _keyboardHook = null;

            _mouseHook.Dispose();
            _mouseHook = null;
        }
Пример #3
0
        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;
            }
        }
Пример #4
0
        void SetInputHooks()
        {
            _keyboardHook = new KeyboardHook();
            _keyboardHook.KeyDown += e => {
                if (!e.IsRepeat)
                    OnInput();
            };

            _mouseHook = new MouseHook();
            _mouseHook.MouseMove += new MouseMoveEventHandler(delegate { OnInput(); });
            _mouseHook.MouseClick += new MouseClickEventHandler(OnInput);
        }