Process mouse events for a ribbon group custom control.
Inheritance: ComponentFactory.Krypton.Toolkit.GlobalId, ISourceController, IKeyController, IRibbonKeyTipTarget
Example #1
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupCustom class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonCustom">Reference to source custom definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupCustomControl(KryptonRibbon ribbon,
                                                KryptonRibbonGroupCustomControl ribbonCustom,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCustom != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon = ribbon;
            _ribbonCustomControl = ribbonCustom;
            _needPaint           = needPaint;
            _currentSize         = _ribbonCustomControl.ItemSizeCurrent;

            // Hook into the custom control events
            _ribbonCustomControl.MouseEnterControl += new EventHandler(OnMouseEnterControl);
            _ribbonCustomControl.MouseLeaveControl += new EventHandler(OnMouseLeaveControl);

            // Associate this view with the source component (required for design time selection)
            Component = _ribbonCustomControl;

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the label
                ContextClickController controller = new ContextClickController();
                controller.ContextClick += new MouseEventHandler(OnContextClick);
                MouseController          = controller;
            }

            // Create controller needed for handling focus and key tip actions
            _controller      = new CustomControlController(_ribbon, _ribbonCustomControl, this);
            SourceController = _controller;
            KeyController    = _controller;

            // We need to rest visibility of the custom control for each layout cycle
            _ribbon.ViewRibbonManager.LayoutBefore += new EventHandler(OnLayoutAction);
            _ribbon.ViewRibbonManager.LayoutAfter  += new EventHandler(OnLayoutAction);

            // Provide back reference to the custom control definition
            _ribbonCustomControl.CustomControlView = this;

            // Give paint delegate to label so its palette changes are redrawn
            _ribbonCustomControl.ViewPaintDelegate = needPaint;

            // Hook into changes in the ribbon custom definition
            _ribbonCustomControl.PropertyChanged += new PropertyChangedEventHandler(OnCustomPropertyChanged);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupCustom class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonCustom">Reference to source custom definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupCustomControl(KryptonRibbon ribbon,
                                                KryptonRibbonGroupCustomControl ribbonCustom,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCustom != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon = ribbon;
            _ribbonCustomControl = ribbonCustom;
            _needPaint = needPaint;
            _currentSize = _ribbonCustomControl.ItemSizeCurrent;

            // Hook into the custom control events
            _ribbonCustomControl.MouseEnterControl += new EventHandler(OnMouseEnterControl);
            _ribbonCustomControl.MouseLeaveControl += new EventHandler(OnMouseLeaveControl);

            // Associate this view with the source component (required for design time selection)
            Component = _ribbonCustomControl;

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the label
                ContextClickController controller = new ContextClickController();
                controller.ContextClick += new MouseEventHandler(OnContextClick);
                MouseController = controller;
            }

            // Create controller needed for handling focus and key tip actions
            _controller = new CustomControlController(_ribbon, _ribbonCustomControl, this);
            SourceController = _controller;
            KeyController = _controller;

            // We need to rest visibility of the custom control for each layout cycle
            _ribbon.ViewRibbonManager.LayoutBefore += new EventHandler(OnLayoutAction);
            _ribbon.ViewRibbonManager.LayoutAfter += new EventHandler(OnLayoutAction);

            // Provide back reference to the custom control definition
            _ribbonCustomControl.CustomControlView = this;

            // Give paint delegate to label so its palette changes are redrawn
            _ribbonCustomControl.ViewPaintDelegate = needPaint;

            // Hook into changes in the ribbon custom definition
            _ribbonCustomControl.PropertyChanged += new PropertyChangedEventHandler(OnCustomPropertyChanged);
        }