JD2022-TU1/main/tools/framework/JD.Timeline/Mashups/MashupClipWidget.cs

54 lines
No EOL
1.4 KiB
C#

using System.Drawing;
using System.Linq;
using JD.Audio.Annotations;
using JD.Timeline.View.ClipView.Widgets;
using JD.Serialization;
namespace JD.Timeline
{
public class MashupClipWidget : ClipWidget
{
public MashupBlockWidget Content { get; private set; }
public MashupClipWidget(MashupClip model)
: base(model)
{
Content = new MashupBlockWidget(model);
Controls.Add(Content);
}
public new MashupClip Model
{
get { return (MashupClip)base.Model; }
}
public override bool IsResizeAllowed
{
get { return IsMoveAllowed; }
}
protected override SnappingUnit SnappingUnit
{
get { return SnappingUnit.Beat; }
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
SetupBounds();
OnPaintChildControls(e);
}
protected override void SetupBounds()
{
if (Timeline != null)
{
int left = Timeline.TimeToPixel(Model.StartBeat);
int right = Timeline.TimeToPixel(Model.StopBeat);
Bounds = new Rectangle(left, Track.Bounds.Top, right - left, Track.Height);
Content.Timeline = Timeline;
Content.Bounds = Bounds;
}
}
}
}