Browse Source

Fix nits

pull/1461/head
Jumar Macato 8 years ago
parent
commit
4d5bb0b4cc
  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. 16
      src/Avalonia.Animation/PlayState.cs
  8. 7
      src/Avalonia.Animation/RepeatCount.cs
  9. 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 kfList = new List<AnimatorKeyFrame>();
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;
}
}
}
}

2
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; }

4
src/Avalonia.Animation/AnimatorAttribute.cs

@ -2,6 +2,10 @@ using System;
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 Type HandlerType;

8
src/Avalonia.Animation/AnimatorKeyFrame.cs

@ -7,15 +7,17 @@ using Avalonia.Collections;
namespace Avalonia.Animation
{
/// <summary>
/// Defines a KeyFrame that is used for
/// <see cref="Animators"/> objects.
/// </summary>
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;
}
}

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

@ -28,6 +28,12 @@ namespace Avalonia.Animation
/// </summary>
public AvaloniaProperty Property { get; set; }
public Animator()
{
// Invalidate keyframes when changed.
this.CollectionChanged += delegate { _isVerfifiedAndConverted = false; };
}
/// <inheritdoc/>
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));
}
}
}
}

12
src/Avalonia.Animation/DoubleSetter.cs

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

16
src/Avalonia.Animation/PlayState.cs

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

7
src/Avalonia.Animation/RepeatCount.cs

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

7
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
{
/// <summary>
/// Setter that handles <see cref="Transform"/> objects
/// in the target.
/// </summary>
[Animator(typeof(TransformAnimator))]
public class TransformSetter : Setter
public class TransformSetter : AnimationSetter
{
}

Loading…
Cancel
Save