using System; using Avalonia.Reactive; using Avalonia.VisualTree; namespace Avalonia.Media { /// /// Scale an . /// public sealed class ScaleTransform : Transform { /// /// Defines the property. /// public static readonly StyledProperty ScaleXProperty = AvaloniaProperty.Register(nameof(ScaleX), 1); /// /// Defines the property. /// public static readonly StyledProperty ScaleYProperty = AvaloniaProperty.Register(nameof(ScaleY), 1); /// /// Initializes a new instance of the class. /// public ScaleTransform() { } /// /// Initializes a new instance of the class. /// /// ScaleX /// ScaleY public ScaleTransform(double scaleX, double scaleY) : this() { ScaleX = scaleX; ScaleY = scaleY; } /// /// Gets or sets the ScaleX property. /// public double ScaleX { get { return GetValue(ScaleXProperty); } set { SetValue(ScaleXProperty, value); } } /// /// Gets or sets the ScaleY property. /// public double ScaleY { get { return GetValue(ScaleYProperty); } set { SetValue(ScaleYProperty, value); } } /// /// Gets the transform's . /// public override Matrix Value => Matrix.CreateScale(ScaleX, ScaleY); protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); if (change.Property == ScaleXProperty || change.Property == ScaleYProperty) { RaiseChanged(); } } } }