Browse Source

Merge branch 'master' into remove-border-line-dash

pull/11548/head
robloo 3 years ago
committed by GitHub
parent
commit
7fcd139417
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 46
      src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs
  2. 8
      src/Avalonia.Controls/Primitives/RangeBase.cs
  3. 47
      src/Avalonia.Controls/Primitives/RangeBaseValueChangedEventArgs.cs
  4. 11
      src/Avalonia.Controls/TextChangedEventArgs.cs
  5. 11
      src/Avalonia.Controls/TextChangingEventArgs.cs

46
src/Avalonia.Base/Interactivity/RoutedPropertyChangedEventArgs.cs

@ -1,46 +0,0 @@
namespace Avalonia.Interactivity
{
/// <summary>
/// Provides both old and new property values with a routed event.
/// </summary>
/// <typeparam name="T">The type of values.</typeparam>
public class RoutedPropertyChangedEventArgs<T> : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RoutedPropertyChangedEventArgs{T}"/> class.
/// </summary>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public RoutedPropertyChangedEventArgs(T oldValue, T newValue, RoutedEvent? routedEvent)
: base(routedEvent)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="RoutedPropertyChangedEventArgs{T}"/> class.
/// </summary>
/// <param name="oldValue">The old property value.</param>
/// <param name="newValue">The new property value.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public RoutedPropertyChangedEventArgs(T oldValue, T newValue, RoutedEvent? routedEvent, object? source)
: base(routedEvent, source)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Gets the old value of the property.
/// </summary>
public T OldValue { get; init; }
/// <summary>
/// Gets the new value of the property.
/// </summary>
public T NewValue { get; init; }
}
}

8
src/Avalonia.Controls/Primitives/RangeBase.cs

@ -45,14 +45,14 @@ namespace Avalonia.Controls.Primitives
/// <summary> /// <summary>
/// Defines the <see cref="ValueChanged"/> event. /// Defines the <see cref="ValueChanged"/> event.
/// </summary> /// </summary>
public static readonly RoutedEvent<RoutedPropertyChangedEventArgs<double>> ValueChangedEvent = public static readonly RoutedEvent<RangeBaseValueChangedEventArgs> ValueChangedEvent =
RoutedEvent.Register<RangeBase, RoutedPropertyChangedEventArgs<double>>( RoutedEvent.Register<RangeBase, RangeBaseValueChangedEventArgs>(
nameof(ValueChanged), RoutingStrategies.Bubble); nameof(ValueChanged), RoutingStrategies.Bubble);
/// <summary> /// <summary>
/// Occurs when the <see cref="Value"/> property changes. /// Occurs when the <see cref="Value"/> property changes.
/// </summary> /// </summary>
public event EventHandler<RoutedPropertyChangedEventArgs<double>>? ValueChanged public event EventHandler<RangeBaseValueChangedEventArgs>? ValueChanged
{ {
add => AddHandler(ValueChangedEvent, value); add => AddHandler(ValueChangedEvent, value);
remove => RemoveHandler(ValueChangedEvent, value); remove => RemoveHandler(ValueChangedEvent, value);
@ -163,7 +163,7 @@ namespace Avalonia.Controls.Primitives
} }
else if (change.Property == ValueProperty) else if (change.Property == ValueProperty)
{ {
var valueChangedEventArgs = new RoutedPropertyChangedEventArgs<double>( var valueChangedEventArgs = new RangeBaseValueChangedEventArgs(
change.GetOldValue<double>(), change.GetOldValue<double>(),
change.GetNewValue<double>(), change.GetNewValue<double>(),
ValueChangedEvent); ValueChangedEvent);

47
src/Avalonia.Controls/Primitives/RangeBaseValueChangedEventArgs.cs

@ -0,0 +1,47 @@
using Avalonia.Interactivity;
namespace Avalonia.Controls.Primitives
{
/// <summary>
/// Provides data specific to a <see cref="RangeBase.ValueChanged"/> event.
/// </summary>
public class RangeBaseValueChangedEventArgs : RoutedEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="RangeBaseValueChangedEventArgs"/> class.
/// </summary>
/// <param name="oldValue">The old value of the range value property.</param>
/// <param name="newValue">The new value of the range value property.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public RangeBaseValueChangedEventArgs(double oldValue, double newValue, RoutedEvent? routedEvent)
: base(routedEvent)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Initializes a new instance of the <see cref="RangeBaseValueChangedEventArgs"/> class.
/// </summary>
/// <param name="oldValue">The old value of the range value property.</param>
/// <param name="newValue">The new value of the range value property.</param>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public RangeBaseValueChangedEventArgs(double oldValue, double newValue, RoutedEvent? routedEvent, object? source)
: base(routedEvent, source)
{
OldValue = oldValue;
NewValue = newValue;
}
/// <summary>
/// Gets the old value of the range value property.
/// </summary>
public double OldValue { get; init; }
/// <summary>
/// Gets the new value of the range value property.
/// </summary>
public double NewValue { get; init; }
}
}

11
src/Avalonia.Controls/TextChangedEventArgs.cs

@ -3,15 +3,24 @@
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
/// Provides data specific to a TextChanged event. /// Provides data specific to a <see cref="TextBox.TextChanged"/> event.
/// </summary> /// </summary>
public class TextChangedEventArgs : RoutedEventArgs public class TextChangedEventArgs : RoutedEventArgs
{ {
/// <summary>
/// Initializes a new instance of the <see cref="TextChangedEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public TextChangedEventArgs(RoutedEvent? routedEvent) public TextChangedEventArgs(RoutedEvent? routedEvent)
: base (routedEvent) : base (routedEvent)
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="TextChangedEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public TextChangedEventArgs(RoutedEvent? routedEvent, Interactive? source) public TextChangedEventArgs(RoutedEvent? routedEvent, Interactive? source)
: base(routedEvent, source) : base(routedEvent, source)
{ {

11
src/Avalonia.Controls/TextChangingEventArgs.cs

@ -3,15 +3,24 @@
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
/// Provides data specific to a TextChanging event. /// Provides data specific to a <see cref="TextBox.TextChanging"/> event.
/// </summary> /// </summary>
public class TextChangingEventArgs : RoutedEventArgs public class TextChangingEventArgs : RoutedEventArgs
{ {
/// <summary>
/// Initializes a new instance of the <see cref="TextChangingEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
public TextChangingEventArgs(RoutedEvent? routedEvent) public TextChangingEventArgs(RoutedEvent? routedEvent)
: base (routedEvent) : base (routedEvent)
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="TextChangingEventArgs"/> class.
/// </summary>
/// <param name="routedEvent">The routed event associated with these event args.</param>
/// <param name="source">The source object that raised the routed event.</param>
public TextChangingEventArgs(RoutedEvent? routedEvent, Interactive? source) public TextChangingEventArgs(RoutedEvent? routedEvent, Interactive? source)
: base(routedEvent, source) : base(routedEvent, source)
{ {

Loading…
Cancel
Save