Skip to content

Commit d6fcdfc

Browse files
michael-hawkerRosuavio
authored andcommitted
Update RangeMin and RangeMax to RangeStart and RangeEnd
These properties and their descriptions were confusing (and abbreviated) which made it difficult to understand how they differed from the Minimum/Maximum value properties. This clearly now separates which properties are being selected by the user. Their comments have been updated as well. It also aligns with the new Range struct field names in .NET: Start/End. original author: @michael-hawker
1 parent df169df commit d6fcdfc

File tree

6 files changed

+79
-79
lines changed

6 files changed

+79
-79
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RangeSelector/RangeSelectorCode.bind

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<TextBlock Grid.Column="0"
2222
HorizontalAlignment="Left"
2323
VerticalAlignment="Center"
24-
Text="{Binding RangeMin, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
24+
Text="{Binding RangeStart, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
2525
<controls:RangeSelector x:Name="RangeSelectorControl"
2626
Grid.Column="1"
2727
Minimum="@[Minimum:Slider:0:0-100]@"
@@ -30,7 +30,7 @@
3030
<TextBlock Grid.Column="2"
3131
HorizontalAlignment="Right"
3232
VerticalAlignment="Center"
33-
Text="{Binding RangeMax, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
33+
Text="{Binding RangeEnd, ElementName=RangeSelectorControl, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:0.##}'}" />
3434
</Grid>
3535
</Grid>
3636
</Page>

Microsoft.Toolkit.Uwp.UI.Controls.Input/RangeSelector/RangeSelector.Input.Drag.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ private void MinThumb_DragDelta(object sender, DragDeltaEventArgs e)
1919
{
2020
_absolutePosition += e.HorizontalChange;
2121

22-
RangeMin = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), _absolutePosition);
22+
RangeStart = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), _absolutePosition);
2323

2424
if (_toolTipText != null)
2525
{
26-
UpdateToolTipText(this, _toolTipText, RangeMin);
26+
UpdateToolTipText(this, _toolTipText, RangeStart);
2727
}
2828
}
2929

3030
private void MaxThumb_DragDelta(object sender, DragDeltaEventArgs e)
3131
{
3232
_absolutePosition += e.HorizontalChange;
3333

34-
RangeMax = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), _absolutePosition);
34+
RangeEnd = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), _absolutePosition);
3535

3636
if (_toolTipText != null)
3737
{
38-
UpdateToolTipText(this, _toolTipText, RangeMax);
38+
UpdateToolTipText(this, _toolTipText, RangeEnd);
3939
}
4040
}
4141

@@ -54,7 +54,7 @@ private void MaxThumb_DragStarted(object sender, DragStartedEventArgs e)
5454
private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
5555
{
5656
OnThumbDragCompleted(e);
57-
OnValueChanged(sender.Equals(_minThumb) ? new RangeChangedEventArgs(_oldValue, RangeMin, RangeSelectorProperty.MinimumValue) : new RangeChangedEventArgs(_oldValue, RangeMax, RangeSelectorProperty.MaximumValue));
57+
OnValueChanged(sender.Equals(_minThumb) ? new RangeChangedEventArgs(_oldValue, RangeStart, RangeSelectorProperty.MinimumValue) : new RangeChangedEventArgs(_oldValue, RangeEnd, RangeSelectorProperty.MaximumValue));
5858
SyncThumbs();
5959

6060
if (_toolTip != null)
@@ -97,7 +97,7 @@ private void Thumb_DragStarted(Thumb thumb)
9797
_absolutePosition = Canvas.GetLeft(thumb);
9898
Canvas.SetZIndex(thumb, 10);
9999
Canvas.SetZIndex(otherThumb, 0);
100-
_oldValue = RangeMin;
100+
_oldValue = RangeStart;
101101

102102
if (_toolTipText != null && _toolTip != null)
103103
{
@@ -107,7 +107,7 @@ private void Thumb_DragStarted(Thumb thumb)
107107
var ttWidth = _toolTip.ActualWidth / 2;
108108
Canvas.SetLeft(_toolTip, thumbCenter - ttWidth);
109109

110-
UpdateToolTipText(this, _toolTipText, useMin ? RangeMin : RangeMax);
110+
UpdateToolTipText(this, _toolTipText, useMin ? RangeStart : RangeEnd);
111111
}
112112

113113
VisualStateManager.GoToState(this, useMin ? "MinPressed" : "MaxPressed", true);

Microsoft.Toolkit.Uwp.UI.Controls.Input/RangeSelector/RangeSelector.Input.Key.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private void MinThumb_KeyDown(object sender, KeyRoutedEventArgs e)
2222
switch (e.Key)
2323
{
2424
case VirtualKey.Left:
25-
RangeMin -= StepFrequency;
25+
RangeStart -= StepFrequency;
2626
SyncThumbs(fromMinKeyDown: true);
2727
if (_toolTip != null)
2828
{
@@ -32,7 +32,7 @@ private void MinThumb_KeyDown(object sender, KeyRoutedEventArgs e)
3232
e.Handled = true;
3333
break;
3434
case VirtualKey.Right:
35-
RangeMin += StepFrequency;
35+
RangeStart += StepFrequency;
3636
SyncThumbs(fromMinKeyDown: true);
3737
if (_toolTip != null)
3838
{
@@ -49,7 +49,7 @@ private void MaxThumb_KeyDown(object sender, KeyRoutedEventArgs e)
4949
switch (e.Key)
5050
{
5151
case VirtualKey.Left:
52-
RangeMax -= StepFrequency;
52+
RangeEnd -= StepFrequency;
5353
SyncThumbs(fromMaxKeyDown: true);
5454
if (_toolTip != null)
5555
{
@@ -59,7 +59,7 @@ private void MaxThumb_KeyDown(object sender, KeyRoutedEventArgs e)
5959
e.Handled = true;
6060
break;
6161
case VirtualKey.Right:
62-
RangeMax += StepFrequency;
62+
RangeEnd += StepFrequency;
6363
SyncThumbs(fromMaxKeyDown: true);
6464
if (_toolTip != null)
6565
{

Microsoft.Toolkit.Uwp.UI.Controls.Input/RangeSelector/RangeSelector.Input.Pointer.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ private void ContainerCanvas_PointerExited(object sender, PointerRoutedEventArgs
3333
{
3434
_pointerManipulatingMin = false;
3535
_containerCanvas.IsHitTestVisible = true;
36-
OnValueChanged(new RangeChangedEventArgs(RangeMin, normalizedPosition, RangeSelectorProperty.MinimumValue));
36+
OnValueChanged(new RangeChangedEventArgs(RangeStart, normalizedPosition, RangeSelectorProperty.MinimumValue));
3737
}
3838
else if (_pointerManipulatingMax)
3939
{
4040
_pointerManipulatingMax = false;
4141
_containerCanvas.IsHitTestVisible = true;
42-
OnValueChanged(new RangeChangedEventArgs(RangeMax, normalizedPosition, RangeSelectorProperty.MaximumValue));
42+
OnValueChanged(new RangeChangedEventArgs(RangeEnd, normalizedPosition, RangeSelectorProperty.MaximumValue));
4343
}
4444

4545
if (_toolTip != null)
@@ -59,13 +59,13 @@ private void ContainerCanvas_PointerReleased(object sender, PointerRoutedEventAr
5959
{
6060
_pointerManipulatingMin = false;
6161
_containerCanvas.IsHitTestVisible = true;
62-
OnValueChanged(new RangeChangedEventArgs(RangeMin, normalizedPosition, RangeSelectorProperty.MinimumValue));
62+
OnValueChanged(new RangeChangedEventArgs(RangeStart, normalizedPosition, RangeSelectorProperty.MinimumValue));
6363
}
6464
else if (_pointerManipulatingMax)
6565
{
6666
_pointerManipulatingMax = false;
6767
_containerCanvas.IsHitTestVisible = true;
68-
OnValueChanged(new RangeChangedEventArgs(RangeMax, normalizedPosition, RangeSelectorProperty.MaximumValue));
68+
OnValueChanged(new RangeChangedEventArgs(RangeEnd, normalizedPosition, RangeSelectorProperty.MaximumValue));
6969
}
7070

7171
SyncThumbs();
@@ -81,34 +81,34 @@ private void ContainerCanvas_PointerMoved(object sender, PointerRoutedEventArgs
8181
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
8282
var normalizedPosition = ((position / DragWidth()) * (Maximum - Minimum)) + Minimum;
8383

84-
if (_pointerManipulatingMin && normalizedPosition < RangeMax)
84+
if (_pointerManipulatingMin && normalizedPosition < RangeEnd)
8585
{
86-
RangeMin = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), position);
87-
UpdateToolTipText(this, _toolTipText, RangeMin);
86+
RangeStart = DragThumb(_minThumb, 0, Canvas.GetLeft(_maxThumb), position);
87+
UpdateToolTipText(this, _toolTipText, RangeStart);
8888
}
89-
else if (_pointerManipulatingMax && normalizedPosition > RangeMin)
89+
else if (_pointerManipulatingMax && normalizedPosition > RangeStart)
9090
{
91-
RangeMax = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), position);
92-
UpdateToolTipText(this, _toolTipText, RangeMax);
91+
RangeEnd = DragThumb(_maxThumb, Canvas.GetLeft(_minThumb), DragWidth(), position);
92+
UpdateToolTipText(this, _toolTipText, RangeEnd);
9393
}
9494
}
9595

9696
private void ContainerCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
9797
{
9898
var position = e.GetCurrentPoint(_containerCanvas).Position.X;
9999
var normalizedPosition = position * Math.Abs(Maximum - Minimum) / DragWidth();
100-
double upperValueDiff = Math.Abs(RangeMax - normalizedPosition);
101-
double lowerValueDiff = Math.Abs(RangeMin - normalizedPosition);
100+
double upperValueDiff = Math.Abs(RangeEnd - normalizedPosition);
101+
double lowerValueDiff = Math.Abs(RangeStart - normalizedPosition);
102102

103103
if (upperValueDiff < lowerValueDiff)
104104
{
105-
RangeMax = normalizedPosition;
105+
RangeEnd = normalizedPosition;
106106
_pointerManipulatingMax = true;
107107
Thumb_DragStarted(_maxThumb);
108108
}
109109
else
110110
{
111-
RangeMin = normalizedPosition;
111+
RangeStart = normalizedPosition;
112112
_pointerManipulatingMin = true;
113113
Thumb_DragStarted(_minThumb);
114114
}

Microsoft.Toolkit.Uwp.UI.Controls.Input/RangeSelector/RangeSelector.Properties.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
1313
public partial class RangeSelector : Control
1414
{
1515
/// <summary>
16-
/// Identifies the Minimum dependency property.
16+
/// Identifies the <see cref="Minimum"/> property.
1717
/// </summary>
1818
public static readonly DependencyProperty MinimumProperty =
1919
DependencyProperty.Register(
@@ -23,7 +23,7 @@ public partial class RangeSelector : Control
2323
new PropertyMetadata(DefaultMinimum, MinimumChangedCallback));
2424

2525
/// <summary>
26-
/// Identifies the Maximum dependency property.
26+
/// Identifies the <see cref="Maximum"/> property.
2727
/// </summary>
2828
public static readonly DependencyProperty MaximumProperty =
2929
DependencyProperty.Register(
@@ -33,27 +33,27 @@ public partial class RangeSelector : Control
3333
new PropertyMetadata(DefaultMaximum, MaximumChangedCallback));
3434

3535
/// <summary>
36-
/// Identifies the RangeMin dependency property.
36+
/// Identifies the <see cref="RangeStart"/> property.
3737
/// </summary>
38-
public static readonly DependencyProperty RangeMinProperty =
38+
public static readonly DependencyProperty RangeStartProperty =
3939
DependencyProperty.Register(
40-
nameof(RangeMin),
40+
nameof(RangeStart),
4141
typeof(double),
4242
typeof(RangeSelector),
4343
new PropertyMetadata(DefaultMinimum, RangeMinChangedCallback));
4444

4545
/// <summary>
46-
/// Identifies the RangeMax dependency property.
46+
/// Identifies the <see cref="RangeEnd"/> property.
4747
/// </summary>
48-
public static readonly DependencyProperty RangeMaxProperty =
48+
public static readonly DependencyProperty RangeEndProperty =
4949
DependencyProperty.Register(
50-
nameof(RangeMax),
50+
nameof(RangeEnd),
5151
typeof(double),
5252
typeof(RangeSelector),
5353
new PropertyMetadata(DefaultMaximum, RangeMaxChangedCallback));
5454

5555
/// <summary>
56-
/// Identifies the StepFrequency dependency property.
56+
/// Identifies the <see cref="StepFrequency"/> property.
5757
/// </summary>
5858
public static readonly DependencyProperty StepFrequencyProperty =
5959
DependencyProperty.Register(
@@ -63,7 +63,7 @@ public partial class RangeSelector : Control
6363
new PropertyMetadata(DefaultStepFrequency));
6464

6565
/// <summary>
66-
/// Gets or sets the minimum value of the range.
66+
/// Gets or sets the absolute minimum value of the range.
6767
/// </summary>
6868
/// <value>
6969
/// The minimum.
@@ -75,7 +75,7 @@ public double Minimum
7575
}
7676

7777
/// <summary>
78-
/// Gets or sets the maximum value of the range.
78+
/// Gets or sets the absolute maximum value of the range.
7979
/// </summary>
8080
/// <value>
8181
/// The maximum.
@@ -87,27 +87,27 @@ public double Maximum
8787
}
8888

8989
/// <summary>
90-
/// Gets or sets the current lower limit value of the range.
90+
/// Gets or sets the current selected lower limit value of the range, modifiable by the user.
9191
/// </summary>
9292
/// <value>
9393
/// The current lower limit.
9494
/// </value>
95-
public double RangeMin
95+
public double RangeStart
9696
{
97-
get => (double)GetValue(RangeMinProperty);
98-
set => SetValue(RangeMinProperty, value);
97+
get => (double)GetValue(RangeStartProperty);
98+
set => SetValue(RangeStartProperty, value);
9999
}
100100

101101
/// <summary>
102-
/// Gets or sets the current upper limit value of the range.
102+
/// Gets or sets the current selected upper limit value of the range, modifiable by the user.
103103
/// </summary>
104104
/// <value>
105105
/// The current upper limit.
106106
/// </value>
107-
public double RangeMax
107+
public double RangeEnd
108108
{
109-
get => (double)GetValue(RangeMaxProperty);
110-
set => SetValue(RangeMaxProperty, value);
109+
get => (double)GetValue(RangeEndProperty);
110+
set => SetValue(RangeEndProperty, value);
111111
}
112112

113113
/// <summary>
@@ -139,14 +139,14 @@ private static void MinimumChangedCallback(DependencyObject d, DependencyPropert
139139
rangeSelector.Maximum = newValue + Epsilon;
140140
}
141141

142-
if (rangeSelector.RangeMin < newValue)
142+
if (rangeSelector.RangeStart < newValue)
143143
{
144-
rangeSelector.RangeMin = newValue;
144+
rangeSelector.RangeStart = newValue;
145145
}
146146

147-
if (rangeSelector.RangeMax < newValue)
147+
if (rangeSelector.RangeEnd < newValue)
148148
{
149-
rangeSelector.RangeMax = newValue;
149+
rangeSelector.RangeEnd = newValue;
150150
}
151151

152152
if (newValue != oldValue)
@@ -172,14 +172,14 @@ private static void MaximumChangedCallback(DependencyObject d, DependencyPropert
172172
rangeSelector.Minimum = newValue - Epsilon;
173173
}
174174

175-
if (rangeSelector.RangeMax > newValue)
175+
if (rangeSelector.RangeEnd > newValue)
176176
{
177-
rangeSelector.RangeMax = newValue;
177+
rangeSelector.RangeEnd = newValue;
178178
}
179179

180-
if (rangeSelector.RangeMin > newValue)
180+
if (rangeSelector.RangeStart > newValue)
181181
{
182-
rangeSelector.RangeMin = newValue;
182+
rangeSelector.RangeStart = newValue;
183183
}
184184

185185
if (newValue != oldValue)
@@ -211,19 +211,19 @@ private static void RangeMinChangedCallback(DependencyObject d, DependencyProper
211211
{
212212
if (newValue < rangeSelector.Minimum)
213213
{
214-
rangeSelector.RangeMin = rangeSelector.Minimum;
214+
rangeSelector.RangeStart = rangeSelector.Minimum;
215215
}
216216
else if (newValue > rangeSelector.Maximum)
217217
{
218-
rangeSelector.RangeMin = rangeSelector.Maximum;
218+
rangeSelector.RangeStart = rangeSelector.Maximum;
219219
}
220220

221221
rangeSelector.SyncActiveRectangle();
222222

223223
// If the new value is greater than the old max, move the max also
224-
if (newValue > rangeSelector.RangeMax)
224+
if (newValue > rangeSelector.RangeEnd)
225225
{
226-
rangeSelector.RangeMax = newValue;
226+
rangeSelector.RangeEnd = newValue;
227227
}
228228
}
229229

@@ -253,19 +253,19 @@ private static void RangeMaxChangedCallback(DependencyObject d, DependencyProper
253253
{
254254
if (newValue < rangeSelector.Minimum)
255255
{
256-
rangeSelector.RangeMax = rangeSelector.Minimum;
256+
rangeSelector.RangeEnd = rangeSelector.Minimum;
257257
}
258258
else if (newValue > rangeSelector.Maximum)
259259
{
260-
rangeSelector.RangeMax = rangeSelector.Maximum;
260+
rangeSelector.RangeEnd = rangeSelector.Maximum;
261261
}
262262

263263
rangeSelector.SyncActiveRectangle();
264264

265265
// If the new max is less than the old minimum then move the minimum
266-
if (newValue < rangeSelector.RangeMin)
266+
if (newValue < rangeSelector.RangeStart)
267267
{
268-
rangeSelector.RangeMin = newValue;
268+
rangeSelector.RangeStart = newValue;
269269
}
270270
}
271271

0 commit comments

Comments
 (0)