112 lines
3.6 KiB
C#
112 lines
3.6 KiB
C#
using JD.Timeline.View.ClipView;
|
|
using TeaBox.Actions;
|
|
using TeaBox.Gui;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using JD.Audio.SoundPlayer;
|
|
using JD.Interfaces.Player;
|
|
using JD.MessageService;
|
|
using JD.Sequencers.Windowlesses;
|
|
using JD.Serialization;
|
|
using TeaBox.Core.Source.Gui;
|
|
|
|
|
|
namespace JD.Timeline.View
|
|
{
|
|
/// <summary>
|
|
/// The main control is composed of a tree view to manage tracks (rename, reorder, ...) and the main ClipView that allows manage clips (add clip, move, delete, ...)
|
|
/// </summary>
|
|
public class TapeMainControl : UserControl, IDelegatedActionRouter
|
|
{
|
|
#region Variables
|
|
|
|
private readonly SplitContainer _splitContainer;
|
|
private readonly TrackTreeView.TrackTreeView _treeView;
|
|
private readonly ClipViewControl _clipView;
|
|
private readonly InformationBox _informationBox = new InformationBox();
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public TapeMainControl(Tape tape, IPlayer player)
|
|
{
|
|
_clipView = new ClipViewControl(tape)
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
Player = player,
|
|
};
|
|
_treeView = new TrackTreeView.TrackTreeView(tape, _clipView.TrackView) { Dock = DockStyle.Fill };
|
|
_splitContainer = new SplitContainer { Dock = DockStyle.Fill };
|
|
_splitContainer.FixedPanel = FixedPanel.Panel1;
|
|
_splitContainer.SplitterDistance = 150;
|
|
_splitContainer.Panel1.Controls.Add(_treeView);
|
|
_splitContainer.Panel2.Controls.Add(_clipView);
|
|
_splitContainer.BackColor = Color.FromArgb(105, 105, 105);
|
|
Controls.Add(_splitContainer);
|
|
|
|
tape.PropertyChanged += tape_Changed;
|
|
tape_Changed(null, null);
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
_clipView.Tape.PropertyChanged -= tape_Changed;
|
|
}
|
|
|
|
// START HACK
|
|
// When switching to AvalonDocking we encountered a showstopper when closing tapes
|
|
// ClipView seems to be disposed before cleaning the tape's children, but is not removed,
|
|
// resulting in a cross-thread operation from the main thread to a disposed thread, crashing
|
|
// the tool. So for now we make sure it is properly disposed and removed manually.
|
|
_clipView.Dispose();
|
|
Controls.Remove(_clipView);
|
|
// END HACK
|
|
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public IEnumerable<object> GetDelegatedActionTarget()
|
|
{
|
|
yield return _treeView;
|
|
yield return _clipView;
|
|
}
|
|
|
|
public Selection Selection
|
|
{
|
|
get { return _clipView.TrackView.Selection; }
|
|
}
|
|
|
|
public TrackTreeView.TrackTreeView TrackTreeView
|
|
{
|
|
get { return _treeView; }
|
|
}
|
|
|
|
public ClipViewControl ClipView
|
|
{
|
|
get { return _clipView; }
|
|
}
|
|
|
|
void tape_Changed(object sender, System.EventArgs e)
|
|
{
|
|
if (_clipView.Tape.LoadingError != null && !Controls.Contains(_informationBox))
|
|
{
|
|
_informationBox.Dock = DockStyle.Top;
|
|
_informationBox.Icon = SystemIconType.Error;
|
|
_informationBox.UseInformationColor();
|
|
_informationBox.Text = _clipView.Tape.LoadingError.Message;
|
|
Controls.Clear();
|
|
Controls.Add(_informationBox);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|