+2009-01-19 Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+ * MonthCalendar.cs: When handling the selection changes using the
+ mouse, don't set SelectionRange if the selection range didn't actually
+ change. This matters because, even if we set the range to the same
+ previous range, an extra DateChanged event is fired. Just to be clear:
+ SelectionRage property doesn't check whether the new value is
+ different to the previous one (by ref equals doesn't work here).
+ Fixes other bits of #364914.
+
2009-01-19 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* MonthCalendar.cs: Remove the extra OnDateChanged call when handling
// attempts to add the date to the selection without throwing exception
private void SelectDate (DateTime date) {
// try and add the new date to the selction range
+ SelectionRange range = null;
if (is_shift_pressed || (click_state [0])) {
- SelectionRange range = new SelectionRange (first_select_start_date, date);
+ range = new SelectionRange (first_select_start_date, date);
if (range.Start.AddDays (MaxSelectionCount-1) < range.End) {
// okay the date is beyond what is allowed, lets set the maximum we can
if (range.Start != first_select_start_date) {
range.End = range.Start.AddDays (MaxSelectionCount-1);
}
}
- SelectionRange = range;
} else {
if (date >= MinDate && date <= MaxDate) {
- SelectionRange = new SelectionRange (date, date);
+ range = new SelectionRange (date, date);
first_select_start_date = date;
}
}
+
+ // Only set if we re actually getting a different range (avoid an extra DateChanged event)
+ if (range != null && range.Start != selection_range.Start || range.End != selection_range.End)
+ SelectionRange = range;
}
// gets the week of the year