public override void Build(IGroup group, DXCanvas canvas) { TextBlocks = new List <TextEntry>(); DynamicMesh meshBuilder = canvas.CreateMesh(DXCanvas.MeshType.Tris); DynamicMesh lineBuilder = canvas.CreateMesh(DXCanvas.MeshType.Lines); MaxHeight = group.Height; Build(DataContext, DataContext, 0.0, meshBuilder, lineBuilder); Mesh = meshBuilder.Freeze(canvas.RenderDevice); Lines = lineBuilder.Freeze(canvas.RenderDevice); double duration = (group.Finish - group.Start).TotalSeconds; Matrix localTransform = new Matrix(); localTransform.Scale((DataContext.Finish - DataContext.Start).TotalSeconds / duration, 1.0); localTransform.Translate((DataContext.Start - group.Start).TotalSeconds / duration, 0.0); if (Mesh != null) { Mesh.LocalTransform = localTransform; } if (Lines != null) { Lines.LocalTransform = localTransform; } TextBlocks.Sort((a, b) => - a.Width.CompareTo(b.Width)); }
public override void Build(IGroup group, DXCanvas canvas) { DynamicMesh meshBuilder = canvas.CreateMesh(DXCanvas.MeshType.Tris); DynamicMesh lineBuilder = canvas.CreateMesh(DXCanvas.MeshType.Lines); double duration = (group.Finish - group.Start).TotalSeconds; ILine line = DataContext; double maxValue = line.Points.Max(p => p.Value); List <Point> points = line.Points.ConvertAll(p => new Point((p.Key - group.Start).TotalSeconds / duration, 1.0 - p.Value / maxValue)); for (int i = 0; i < points.Count - 1; ++i) { lineBuilder.AddLine(points[i], points[i + 1], line.StrokeColor); } Mesh = meshBuilder.Freeze(canvas.RenderDevice); Lines = lineBuilder.Freeze(canvas.RenderDevice); }