Browse Source

Fix nits

pull/1461/head
Jumar Macato 8 years ago
parent
commit
d196a431a8
  1. 8
      src/Avalonia.Animation/Animation.cs
  2. 2
      src/Avalonia.Animation/AnimationSetter.cs
  3. 4
      src/Avalonia.Animation/AnimatorAttribute.cs
  4. 8
      src/Avalonia.Animation/AnimatorKeyFrame.cs
  5. 7
      src/Avalonia.Animation/Animator`1.cs
  6. 12
      src/Avalonia.Animation/DoubleSetter.cs
  7. 1
      src/Avalonia.Animation/IAnimator.cs
  8. 16
      src/Avalonia.Animation/PlayState.cs
  9. 7
      src/Avalonia.Animation/RepeatCount.cs
  10. 7
      src/Avalonia.Visuals/Animation/TransformSetter.cs

8
src/Avalonia.Animation/Animation.cs

@ -63,12 +63,10 @@ namespace Avalonia.Animation
var handlerList = new List<(Type, AvaloniaProperty)>(); var handlerList = new List<(Type, AvaloniaProperty)>();
var kfList = new List<AnimatorKeyFrame>(); var kfList = new List<AnimatorKeyFrame>();
foreach (var keyframe in this) foreach (var keyframe in this)
{ {
foreach (var setter in keyframe) foreach (var setter in keyframe)
{ {
var custAttr = setter.GetType() var custAttr = setter.GetType()
.GetCustomAttributes() .GetCustomAttributes()
.Where(p => p.GetType() == typeof(AnimatorAttribute)); .Where(p => p.GetType() == typeof(AnimatorAttribute));
@ -106,8 +104,8 @@ namespace Avalonia.Animation
foreach (var kf in kfList) foreach (var kf in kfList)
{ {
var parent = newAnimatorInstances.Where(p=>p.handler == kf.Handler && var parent = newAnimatorInstances.Where(p => p.handler == kf.Handler &&
p.prop == kf.Property) p.prop == kf.Property)
.First(); .First();
parent.inst.Add(kf); parent.inst.Add(kf);
} }
@ -144,4 +142,4 @@ namespace Avalonia.Animation
return this; return this;
} }
} }
} }

2
src/Avalonia.Animation/AnimationSetter.cs

@ -9,7 +9,7 @@ using Avalonia.Data;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
public abstract class Setter : IAnimationSetter public abstract class AnimationSetter : IAnimationSetter
{ {
public AvaloniaProperty Property { get; set; } public AvaloniaProperty Property { get; set; }
public object Value { get; set; } public object Value { get; set; }

4
src/Avalonia.Animation/AnimatorAttribute.cs

@ -2,6 +2,10 @@ using System;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
/// <summary>
/// Attribute for <see cref="IAnimationSetter"/> objects
/// that maps the setter to it's <see cref="Animator{T}"/>.
/// </summary>
public class AnimatorAttribute : Attribute public class AnimatorAttribute : Attribute
{ {
public Type HandlerType; public Type HandlerType;

8
src/Avalonia.Animation/AnimatorKeyFrame.cs

@ -7,15 +7,17 @@ using Avalonia.Collections;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
/// <summary>
/// Defines a KeyFrame that is used for
/// <see cref="Animators"/> objects.
/// </summary>
public class AnimatorKeyFrame public class AnimatorKeyFrame
{ {
public Type Handler; public Type Handler;
public Cue Cue; public Cue Cue;
public TimeSpan KeyTime; public TimeSpan KeyTime;
internal bool timeSpanSet, cueSet; internal bool timeSpanSet, cueSet;
internal AvaloniaProperty Property; public AvaloniaProperty Property;
public object Value; public object Value;
} }
} }

7
src/Avalonia.Animation/Animator`1.cs

@ -28,6 +28,12 @@ namespace Avalonia.Animation
/// </summary> /// </summary>
public AvaloniaProperty Property { get; set; } public AvaloniaProperty Property { get; set; }
public Animator()
{
// Invalidate keyframes when changed.
this.CollectionChanged += delegate { _isVerfifiedAndConverted = false; };
}
/// <inheritdoc/> /// <inheritdoc/>
public virtual IDisposable Apply(Animation animation, Animatable control, IObservable<bool> obsMatch) public virtual IDisposable Apply(Animation animation, Animatable control, IObservable<bool> obsMatch)
{ {
@ -182,6 +188,5 @@ namespace Avalonia.Animation
convertedKeyframes.Add(1.0d, (default(T), true)); convertedKeyframes.Add(1.0d, (default(T), true));
} }
} }
} }
} }

12
src/Avalonia.Animation/DoubleSetter.cs

@ -9,9 +9,13 @@ using Avalonia.Data;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
/// <summary>
/// Setter that handles <see cref="double"/> properties
/// in the target.
/// </summary>
[Animator(typeof(DoubleAnimator))] [Animator(typeof(DoubleAnimator))]
public class DoubleSetter : Setter public class DoubleSetter : AnimationSetter
{ {
} }
} }

1
src/Avalonia.Animation/IAnimator.cs

@ -18,6 +18,5 @@ namespace Avalonia.Animation
/// Applies the current KeyFrame group to the specified control. /// Applies the current KeyFrame group to the specified control.
/// </summary> /// </summary>
IDisposable Apply(Animation animation, Animatable control, IObservable<bool> obsMatch); IDisposable Apply(Animation animation, Animatable control, IObservable<bool> obsMatch);
} }
} }

16
src/Avalonia.Animation/PlayState.cs

@ -4,10 +4,24 @@ using System.Text;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
/// <summary>
/// Determines the playback state of an animation.
/// </summary>
public enum PlayState public enum PlayState
{ {
/// <summary>
/// The animation is running.
/// </summary>
Run, Run,
/// <summary>
/// The animation is paused.
/// </summary>
Pause, Pause,
/// <summary>
/// The animation is stopped.
/// </summary>
Stop Stop
} }
} }

7
src/Avalonia.Animation/RepeatCount.cs

@ -21,13 +21,13 @@ namespace Avalonia.Animation
} }
/// <summary> /// <summary>
/// Determines the repeat behavior of an animation. /// Determines the number of iterations of an animation.
/// Also defines its repeat behavior.
/// </summary> /// </summary>
[TypeConverter(typeof(RepeatCountTypeConverter))] [TypeConverter(typeof(RepeatCountTypeConverter))]
public struct RepeatCount : IEquatable<RepeatCount> public struct RepeatCount : IEquatable<RepeatCount>
{ {
private readonly RepeatType _type; private readonly RepeatType _type;
private readonly ulong _value; private readonly ulong _value;
/// <summary> /// <summary>
@ -61,7 +61,6 @@ namespace Avalonia.Animation
/// </summary> /// </summary>
public static RepeatCount Loop => new RepeatCount(0, RepeatType.Loop); public static RepeatCount Loop => new RepeatCount(0, RepeatType.Loop);
/// <summary> /// <summary>
/// Gets an instance of <see cref="RepeatCount"/> that indicates that an animation /// Gets an instance of <see cref="RepeatCount"/> that indicates that an animation
/// should not repeat. /// should not repeat.
@ -189,7 +188,7 @@ namespace Avalonia.Animation
else else
{ {
if(s.StartsWith("-")) 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); var value = ulong.Parse(s, CultureInfo.InvariantCulture);

7
src/Avalonia.Visuals/Animation/TransformSetter.cs

@ -6,11 +6,16 @@ using System.Reactive.Linq;
using System.Diagnostics; using System.Diagnostics;
using Avalonia.Animation.Utils; using Avalonia.Animation.Utils;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Media;
namespace Avalonia.Animation namespace Avalonia.Animation
{ {
/// <summary>
/// Setter that handles <see cref="Transform"/> objects
/// in the target.
/// </summary>
[Animator(typeof(TransformAnimator))] [Animator(typeof(TransformAnimator))]
public class TransformSetter : Setter public class TransformSetter : AnimationSetter
{ {
} }

Loading…
Cancel
Save