-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix RangeSlider Upper/Lower value coercion and value changed events
- Loading branch information
Showing
4 changed files
with
653 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
src/MahApps.Metro/Controls/RangeParameterChangedEventArgs.cs
This file was deleted.
Oops, something went wrong.
80 changes: 66 additions & 14 deletions
80
src/MahApps.Metro/Controls/RangeSelectionChangedEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,85 @@ | ||
using System; | ||
using System.Windows; | ||
|
||
namespace MahApps.Metro.Controls | ||
{ | ||
/// <summary> | ||
/// Event arguments created for the RangeSlider's SelectionChanged event. | ||
/// <see cref="RangeSlider"/> | ||
/// This delegate must used by handlers of the RangeSelectionChangedEvent event. | ||
/// </summary> | ||
public class RangeSelectionChangedEventArgs : RoutedEventArgs | ||
/// <param name="sender">The current element along the event's route.</param> | ||
/// <param name="e">The event arguments containing additional information about the event.</param> | ||
/// <returns>Nothing.</returns> | ||
public delegate void RangeSelectionChangedEventHandler<T>(object sender, RangeSelectionChangedEventArgs<T> e); | ||
|
||
/// <summary> | ||
/// This RangeSelectionChangedEventArgs class contains old and new value when | ||
/// RangeSelectionChanged is raised. | ||
/// </summary> | ||
/// <seealso cref="RoutedEventArgs" /> | ||
/// <typeparam name="T"></typeparam> | ||
public class RangeSelectionChangedEventArgs<T> : RoutedEventArgs | ||
{ | ||
/// <summary> | ||
/// The value of the new range's beginning. | ||
/// Return the old lower value. | ||
/// </summary> | ||
public double NewLowerValue { get; set; } | ||
public T OldLowerValue { get; } | ||
|
||
/// <summary> | ||
/// The value of the new range's ending. | ||
/// Return the new lower value. | ||
/// </summary> | ||
public double NewUpperValue { get; set; } | ||
public T NewLowerValue { get; } | ||
|
||
public double OldLowerValue { get; set; } | ||
/// <summary> | ||
/// Return the old upper value. | ||
/// </summary> | ||
public T OldUpperValue { get; } | ||
|
||
public double OldUpperValue { get; set; } | ||
/// <summary> | ||
/// Return the new upper value. | ||
/// </summary> | ||
public T NewUpperValue { get; } | ||
|
||
internal RangeSelectionChangedEventArgs(double newLowerValue, double newUpperValue, double oldLowerValue, double oldUpperValue) | ||
/// <summary> | ||
/// This is an instance constructor for the RangeSelectionChangedEventArgs class. | ||
/// </summary> | ||
/// <param name="oldLowerValue">The old lower property value</param> | ||
/// <param name="newLowerValue">The new lower property value</param> | ||
/// <param name="oldUpperValue">The old upper property value</param> | ||
/// <param name="newUpperValue">The new upper property value</param> | ||
public RangeSelectionChangedEventArgs(T oldLowerValue, T newLowerValue, T oldUpperValue, T newUpperValue) | ||
{ | ||
this.OldLowerValue = oldLowerValue; | ||
this.NewLowerValue = newLowerValue; | ||
this.OldUpperValue = oldUpperValue; | ||
this.NewUpperValue = newUpperValue; | ||
} | ||
|
||
/// <summary> | ||
/// This is an instance constructor for the RoutedPropertyChangedEventArgs class. | ||
/// It is constructed with a reference to the event being raised. | ||
/// </summary> | ||
/// <param name="oldLowerValue">The old lower property value</param> | ||
/// <param name="newLowerValue">The new lower property value</param> | ||
/// <param name="oldUpperValue">The old upper property value</param> | ||
/// <param name="newUpperValue">The new upper property value</param> | ||
/// <param name="routedEvent">RoutedEvent</param> | ||
public RangeSelectionChangedEventArgs(T oldLowerValue, T newLowerValue, T oldUpperValue, T newUpperValue, RoutedEvent routedEvent) | ||
: this(oldLowerValue, newLowerValue, oldUpperValue, newUpperValue) | ||
{ | ||
this.RoutedEvent = routedEvent; | ||
} | ||
|
||
/// <summary> | ||
/// This method is used to perform the proper type casting in order to | ||
/// call the type-safe RoutedPropertyChangedEventHandler delegate for the IsCheckedChangedEvent event. | ||
/// </summary> | ||
/// <param name="genericHandler">The handler to invoke.</param> | ||
/// <param name="genericTarget">The current object along the event's route.</param> | ||
/// <returns>Nothing.</returns> | ||
protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget) | ||
{ | ||
NewLowerValue = newLowerValue; | ||
NewUpperValue = newUpperValue; | ||
OldLowerValue = oldLowerValue; | ||
OldUpperValue = oldUpperValue; | ||
var handler = (RangeSelectionChangedEventHandler<T>)genericHandler; | ||
handler(genericTarget, this); | ||
} | ||
} | ||
} |
Oops, something went wrong.