void History_Changed(object sender, EventArgs <Command> e) { UpdateScene(); if (!Tracks.Contains(ActiveTrack)) { if (Tracks.Count > 0) { ActiveTrack = Tracks[0]; } else { ActiveTrack = null; } } }
public PanZoomMenuHandler(TLViewBase view, string sessionID) : base(view, sessionID) { if (Instance is RulerView) { FRulerView = Instance as RulerView; FTimelineView = FRulerView.Parent; } else if (Instance is TimelineView) { FTimelineView = Instance as TimelineView; FRulerView = FTimelineView.Ruler; } else if (Instance is TrackView) { FTrackView = Instance as TrackView; FTimelineView = FTrackView.Parent; FRulerView = FTimelineView.Ruler; } }
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; } }); }
//gets the right mouse handler protected override IMouseEventHandler GetMouseHandler(object sender, MouseArg e) { if (sender is IMouseEventHandler) { return(sender as IMouseEventHandler); } else if (sender is TrackView) { ActiveTrack = sender as TrackView; HideMenus(); if ((e.Button == 1) && (sender is TrackView)) { return(new SelectionMouseHandler(sender as TrackView, e.SessionID)); } else if (e.Button == 3) { return(new PanZoomMenuHandler(sender as TrackView, e.SessionID)); } else { return(null); } } else if ((sender == Ruler.Background) || (sender == Ruler.SizeBar)) { HideMenus(); if (e.Button == 1) { return(new SeekHandler(Ruler, e.SessionID)); } else if (e.Button == 3) { return(new PanZoomMenuHandler(Ruler, e.SessionID)); } else { return(null); } } else if (sender == Ruler.LoopStart) { HideMenus(); if (e.Button == 1) { return(new RulerMouseHandler(Ruler, Ruler.Model.LoopStart, null, e.SessionID)); } else { return(null); } } else if (sender == Ruler.LoopEnd) { HideMenus(); if (e.Button == 1) { return(new RulerMouseHandler(Ruler, null, Ruler.Model.LoopEnd, e.SessionID)); } else { return(null); } } else if (sender == Ruler.LoopRegion) { HideMenus(); if (e.Button == 1) { return(new RulerMouseHandler(Ruler, Ruler.Model.LoopStart, Ruler.Model.LoopEnd, e.SessionID)); } else if (e.Button == 3) { return(new PanZoomMenuHandler(Ruler, e.SessionID)); } else { return(null); } } else if (sender is KeyframeView) { HideMenus(); return(new KeyframeMouseHandler(sender as KeyframeView, e.SessionID)); } else if (sender == TimeBar) { HideMenus(); return(new TimeBarHandler(this, e.SessionID)); } else if (sender == Background) { HideMenus(); if ((e.Button == 1) && (ActiveTrack != null)) { return(new SelectionMouseHandler(ActiveTrack, e.SessionID)); } else if (e.Button == 3) { return(new PanZoomMenuHandler(this, e.SessionID)); } else { return(null); } } else { HideMenus(); return(null); } }