コード例 #1
0
        /// <summary>
        /// Key has been pressed down.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="e">A KeyEventArgs that contains the event data.</param>
        public virtual void KeyDown(Control c, KeyEventArgs e)
        {
            Debug.Assert(c != null);
            Debug.Assert(e != null);

            // Validate incoming references
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
            case Keys.Space:
                if (_layout.ItemEnabled)
                {
                    Point pt = new Point(int.MaxValue, int.MaxValue);
                    OnClick(new MouseEventArgs(MouseButtons.Left, 1, pt.X, pt.Y, 0));
                    UpdateTargetState(pt);
                }
                break;

            case Keys.Tab:
                _viewManager.KeyTab(e.Shift);
                break;

            case Keys.Home:
                _viewManager.KeyHome();
                break;

            case Keys.End:
                _viewManager.KeyEnd();
                break;

            case Keys.Up:
                _viewManager.KeyUp();
                break;

            case Keys.Down:
                _viewManager.KeyDown();
                break;

            case Keys.Left:
                _viewManager.KeyLeft(true);
                break;

            case Keys.Right:
                _viewManager.KeyRight();
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Key has been pressed down.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="e">A KeyEventArgs that contains the event data.</param>
        public virtual void KeyDown(Control c, KeyEventArgs e)
        {
            Debug.Assert(c != null);
            Debug.Assert(e != null);

            // Validate incoming references
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
            case Keys.Space:
                // Only interested in enabled items
                if (_menuColorBlock.ItemEnabled)
                {
                    PressColorBlock();
                }
                break;

            case Keys.Tab:
                _viewManager.KeyTab(e.Shift);
                break;

            case Keys.Home:
                _viewManager.KeyHome();
                break;

            case Keys.End:
                _viewManager.KeyEnd();
                break;

            case Keys.Up:
                _viewManager.KeyUp();
                break;

            case Keys.Down:
                _viewManager.KeyDown();
                break;

            case Keys.Left:
                _viewManager.KeyLeft(true);
                break;

            case Keys.Right:
                _viewManager.KeyRight();
                break;
            }
        }
コード例 #3
0
        /// <summary>
        /// Key has been pressed down.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="e">A KeyEventArgs that contains the event data.</param>
        public virtual void KeyDown(Control c, KeyEventArgs e)
        {
            Debug.Assert(c != null);
            Debug.Assert(e != null);

            // Validate incoming references
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            switch (e.KeyCode)
            {
            case Keys.Tab:
                _viewManager.KeyTab(e.Shift);
                break;

            case Keys.Home:
                _viewManager.KeyHome();
                break;

            case Keys.End:
                _viewManager.KeyEnd();
                break;

            case Keys.Up:
                _viewManager.KeyUp();
                break;

            case Keys.Down:
                _viewManager.KeyDown();
                break;

            case Keys.Left:
                _viewManager.KeyLeft(false);
                break;

            case Keys.Right:
                _viewManager.KeyRight();
                break;
            }
        }
コード例 #4
0
        /// <summary>
        /// Key has been pressed down.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="e">A KeyEventArgs that contains the event data.</param>
        public virtual void KeyDown(Control c, KeyEventArgs e)
        {
            Debug.Assert(c != null);
            Debug.Assert(e != null);

            // Validate incoming references
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            switch (e.KeyCode)
            {
            case Keys.Enter:
            case Keys.Space:
                // Only interested in enabled items
                if (_menuItem.ItemEnabled)
                {
                    // Do we press the item or show the sub menu?
                    if (!_menuItem.HasSubMenu)
                    {
                        PressMenuItem();
                    }
                    else
                    {
                        _menuItem.ShowSubMenu(true);
                    }
                }
                break;

            case Keys.Tab:
                _viewManager.KeyTab(e.Shift);
                break;

            case Keys.Home:
                _viewManager.KeyHome();
                break;

            case Keys.End:
                _viewManager.KeyEnd();
                break;

            case Keys.Up:
                _viewManager.KeyUp();
                break;

            case Keys.Down:
                _viewManager.KeyDown();
                break;

            case Keys.Left:
                // We wrap if are the first context menu shown, rather than a sub menu showing
                if (_viewManager.KeyLeft(!_menuItem.HasParentMenu))
                {
                    // User tried to fall off the left edge, so dismiss ourself and let the
                    // keyboard access take us back to the owning context menu instance
                    _menuItem.DisposeContextMenu();
                }
                break;

            case Keys.Right:
                // If enabled and with a sub menu, then show the sub menu
                if (_menuItem.ItemEnabled && _menuItem.HasSubMenu)
                {
                    _menuItem.ShowSubMenu(true);
                }
                else
                {
                    _viewManager.KeyRight();
                }
                break;
            }
        }