69 lines
No EOL
1.9 KiB
C#
69 lines
No EOL
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using JD.Application.View.Timeline;
|
|
using JD.Serialization;
|
|
|
|
namespace JD.Timeline.View.ClipView.Widgets
|
|
{
|
|
public class AnimationClipWidget : ClipWithActorWidget
|
|
{
|
|
public AnimationClipWidget(AnimationClip model)
|
|
: base(model)
|
|
{
|
|
}
|
|
|
|
public new AnimationClip Model
|
|
{
|
|
get { return (AnimationClip)base.Model; }
|
|
}
|
|
|
|
public override string ToolTipText
|
|
{
|
|
get
|
|
{
|
|
return string.Concat(base.ToolTipText, "\nAnimation: ", Model.AnimationName);
|
|
}
|
|
}
|
|
|
|
protected override void DrawActorName(PaintEventArgs e)
|
|
{
|
|
base.DrawActorName(e);
|
|
DrawText(e.Graphics, "Animation: ", Model.AnimationName, 1);
|
|
}
|
|
|
|
protected override void FillBackground(Graphics graphics, Rectangle bounds)
|
|
{
|
|
base.FillBackground(graphics, bounds);
|
|
PaintLoopLines(graphics);
|
|
}
|
|
|
|
private void PaintLoopLines(Graphics graphics)
|
|
{
|
|
foreach (var frame in EnumerateLoopFrames)
|
|
{
|
|
int x = Timeline.PixelFromFrame(frame);
|
|
graphics.DrawLine(Pens.DarkRed, x, Bounds.Top, x, Bounds.Bottom - 1);
|
|
}
|
|
}
|
|
|
|
protected IEnumerable<float> EnumerateLoopFrames
|
|
{
|
|
get
|
|
{
|
|
var animation = Model.GetAnimation();
|
|
if (animation != null)
|
|
{
|
|
for (int frame = Model.StartFrame + animation.Duration; frame < Model.StopFrame; frame += animation.Duration)
|
|
{
|
|
yield return frame;
|
|
if (!Model.Loop)
|
|
{
|
|
yield break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |