Beispiel #1
0
        /// <summary>
        /// Initialize a new instance of the NumericUpDownController class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="numericUpDown">Source definition.</param>
        /// <param name="target">Target view element.</param>
        public NumericUpDownController(KryptonRibbon ribbon,
                                       KryptonRibbonGroupNumericUpDown numericUpDown,
                                       ViewDrawRibbonGroupNumericUpDown target)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(numericUpDown != null);
            Debug.Assert(target != null);

            _ribbon        = ribbon;
            _numericUpDown = numericUpDown;
            _target        = target;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupNumericUpDown class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonNumericUpDown">Reference to source numeric up-down.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupNumericUpDown(KryptonRibbon ribbon,
                                                KryptonRibbonGroupNumericUpDown ribbonNumericUpDown,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonNumericUpDown != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon            = ribbon;
            GroupNumericUpDown = ribbonNumericUpDown;
            _needPaint         = needPaint;
            _currentSize       = GroupNumericUpDown.ItemSizeCurrent;

            // Hook into the numeric up-down events
            GroupNumericUpDown.MouseEnterControl += OnMouseEnterControl;
            GroupNumericUpDown.MouseLeaveControl += OnMouseLeaveControl;

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

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

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

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

            // Define back reference to view for the numeric up-down definition
            GroupNumericUpDown.NumericUpDownView = this;

            // Give paint delegate to numeric up-down so its palette changes are redrawn
            GroupNumericUpDown.ViewPaintDelegate = needPaint;

            // Hook into changes in the ribbon custom definition
            GroupNumericUpDown.PropertyChanged += OnNumericUpDownPropertyChanged;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate the designer with.</param>
        public override void Initialize(IComponent component)
        {
            Debug.Assert(component != null);

            // Validate the parameter reference
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            // Let base class do standard stuff
            base.Initialize(component);

            // Cast to correct type
            _ribbonNumericUpDown = (KryptonRibbonGroupNumericUpDown)component;
            _ribbonNumericUpDown.NumericUpDownDesigner = this;

            // Update designer properties with actual starting values
            Visible = _ribbonNumericUpDown.Visible;
            Enabled = _ribbonNumericUpDown.Enabled;

            // Update visible/enabled to always be showing/enabled at design time
            _ribbonNumericUpDown.Visible = true;
            _ribbonNumericUpDown.Enabled = true;

            // Tell the embedded numeric up-down control it is in design mode
            _ribbonNumericUpDown.NumericUpDown.InRibbonDesignMode = true;

            // Hook into events
            _ribbonNumericUpDown.DesignTimeContextMenu += OnContextMenu;

            // Get access to the services
            _designerHost  = (IDesignerHost)GetService(typeof(IDesignerHost));
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentChanged += OnComponentChanged;
        }