public Timeliner(TLContext context) { Context = context; TimelineModel = new TLDocument("", @"timeline.xml"); Shell.Instance.Root = TimelineModel; TimelineModel.CreateMapper(context.MappingRegistry); //only after mapper and root are set TimelineModel.Initialize(); var commandHistory = TimelineModel.Mapper.Map<ICommandHistory>(); TimelineView = new TimelineView(TimelineModel, commandHistory, Timer); TimelineModel.Tracks.Added += Timeline_Tracks_Added; TimelineModel.Tracks.Removed += Timeline_Tracks_Removed; TimelineModel.Tracks.OrderChanged += Timeline_Tracks_OrderChanged; TimelineView.Tracks.OrderChanged += TimelineView_Tracks_OrderChanged; }
public Timeliner(TLContext context) { Context = context; TimelineModel = new TLDocument("", @"timeline.xml"); Shell.Instance.Root = TimelineModel; TimelineModel.CreateMapper(context.MappingRegistry); //only after mapper and root are set TimelineModel.Initialize(); var commandHistory = TimelineModel.Mapper.Map <ICommandHistory>(); TimelineView = new TimelineView(TimelineModel, commandHistory, Timer); TimelineModel.Tracks.Added += Timeline_Tracks_Added; TimelineModel.Tracks.Removed += Timeline_Tracks_Removed; TimelineModel.Tracks.OrderChanged += Timeline_Tracks_OrderChanged; TimelineView.Tracks.OrderChanged += TimelineView_Tracks_OrderChanged; }
public static TLDocument FromFile(string path, Serializer serializer) { //load data of this document from disk using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { // We can handle empty files too var document = new TLDocument(Path.GetFileName(path), path); if (fileStream.Length > 0) { var xml = XElement.Load(fileStream); if (xml.IsEmpty) { return(document); } document = FromXML(xml, serializer); } return(document); } }
public TimelineView(TLDocument tl, ICommandHistory history, Timer timer) { History = history; History.CommandInserted += History_Changed; History.Undone += History_Changed; History.Redone += History_Changed; Document = tl; Timer = timer; //replace id manager before any svg element was added var caller = Document.Mapper.Map <ISvgEventCaller>(); var manager = new SvgIdManager(SvgRoot, caller, Document.Mapper.Map <RemoteContext>()); SvgRoot.ID = "svg"; SvgRoot.OverwriteIdManager(manager); Background.Width = new SvgUnit(SvgUnitType.Percentage, 100); Background.Height = 500; Background.ID = Document.GetID() + "_Background"; Background.Opacity = 0; Background.MouseDown += Default_MouseDown; Background.MouseMove += Default_MouseMove; Background.MouseUp += Default_MouseUp; Selection.ID = "Selection"; Selection.CustomAttributes["pointer-events"] = "none"; Selection.CustomAttributes["class"] = "selection"; Ruler = new RulerView(Document.Ruler, this); MouseTimeLine.ID = "MouseTime"; MouseTimeLine.StartX = 0; MouseTimeLine.StartY = 0; MouseTimeLine.EndX = 0; TimeBar.ID = "Timebar"; TimeBar.Y = -Ruler.Height; TimeBar.X = -1; TimeBar.Width = 2; TimeBar.MouseDown += Default_MouseDown; TimeBar.MouseMove += Default_MouseMove; TimeBar.MouseUp += Default_MouseUp; MainMenu = new SvgMenuWidget(120); MainMenu.ID = "MainMenu"; var addValueTrack = new SvgButtonWidget(0, 20, "Add Value Track"); addValueTrack.ValueChanged += AddValueTrack; var addStringTrack = new SvgButtonWidget(0, 20, "Add String Track"); addStringTrack.ValueChanged += AddStringTrack; MainMenu.AddItem(addValueTrack, 0); MainMenu.AddItem(addStringTrack, 1); FRulerGroup.ID = "Ruler"; FRulerGroup.CustomAttributes["class"] = "fixed"; FRulerGroup.Transforms = new SvgTransformCollection(); FRulerGroup.Transforms.Add(new SvgTranslate(0, 0)); FTrackGroup.ID = "Tracks"; FTrackGroup.Transforms = new SvgTransformCollection(); FOverlaysGroup.ID = "Overlays"; FOverlaysGroup.Transforms = new SvgTransformCollection(); //initialize svg tree BuildSVGRoot(); Syncer = Tracks.SyncWith(Document.Tracks, tm => { TrackView tv; if (tm is TLValueTrack) { tv = new ValueTrackView(tm as TLValueTrack, this, Ruler); } else if (tm is TLStringTrack) { tv = new StringTrackView(tm as TLStringTrack, this, Ruler); } else { tv = new AudioTrackView(tm as TLAudioTrack, this, Ruler); } if (ActiveTrack == null) { ActiveTrack = tv; } tv.AddToSceneGraphAt(FTrackGroup); //update Order on all tracks below the one added var order = tv.Model.Order.Value; foreach (var track in Tracks.Where(x => x.Model.Order.Value >= order)) { track.Model.Order.Value += 1; } return(tv); }, tv => { var order = tv.Model.Order.Value; tv.Dispose(); //update Order on all tracks below the one removed foreach (var track in Tracks.Where(x => x.Model.Order.Value > order)) { track.Model.Order.Value -= 1; } }); }
public static TLDocument FromFile(string path, Serializer serializer) { //load data of this document from disk using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { // We can handle empty files too var document = new TLDocument(Path.GetFileName(path), path); if (fileStream.Length > 0) { var xml = XElement.Load(fileStream); if(xml.IsEmpty) { return document; } document = FromXML(xml, serializer); } return document; } }