/// <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; _ribbonDateTimePicker = ribbonDateTimePicker; _needPaint = needPaint; _currentSize = _ribbonDateTimePicker.ItemSizeCurrent; // Hook into the date time picker events _ribbonDateTimePicker.MouseEnterControl += new EventHandler(OnMouseEnterControl); _ribbonDateTimePicker.MouseLeaveControl += new EventHandler(OnMouseLeaveControl); // Associate this view with the source component (required for design time selection) Component = _ribbonDateTimePicker; 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 += new MouseEventHandler(OnContextClick); MouseController = controller; } // Create controller needed for handling focus and key tip actions _controller = new DateTimePickerController(_ribbon, _ribbonDateTimePicker, this); SourceController = _controller; KeyController = _controller; // We need to rest visibility of the date time picker for each layout cycle _ribbon.ViewRibbonManager.LayoutBefore += new EventHandler(OnLayoutAction); _ribbon.ViewRibbonManager.LayoutAfter += new EventHandler(OnLayoutAction); // Define back reference to view for the text box definition _ribbonDateTimePicker.DateTimePickerView = this; // Give paint delegate to date time picker so its palette changes are redrawn _ribbonDateTimePicker.ViewPaintDelegate = needPaint; // Hook into changes in the ribbon custom definition _ribbonDateTimePicker.PropertyChanged += new PropertyChangedEventHandler(OnDateTimePickerPropertyChanged); }