/// <include file='doc\MonthCalendar.uex' path='docs/doc[@for="MonthCalendar.WmDateBold"]/*' /> /// <devdoc> /// Handles the MCN_GETDAYSTATE notification /// </devdoc> /// <internalonly/> private void WmDateBold(ref Message m) { NativeMethods.NMDAYSTATE nmmcds = (NativeMethods.NMDAYSTATE)m.GetLParam(typeof(NativeMethods.NMDAYSTATE)); DateTime start = DateTimePicker.SysTimeToDateTime(nmmcds.stStart); DateBoldEventArgs boldEvent = new DateBoldEventArgs(start, nmmcds.cDayState); BoldDates(boldEvent); mdsBuffer = RequestBuffer(boldEvent.Size); // copy boldEvent into mdsBuffer Marshal.Copy(boldEvent.DaysToBold, 0, mdsBuffer, boldEvent.Size); // now we replug DateBoldEventArgs info into NMDAYSTATE nmmcds.prgDayState = mdsBuffer; Marshal.StructureToPtr(nmmcds, m.LParam, false); }
/// <include file='doc\MonthCalendar.uex' path='docs/doc[@for="MonthCalendar.BoldDates"]/*' /> /// <devdoc> /// Event handler that bolds dates indicated by arrayOfDates /// </devdoc> /// <internalonly/> private void BoldDates(DateBoldEventArgs e) { int months = e.Size; e.DaysToBold = new int[months]; SelectionRange range = GetDisplayRange(false); int startMonth = range.Start.Month; int startYear = range.Start.Year; int numDates = arrayOfDates.Count; for (int i=0; i<numDates; ++i) { DateTime date = (DateTime) arrayOfDates[i]; if (DateTime.Compare(date, range.Start) >= 0 && DateTime.Compare(date, range.End) <= 0) { int month = date.Month; int year = date.Year; int index = (year == startYear) ? month - startMonth : month + year*MONTHS_IN_YEAR - startYear*MONTHS_IN_YEAR - startMonth; e.DaysToBold[index] |= (0x00000001<<(date.Day-1)); } } //now we figure out which monthly and annual dates to bold --startMonth; for (int i=0; i<months; ++i, ++startMonth) e.DaysToBold[i] |= monthsOfYear[startMonth % MONTHS_IN_YEAR] | datesToBoldMonthly; }
private void WmDateBold(ref Message m) { System.Windows.Forms.NativeMethods.NMDAYSTATE lParam = (System.Windows.Forms.NativeMethods.NMDAYSTATE) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMDAYSTATE)); DateBoldEventArgs e = new DateBoldEventArgs(DateTimePicker.SysTimeToDateTime(lParam.stStart), lParam.cDayState); this.BoldDates(e); this.mdsBuffer = this.RequestBuffer(e.Size); Marshal.Copy(e.DaysToBold, 0, this.mdsBuffer, e.Size); lParam.prgDayState = this.mdsBuffer; Marshal.StructureToPtr(lParam, m.LParam, false); }
private void BoldDates(DateBoldEventArgs e) { int size = e.Size; e.DaysToBold = new int[size]; System.Windows.Forms.SelectionRange displayRange = this.GetDisplayRange(false); int month = displayRange.Start.Month; int year = displayRange.Start.Year; int count = this.arrayOfDates.Count; for (int i = 0; i < count; i++) { DateTime time = (DateTime) this.arrayOfDates[i]; if ((DateTime.Compare(time, displayRange.Start) >= 0) && (DateTime.Compare(time, displayRange.End) <= 0)) { int num6 = time.Month; int num7 = time.Year; int num8 = (num7 == year) ? (num6 - month) : (((num6 + (num7 * 12)) - (year * 12)) - month); e.DaysToBold[num8] |= ((int) 1) << (time.Day - 1); } } month--; int index = 0; while (index < size) { e.DaysToBold[index] |= this.monthsOfYear[month % 12] | this.datesToBoldMonthly; index++; month++; } }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// dateboldeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this DateBoldEventHandler dateboldeventhandler, Object sender, DateBoldEventArgs e, AsyncCallback callback) { if(dateboldeventhandler == null) throw new ArgumentNullException("dateboldeventhandler"); return dateboldeventhandler.BeginInvoke(sender, e, callback, null); }