Пример #1
0
        /// <summary>
        /// Initialize a new instance of the VisualPopupGroup class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonGroup">Reference to ribbon group for display.</param>
        /// <param name="renderer">Drawing renderer.</param>
        public VisualPopupGroup(KryptonRibbon ribbon,
                                KryptonRibbonGroup ribbonGroup,
                                IRenderer renderer)
            : base(renderer, true)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonGroup != null);

            // Remember references needed later
            _ribbon      = ribbon;
            _ribbonGroup = ribbonGroup;

            // Create a view element for drawing the group
            _viewGroup           = new ViewDrawRibbonGroup(ribbon, ribbonGroup, NeedPaintDelegate);
            _viewGroup.Collapsed = false;

            // Create the background that will contain the actual group instance
            _viewBackground = new ViewDrawRibbonGroupsBorder(ribbon, true, NeedPaintDelegate);
            _viewBackground.Add(_viewGroup);

            // Attach the root to the view manager instance
            ViewManager = new ViewRibbonPopupGroupManager(this, ribbon, _viewBackground, _viewGroup, NeedPaintDelegate);

            // Create and add a hidden button to act as the focus target
            _hiddenFocusTarget          = new Button();
            _hiddenFocusTarget.TabStop  = false;
            _hiddenFocusTarget.Location = new Point(-_hiddenFocusTarget.Width, -_hiddenFocusTarget.Height);
            CommonHelper.AddControlToParent(this, _hiddenFocusTarget);
        }
Пример #2
0
            /// <summary>
            /// Processes a dialog key.
            /// </summary>
            /// <param name="keyData">One of the Keys values that represents the key to process.</param>
            /// <returns>True is handled; otherwise false.</returns>
            protected override bool ProcessDialogKey(Keys keyData)
            {
                // Grab the controlling control that is a parent
                Control c = _ribbon.GetControllerControl(this);

                // Grab the view manager handling the focus view
                ViewBase focusView = null;

                if (c is VisualPopupGroup)
                {
                    ViewRibbonPopupGroupManager manager = (ViewRibbonPopupGroupManager)((VisualPopupGroup)c).GetViewManager();
                    focusView = manager.FocusView;
                }
                else if (c is VisualPopupMinimized)
                {
                    ViewRibbonMinimizedManager manager = (ViewRibbonMinimizedManager)((VisualPopupMinimized)c).GetViewManager();
                    focusView = manager.FocusView;
                }

                // When in keyboard mode...
                if (focusView != null)
                {
                    // We pass movements keys onto the view
                    switch (keyData)
                    {
                    case Keys.Tab | Keys.Shift:
                    case Keys.Tab:
                    case Keys.Left:
                    case Keys.Right:
                    case Keys.Up:
                    case Keys.Down:
                    case Keys.Space:
                    case Keys.Enter:
                        _ribbon.KillKeyboardKeyTips();
                        focusView.KeyDown(new KeyEventArgs(keyData));
                        return(true);
                    }
                }

                return(base.ProcessDialogKey(keyData));
            }