JD2022-TU1/main/tools/framework/JD.Application.TeaBox/View/Tracks/OverlappingTrack.cs

83 lines
No EOL
2.2 KiB
C#

using JD.Audio.Sound;
using System.Linq;
using JD.Sequencers.Times;
using JD.Sequencers.Windowlesses;
namespace JD.Application.View.Tracks
{
public enum OverlapMode
{
AllTracks,
WaveOnly
};
/// <summary>
/// TrackView control works only with non overlapping tracks, those tracks are paint behind or in front of other tracks.
/// </summary>
public class OverlappingTrack : WindowlessControl
{
private readonly global::JD.Sequencers.Times.Timeline _timeline;
private Wave _wave;
private static OverlapMode _overlapMode = OverlapMode.AllTracks;
public static OverlapMode OverlapMode
{
get { return _overlapMode; }
set { _overlapMode = value; }
}
/// <summary>
/// Constructor.
/// </summary>
public OverlappingTrack(global::JD.Sequencers.Times.Timeline timeline)
{
_timeline = timeline;
}
protected global::JD.Sequencers.Times.Timeline Timeline
{
get { return _timeline; }
}
public Wave Wave
{
get { return _wave; }
set { _wave = value; }
}
/// <summary>
/// Docks to match the background of the tracks in the track view.
/// </summary>
public void UpdateBounds(TrackView parent)
{
var bounds = parent.Bounds;
switch (_overlapMode)
{
case OverlapMode.AllTracks:
{
var bottomTrack = parent.GetTracks().LastOrDefault();
if (bottomTrack != null)
{
bounds.Height = bottomTrack.Bounds.Bottom - bounds.Y;
}
}
break;
case OverlapMode.WaveOnly:
{
var waveTrack = parent.GetTracks().OfType<WaveTrack>().FirstOrDefault();
if (waveTrack != null)
{
bounds.Height = waveTrack.Bounds.Height;
}
}
break;
}
Bounds = bounds;
}
}
}