/// <summary>
        /// Initialize a new instance of the DateTimePickerController class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="dateTimePicker">Source definition.</param>
        /// <param name="target">Target view element.</param>
        public DateTimePickerController(KryptonRibbon ribbon,
                                        KryptonRibbonGroupDateTimePicker dateTimePicker,
                                        ViewDrawRibbonGroupDateTimePicker target)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(dateTimePicker != null);
            Debug.Assert(target != null);

            _ribbon         = ribbon;
            _dateTimePicker = dateTimePicker;
            _target         = target;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupDateTimePicker class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonDateTimePicker">Reference to source date time picker.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupDateTimePicker(KryptonRibbon ribbon,
                                                 KryptonRibbonGroupDateTimePicker ribbonDateTimePicker,
                                                 NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonDateTimePicker != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon             = ribbon;
            GroupDateTimePicker = ribbonDateTimePicker;
            _needPaint          = needPaint;
            _currentSize        = GroupDateTimePicker.ItemSizeCurrent;

            // Hook into the date time picker events
            GroupDateTimePicker.MouseEnterControl += OnMouseEnterControl;
            GroupDateTimePicker.MouseLeaveControl += OnMouseLeaveControl;

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

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

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

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

            // Define back reference to view for the text box definition
            GroupDateTimePicker.DateTimePickerView = this;

            // Give paint delegate to date time picker so its palette changes are redrawn
            GroupDateTimePicker.ViewPaintDelegate = needPaint;

            // Hook into changes in the ribbon custom definition
            GroupDateTimePicker.PropertyChanged += OnDateTimePickerPropertyChanged;
        }
Exemple #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
            _ribbonDateTimePicker = (KryptonRibbonGroupDateTimePicker)component;
            _ribbonDateTimePicker.DateTimePickerDesigner = this;

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

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

            // Tell the embedded text box it is in design mode
            _ribbonDateTimePicker.DateTimePicker.InRibbonDesignMode = true;

            // Hook into events
            _ribbonDateTimePicker.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;
        }