A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

80 lines
2.0 KiB

using System;
using System.Collections.Generic;
using Avalonia.Collections;
using Avalonia.Metadata;
namespace Avalonia.Animation
{
internal enum KeyFrameTimingMode
{
TimeSpan = 1,
Cue
}
/// <summary>
/// Stores data regarding a specific key
/// point and value in an animation.
/// </summary>
public class KeyFrame : AvaloniaObject
{
private TimeSpan _ktimeSpan;
private Cue _kCue;
public KeyFrame()
{
}
/// <summary>
/// Gets the setters of <see cref="KeyFrame"/>.
/// </summary>
[Content]
public AvaloniaList<IAnimationSetter> Setters { get; } = new AvaloniaList<IAnimationSetter>();
internal KeyFrameTimingMode TimingMode { get; private set; }
/// <summary>
/// Gets or sets the key time of this <see cref="KeyFrame"/>.
/// </summary>
/// <value>The key time.</value>
public TimeSpan KeyTime
{
get
{
return _ktimeSpan;
}
set
{
if (TimingMode == KeyFrameTimingMode.Cue)
{
throw new InvalidOperationException($"You can only set either {nameof(KeyTime)} or {nameof(Cue)}.");
}
TimingMode = KeyFrameTimingMode.TimeSpan;
_ktimeSpan = value;
}
}
/// <summary>
/// Gets or sets the cue of this <see cref="KeyFrame"/>.
/// </summary>
/// <value>The cue.</value>
public Cue Cue
{
get
{
return _kCue;
}
set
{
if (TimingMode == KeyFrameTimingMode.TimeSpan)
{
throw new InvalidOperationException($"You can only set either {nameof(KeyTime)} or {nameof(Cue)}.");
}
TimingMode = KeyFrameTimingMode.Cue;
_kCue = value;
}
}
}
}