Process mouse events for a ribbon group track bar.
Inheritance: ComponentFactory.Krypton.Toolkit.GlobalId, ISourceController, IKeyController, IRibbonKeyTipTarget
Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupTrackBar class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonTrackBar">Reference to source track bar.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupTrackBar(KryptonRibbon ribbon,
                                           KryptonRibbonGroupTrackBar ribbonTrackBar,
                                           NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonTrackBar != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon       = ribbon;
            GroupTrackBar = ribbonTrackBar;
            _needPaint    = needPaint;
            _currentSize  = GroupTrackBar.ItemSizeCurrent;

            // Hook into the textbox events
            GroupTrackBar.MouseEnterControl += OnMouseEnterControl;
            GroupTrackBar.MouseLeaveControl += OnMouseLeaveControl;

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

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

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

            // We need to rest visibility of the textbox for each layout cycle
            _ribbon.ViewRibbonManager.LayoutBefore += OnLayoutAction;
            _ribbon.ViewRibbonManager.LayoutAfter  += OnLayoutAction;

            // Define back reference to view for the text box definition
            GroupTrackBar.TrackBarView = this;

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

            // Hook into changes in the ribbon custom definition
            GroupTrackBar.PropertyChanged += OnTextBoxPropertyChanged;
        }