Exemple #1
0
        private void OnExtraButtonClick(object sender, EventHandler finishDelegate)
        {
            ViewDrawRibbonQATExtraButton button = (ViewDrawRibbonQATExtraButton)sender;

            // Convert the button rectangle to screen coordinates
            Rectangle screenRect = _ribbon.RectangleToScreen(button.ClientRectangle);

            // If integrated into the caption area
            if ((OwnerForm != null) && !OwnerForm.ApplyComposition)
            {
                // Adjust for the height/width of borders
                Padding borders = OwnerForm.RealWindowBorders;
                screenRect.X -= borders.Left;
                screenRect.Y -= borders.Top;
            }

            if (_extraButton.Overflow)
            {
                _ribbon.DisplayQATOverflowMenu(screenRect, _borderContents, finishDelegate);
            }
            else
            {
                _ribbon.DisplayQATCustomizeMenu(screenRect, _borderContents, finishDelegate);
            }
        }
        private void OnExtraButtonClick(object sender, EventHandler finishDelegate)
        {
            ViewDrawRibbonQATExtraButton button = (ViewDrawRibbonQATExtraButton)sender;

            // Convert the button rectangle to screen coordinates
            Rectangle screenRect = ParentControl.RectangleToScreen(button.ClientRectangle);

            if (_extraButton.Overflow)
            {
                _ribbon.DisplayQATOverflowMenu(screenRect, this, finishDelegate);
            }
            else
            {
                _ribbon.DisplayQATCustomizeMenu(screenRect, this, finishDelegate);
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonQATContents class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon control instance.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        /// <param name="showExtraButton">Should the extra button be shown.</param>
        public ViewLayoutRibbonQATContents(KryptonRibbon ribbon,
                                           NeedPaintHandler needPaint,
                                           bool showExtraButton)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(needPaint != null);

            _ribbon    = ribbon;
            _needPaint = needPaint;

            // Create initial lookup table
            _qatButtonToView = new QATButtonToView();

            // Create the extra button for customization/overflow
            if (showExtraButton)
            {
                _extraButton = new ViewDrawRibbonQATExtraButton(ribbon, needPaint);
                _extraButton.ClickAndFinish += new ClickAndFinishHandler(OnExtraButtonClick);
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Clear();

                foreach (ViewDrawRibbonQATButton view in _qatButtonToView.Values)
                {
                    view.Dispose();
                }

                _qatButtonToView.Clear();

                if (_extraButton != null)
                {
                    _extraButton.ClickAndFinish -= new ClickAndFinishHandler(OnExtraButtonClick);
                    _extraButton = null;
                }
            }

            base.Dispose(disposing);
        }