From 4d5bb0b4cced8510281427f5465339d4fb564d2c Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 25 May 2018 11:55:45 +0800 Subject: [PATCH] Fix nits --- src/Avalonia.Animation/Animation.cs | 8 +++----- src/Avalonia.Animation/AnimationSetter.cs | 2 +- src/Avalonia.Animation/AnimatorAttribute.cs | 4 ++++ src/Avalonia.Animation/AnimatorKeyFrame.cs | 8 +++++--- src/Avalonia.Animation/Animator`1.cs | 7 ++++++- src/Avalonia.Animation/DoubleSetter.cs | 12 ++++++++---- src/Avalonia.Animation/PlayState.cs | 16 +++++++++++++++- src/Avalonia.Animation/RepeatCount.cs | 7 +++---- .../Animation/TransformSetter.cs | 7 ++++++- 9 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 1ef28490f4..525be53fc2 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -63,12 +63,10 @@ namespace Avalonia.Animation var handlerList = new List<(Type, AvaloniaProperty)>(); var kfList = new List(); - foreach (var keyframe in this) { foreach (var setter in keyframe) { - var custAttr = setter.GetType() .GetCustomAttributes() .Where(p => p.GetType() == typeof(AnimatorAttribute)); @@ -106,8 +104,8 @@ namespace Avalonia.Animation foreach (var kf in kfList) { - var parent = newAnimatorInstances.Where(p=>p.handler == kf.Handler && - p.prop == kf.Property) + var parent = newAnimatorInstances.Where(p => p.handler == kf.Handler && + p.prop == kf.Property) .First(); parent.inst.Add(kf); } @@ -144,4 +142,4 @@ namespace Avalonia.Animation return this; } } -} +} \ No newline at end of file diff --git a/src/Avalonia.Animation/AnimationSetter.cs b/src/Avalonia.Animation/AnimationSetter.cs index bd6d395c20..1194e4606b 100644 --- a/src/Avalonia.Animation/AnimationSetter.cs +++ b/src/Avalonia.Animation/AnimationSetter.cs @@ -9,7 +9,7 @@ using Avalonia.Data; namespace Avalonia.Animation { - public abstract class Setter : IAnimationSetter + public abstract class AnimationSetter : IAnimationSetter { public AvaloniaProperty Property { get; set; } public object Value { get; set; } diff --git a/src/Avalonia.Animation/AnimatorAttribute.cs b/src/Avalonia.Animation/AnimatorAttribute.cs index 41fa78ec53..58ee823a87 100644 --- a/src/Avalonia.Animation/AnimatorAttribute.cs +++ b/src/Avalonia.Animation/AnimatorAttribute.cs @@ -2,6 +2,10 @@ using System; namespace Avalonia.Animation { + /// + /// Attribute for objects + /// that maps the setter to it's . + /// public class AnimatorAttribute : Attribute { public Type HandlerType; diff --git a/src/Avalonia.Animation/AnimatorKeyFrame.cs b/src/Avalonia.Animation/AnimatorKeyFrame.cs index 8892dbc14b..875bf761c4 100644 --- a/src/Avalonia.Animation/AnimatorKeyFrame.cs +++ b/src/Avalonia.Animation/AnimatorKeyFrame.cs @@ -7,15 +7,17 @@ using Avalonia.Collections; namespace Avalonia.Animation { - + /// + /// Defines a KeyFrame that is used for + /// objects. + /// public class AnimatorKeyFrame { public Type Handler; public Cue Cue; public TimeSpan KeyTime; internal bool timeSpanSet, cueSet; - internal AvaloniaProperty Property; + public AvaloniaProperty Property; public object Value; } - } diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index bc848c5945..6d4ae7d8e2 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -28,6 +28,12 @@ namespace Avalonia.Animation /// public AvaloniaProperty Property { get; set; } + public Animator() + { + // Invalidate keyframes when changed. + this.CollectionChanged += delegate { _isVerfifiedAndConverted = false; }; + } + /// public virtual IDisposable Apply(Animation animation, Animatable control, IObservable obsMatch) { @@ -182,6 +188,5 @@ namespace Avalonia.Animation convertedKeyframes.Add(1.0d, (default(T), true)); } } - } } \ No newline at end of file diff --git a/src/Avalonia.Animation/DoubleSetter.cs b/src/Avalonia.Animation/DoubleSetter.cs index cf5c685f82..e524324a8c 100644 --- a/src/Avalonia.Animation/DoubleSetter.cs +++ b/src/Avalonia.Animation/DoubleSetter.cs @@ -9,9 +9,13 @@ using Avalonia.Data; namespace Avalonia.Animation { + /// + /// Setter that handles properties + /// in the target. + /// [Animator(typeof(DoubleAnimator))] - public class DoubleSetter : Setter - { - + public class DoubleSetter : AnimationSetter + { + } -} +} \ No newline at end of file diff --git a/src/Avalonia.Animation/PlayState.cs b/src/Avalonia.Animation/PlayState.cs index 51933703c2..a3a6eb34d7 100644 --- a/src/Avalonia.Animation/PlayState.cs +++ b/src/Avalonia.Animation/PlayState.cs @@ -4,10 +4,24 @@ using System.Text; namespace Avalonia.Animation { + /// + /// Determines the playback state of an animation. + /// public enum PlayState { + /// + /// The animation is running. + /// Run, + + /// + /// The animation is paused. + /// Pause, + + /// + /// The animation is stopped. + /// Stop } -} +} \ No newline at end of file diff --git a/src/Avalonia.Animation/RepeatCount.cs b/src/Avalonia.Animation/RepeatCount.cs index 0634573366..2050513df2 100644 --- a/src/Avalonia.Animation/RepeatCount.cs +++ b/src/Avalonia.Animation/RepeatCount.cs @@ -21,13 +21,13 @@ namespace Avalonia.Animation } /// - /// Determines the repeat behavior of an animation. + /// Determines the number of iterations of an animation. + /// Also defines its repeat behavior. /// [TypeConverter(typeof(RepeatCountTypeConverter))] public struct RepeatCount : IEquatable { private readonly RepeatType _type; - private readonly ulong _value; /// @@ -61,7 +61,6 @@ namespace Avalonia.Animation /// public static RepeatCount Loop => new RepeatCount(0, RepeatType.Loop); - /// /// Gets an instance of that indicates that an animation /// should not repeat. @@ -189,7 +188,7 @@ namespace Avalonia.Animation else { if(s.StartsWith("-")) - throw new InvalidCastException("RepeatCount iterations can't be a negative number."); + throw new InvalidCastException("RepeatCount can't be a negative number."); var value = ulong.Parse(s, CultureInfo.InvariantCulture); diff --git a/src/Avalonia.Visuals/Animation/TransformSetter.cs b/src/Avalonia.Visuals/Animation/TransformSetter.cs index f8b8d588fc..1c0319514e 100644 --- a/src/Avalonia.Visuals/Animation/TransformSetter.cs +++ b/src/Avalonia.Visuals/Animation/TransformSetter.cs @@ -6,11 +6,16 @@ using System.Reactive.Linq; using System.Diagnostics; using Avalonia.Animation.Utils; using Avalonia.Data; +using Avalonia.Media; namespace Avalonia.Animation { + /// + /// Setter that handles objects + /// in the target. + /// [Animator(typeof(TransformAnimator))] - public class TransformSetter : Setter + public class TransformSetter : AnimationSetter { }