Exemple #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)
            {
                Collapsed = false
            };

            // Create the background that will contain the actual group instance
            _viewBackground = new ViewDrawRibbonGroupsBorder(ribbon, true, NeedPaintDelegate)
            {
                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
            {
                TabStop = false
            };
            _hiddenFocusTarget.Location = new Point(-_hiddenFocusTarget.Width, -_hiddenFocusTarget.Height);
            CommonHelper.AddControlToParent(this, _hiddenFocusTarget);
        }
            /// <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 popGroup)
                {
                    ViewRibbonPopupGroupManager manager = (ViewRibbonPopupGroupManager)popGroup.GetViewManager();
                    focusView = manager.FocusView;
                }
                else if (c is VisualPopupMinimized minimized)
                {
                    ViewRibbonMinimizedManager manager = (ViewRibbonMinimizedManager)minimized.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));
            }