Skip to content

Commit

Permalink
2009-01-19 Carlos Alberto Cortez <calberto.cortez@gmail.com>
Browse files Browse the repository at this point in the history
	* 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.


svn path=/trunk/mcs/; revision=123799
  • Loading branch information
carlosalberto committed Jan 19, 2009
1 parent 401e3d3 commit 2501c05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 10 additions & 0 deletions mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,13 @@
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
Expand Down
Expand Up @@ -1626,8 +1626,9 @@ private void AddTimeToSelection (int delta, bool isDays)
// 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) {
Expand All @@ -1636,13 +1637,16 @@ private void AddTimeToSelection (int delta, bool isDays)
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
Expand Down

0 comments on commit 2501c05

Please sign in to comment.