/// <summary> /// Perform final steps now that the button spec has been created. /// </summary> /// <param name="buttonSpec">ButtonSpec instance.</param> /// <param name="buttonView">Associated ButtonSpecView instance.</param> /// <param name="viewDockerIndex">Index of view docker button is placed onto.</param> protected virtual void ButtonSpecCreated(ButtonSpec buttonSpec, ButtonSpecView buttonView, int viewDockerIndex) { // Cast the remapping palette to the correct type ButtonSpecRemapByContentView remapPalette = (ButtonSpecRemapByContentView)buttonView.RemapPalette; // Update button with the foreground used for colour mapping remapPalette.Foreground = GetDockerForeground(viewDockerIndex); }
/// <summary> /// Initialize a new instance of the ViewLayoutMonths class. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="monthCalendar">Reference to owning month calendar entry.</param> /// <param name="viewManager">Owning view manager instance.</param> /// <param name="calendar">Reference to calendar provider.</param> /// <param name="redirector">Redirector for getting values.</param> /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param> public ViewLayoutMonths(IContextMenuProvider provider, KryptonContextMenuMonthCalendar monthCalendar, ViewContextMenuManager viewManager, IKryptonMonthCalendar calendar, PaletteRedirect redirector, NeedPaintHandler needPaintDelegate) { Provider = provider; Calendar = calendar; _oldSelectionStart = Calendar.SelectionStart; _oldSelectionEnd = Calendar.SelectionEnd; _displayMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); _redirector = redirector; _needPaintDelegate = needPaintDelegate; _showToday = true; _showTodayCircle = true; CloseOnTodayClick = false; _firstTimeSync = true; AllowButtonSpecToolTips = false; // Use a controller that can work against all the displayed months MonthCalendarController controller = new MonthCalendarController(monthCalendar, viewManager, this, _needPaintDelegate); MouseController = controller; SourceController = controller; KeyController = controller; _borderForced = new PaletteBorderInheritForced(Calendar.StateNormal.Header.Border); _borderForced.ForceBorderEdges(PaletteDrawBorders.None); _drawHeader = new ViewDrawDocker(Calendar.StateNormal.Header.Back, _borderForced, null); _emptyContent = new ViewDrawEmptyContent(Calendar.StateDisabled.Header.Content, Calendar.StateNormal.Header.Content); _drawHeader.Add(_emptyContent, ViewDockStyle.Fill); Add(_drawHeader); // Using a button spec manager to add the buttons to the header ButtonSpecs = new MonthCalendarButtonSpecCollection(this); ButtonManager = new ButtonSpecManagerDraw(Calendar.CalendarControl, redirector, ButtonSpecs, null, new ViewDrawDocker[] { _drawHeader }, new IPaletteMetric[] { Calendar.StateCommon }, new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetCalendar }, new PaletteMetricPadding[] { PaletteMetricPadding.None }, Calendar.GetToolStripDelegate, _needPaintDelegate); // Create the manager for handling tooltips _toolTipManager = new ToolTipManager(); _toolTipManager.ShowToolTip += OnShowToolTip; _toolTipManager.CancelToolTip += OnCancelToolTip; ButtonManager.ToolTipManager = _toolTipManager; // Create the bottom header used for showing 'today' and defined button specs _remapPalette = (ButtonSpecRemapByContentView)ButtonManager.CreateButtonSpecRemap(redirector, new ButtonSpecAny()); _remapPalette.Foreground = _emptyContent; // Use a redirector to get button values directly from palette _palette = new PaletteTripleRedirect(_remapPalette, PaletteBackStyle.ButtonButtonSpec, PaletteBorderStyle.ButtonButtonSpec, PaletteContentStyle.ButtonButtonSpec, _needPaintDelegate); _drawToday = new ViewDrawToday(Calendar, _palette, _palette, _palette, _palette, _needPaintDelegate); _drawToday.Click += OnTodayClick; _drawHeader.Add(_drawToday, ViewDockStyle.Left); }