public RulerView(TLRuler ruler, TimelineView tv) : base(ruler, tv) { Model = ruler; Parent = tv; PanZoomMatrix = new SvgMatrix(FView.Elements.ToList()); MainGroup.Transforms = new SvgTransformCollection(); MainGroup.Transforms.Add(new SvgTranslate(0, 0)); var width = new SvgUnit(SvgUnitType.Percentage, 100); Background.Width = width; Background.Height = 25; Background.ID = "bg"; Background.CustomAttributes["class"] = "ruler"; //register event handlers Background.MouseDown += Background_MouseDown; Background.MouseUp += Background_MouseUp; Background.MouseMove += Background_MouseMove; var caller = Parent.Document.Mapper.Map <ISvgEventCaller>(); PlayButton = SvgDocumentWidget.Load(Path.Combine(TimelineView.ResourcePath, "PlayButton.svg"), caller, 2); StopButton = SvgDocumentWidget.Load(Path.Combine(TimelineView.ResourcePath, "StopButton.svg"), caller, 1); StopButton.X = 25; PlayButton.Click += PlayButton_Click; StopButton.Click += StopButton_Click; TimeCodeLabelBackground.Width = CLeftOffset; TimeCodeLabelBackground.Height = Background.Height; TimeCodeLabelBackground.CustomAttributes["class"] = "ruler"; TimeCodeLabelBackground.MouseDown += Background_MouseDown; TimeCodeLabel.FontSize = 20; TimeCodeLabel.X = 55; TimeCodeLabel.Y = TimeCodeLabel.FontSize; TimeCodeLabel.CustomAttributes["class"] = "time"; TimeCodeLabel.ID = Model.GetID() + "_label"; TimeCodeLabel.Text = "00:00:00:000"; TimeCodeLabel.CustomAttributes["class"] = "time"; TimeCodeLabel.MouseDown += Background_MouseDown; SizeBar.Width = Background.Width; SizeBar.Height = 10; SizeBar.ID = "SizeBar"; SizeBar.Y = Background.Height; SizeBar.MouseDown += Background_MouseDown; SizeBar.MouseMove += Background_MouseMove; SizeBar.MouseUp += Background_MouseUp; MouseTimeLabel.ID = "MouseTimeLabel"; MouseTimeLabel.Y = Height; MouseTimeLabel.FontSize = 14; ClipRect.Width = width; ClipRect.Height = Height; ClipRect.ID = "ClipRect"; //document roots id is "svg". this is where the trackclips are added to RulerClipPath.ID = "svg_clip" + IDGenerator.NewID; RulerClipPath.Children.Add(ClipRect); var uri = new Uri("url(#" + RulerClipPath.ID + ")", UriKind.Relative); MainGroup.ClipPath = uri; NumberGroup.ID = "Ticks"; NumberGroup.Transforms = new SvgTransformCollection(); NumberGroup.Transforms.Add(PanZoomMatrix); PanZoomGroup.ID = "PanZoom"; PanZoomGroup.Transforms = new SvgTransformCollection(); PanZoomGroup.Transforms.Add(PanZoomMatrix); for (int i = 0; i < 70; i++) { var num = new SvgText(i.ToString()); num.FontSize = 20; num.Y = num.FontSize; num.CustomAttributes["class"] = "time hair"; num.Transforms = new SvgTransformCollection(); num.Transforms.Add(new SvgTranslate(i)); num.Transforms.Add(new SvgScale(1 / Timer.PPS, 1)); NumberGroup.Children.Add(num); } LoopRegion.ID = "LoopRegion"; LoopRegion.Y = Background.Height / 4; LoopRegion.Height = Background.Height / 2; LoopRegion.FillOpacity = 0.7f; LoopRegion.CustomAttributes["pointer-events"] = "fill"; LoopRegion.CustomAttributes["class"] = "loop"; LoopRegion.MouseDown += Background_MouseDown; LoopRegion.MouseUp += Parent.Default_MouseUp; LoopRegion.MouseMove += Parent.Default_MouseMove; PanZoomGroup.Children.Add(LoopRegion); LoopStart.ID = "LoopStart"; LoopStart.Width = 1 / Timer.PPS * CHandlerWidth; LoopStart.Height = Background.Height; PanZoomGroup.Children.Add(LoopStart); LoopStart.MouseDown += Background_MouseDown; LoopStart.MouseUp += Parent.Default_MouseUp; LoopStart.MouseMove += Parent.Default_MouseMove; LoopStart.CustomAttributes["pointer-events"] = "fill"; LoopStart.CustomAttributes["class"] = "loopcap"; LoopEnd.ID = "LoopEnd"; LoopEnd.Width = 1 / Timer.PPS * CHandlerWidth; LoopEnd.Height = Background.Height; PanZoomGroup.Children.Add(LoopEnd); LoopEnd.MouseDown += Background_MouseDown; LoopEnd.MouseUp += Parent.Default_MouseUp; LoopEnd.MouseMove += Parent.Default_MouseMove; LoopEnd.CustomAttributes["pointer-events"] = "fill"; LoopEnd.CustomAttributes["class"] = "loopcap"; CreateMenu(); //init scalings PanZoom(0, 0, 0); UpdateScene(); }
public RulerView(TLRuler ruler, TimelineView tv) : base(ruler, tv) { Model = ruler; Parent = tv; PanZoomMatrix = new SvgMatrix(FView.Elements.ToList()); MainGroup.Transforms = new SvgTransformCollection(); MainGroup.Transforms.Add(new SvgTranslate(0, 0)); var width = new SvgUnit(SvgUnitType.Percentage, 100); Background.Width = width; Background.Height = 25; Background.ID = "bg"; Background.CustomAttributes["class"] = "ruler"; //register event handlers Background.MouseDown += Background_MouseDown; Background.MouseUp += Background_MouseUp; Background.MouseMove += Background_MouseMove; var caller = Parent.Document.Mapper.Map<ISvgEventCaller>(); PlayButton = SvgDocumentWidget.Load(Path.Combine(TimelineView.ResourcePath, "PlayButton.svg"), caller, 2); StopButton = SvgDocumentWidget.Load(Path.Combine(TimelineView.ResourcePath, "StopButton.svg"), caller, 1); StopButton.X = 25; PlayButton.Click += PlayButton_Click; StopButton.Click += StopButton_Click; TimeCodeLabelBackground.Width = CLeftOffset; TimeCodeLabelBackground.Height = Background.Height; TimeCodeLabelBackground.CustomAttributes["class"] = "ruler"; TimeCodeLabelBackground.MouseDown += Background_MouseDown; TimeCodeLabel.FontSize = 20; TimeCodeLabel.X = 55; TimeCodeLabel.Y = TimeCodeLabel.FontSize; TimeCodeLabel.CustomAttributes["class"] = "time"; TimeCodeLabel.ID = Model.GetID() + "_label"; TimeCodeLabel.Text = "00:00:00:000"; TimeCodeLabel.CustomAttributes["class"] = "time"; TimeCodeLabel.MouseDown += Background_MouseDown; SizeBar.Width = Background.Width; SizeBar.Height = 10; SizeBar.ID = "SizeBar"; SizeBar.Y = Background.Height; SizeBar.MouseDown += Background_MouseDown; SizeBar.MouseMove += Background_MouseMove; SizeBar.MouseUp += Background_MouseUp; MouseTimeLabel.ID = "MouseTimeLabel"; MouseTimeLabel.Y = Height; MouseTimeLabel.FontSize = 14; ClipRect.Width = width; ClipRect.Height = Height; ClipRect.ID = "ClipRect"; //document roots id is "svg". this is where the trackclips are added to RulerClipPath.ID = "svg_clip" + IDGenerator.NewID; RulerClipPath.Children.Add(ClipRect); var uri = new Uri("url(#" + RulerClipPath.ID + ")", UriKind.Relative); MainGroup.ClipPath = uri; NumberGroup.ID = "Ticks"; NumberGroup.Transforms = new SvgTransformCollection(); NumberGroup.Transforms.Add(PanZoomMatrix); PanZoomGroup.ID = "PanZoom"; PanZoomGroup.Transforms = new SvgTransformCollection(); PanZoomGroup.Transforms.Add(PanZoomMatrix); for (int i=0; i<70; i++) { var num = new SvgText(i.ToString()); num.FontSize = 20; num.Y = num.FontSize; num.CustomAttributes["class"] = "time hair"; num.Transforms = new SvgTransformCollection(); num.Transforms.Add(new SvgTranslate(i)); num.Transforms.Add(new SvgScale(1/Timer.PPS, 1)); NumberGroup.Children.Add(num); } LoopRegion.ID = "LoopRegion"; LoopRegion.Y = Background.Height / 4; LoopRegion.Height = Background.Height / 2; LoopRegion.FillOpacity = 0.7f; LoopRegion.CustomAttributes["pointer-events"] = "fill"; LoopRegion.CustomAttributes["class"] = "loop"; LoopRegion.MouseDown += Background_MouseDown; LoopRegion.MouseUp += Parent.Default_MouseUp; LoopRegion.MouseMove += Parent.Default_MouseMove; PanZoomGroup.Children.Add(LoopRegion); LoopStart.ID = "LoopStart"; LoopStart.Width = 1/Timer.PPS * CHandlerWidth; LoopStart.Height = Background.Height; PanZoomGroup.Children.Add(LoopStart); LoopStart.MouseDown += Background_MouseDown; LoopStart.MouseUp += Parent.Default_MouseUp; LoopStart.MouseMove += Parent.Default_MouseMove; LoopStart.CustomAttributes["pointer-events"] = "fill"; LoopStart.CustomAttributes["class"] = "loopcap"; LoopEnd.ID = "LoopEnd"; LoopEnd.Width = 1/Timer.PPS * CHandlerWidth; LoopEnd.Height = Background.Height; PanZoomGroup.Children.Add(LoopEnd); LoopEnd.MouseDown += Background_MouseDown; LoopEnd.MouseUp += Parent.Default_MouseUp; LoopEnd.MouseMove += Parent.Default_MouseMove; LoopEnd.CustomAttributes["pointer-events"] = "fill"; LoopEnd.CustomAttributes["class"] = "loopcap"; CreateMenu(); //init scalings PanZoom(0, 0, 0); UpdateScene(); }