using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace QuikDawEditor; public class WaveFormPresenter : Canvas { private double ContinueTo = 100 + 20; Pen linePenMeasure = new Pen(Brushes.White, 1); Pen linePenBeat = new Pen(Brushes.White, 0.6); SolidColorBrush NumbersBrush = Brushes.White; double beatsPerSecond { get { return BeatsPerMinute / 60; } } protected override void OnRender(DrawingContext dc) { if (editingProject == null) return; double lineStart = this.ActualHeight / 2; double textY = this.ActualHeight / 2; int stride = editingProject.ViewXZoomFac < 0.6 ? 40 : (editingProject.ViewXZoomFac < 1 ? 20 : 10); int midStride = stride / 2; bool showMid = editingProject.ViewXZoomFac >= 1; bool showSecs = editingProject.ViewXZoomFac >= 3; bool showSubSecs = editingProject.ViewXZoomFac > 30; for (int secNo = 1; secNo < ContinueTo; secNo++) { double x = Math.Floor(secNo * PixelsPerSecond * editingProject.ViewXZoomFac); int oneBasedNo = secNo + 1; if (oneBasedNo % stride == 0) { textY = 0; dc.DrawLine(linePenMeasure, new Point(x, 0), new Point(x, this.ActualHeight)); } else { if (showMid) { if (oneBasedNo % midStride == 0) { textY = Math.Floor(this.ActualHeight / 2 - 1); lineStart = Math.Floor(this.ActualHeight / 2.5); dc.DrawLine(linePenBeat, new Point(x, lineStart), new Point(x, this.ActualHeight)); } } if (showSecs) { lineStart = this.ActualHeight / 1.5; dc.DrawLine(linePenBeat, new Point(x, lineStart), new Point(x, this.ActualHeight)); } } if (showSubSecs) { for (int i = 0; i < 10; i++) { lineStart = this.ActualHeight / 1.5; double subxunit = PixelsPerSecond * editingProject.ViewXZoomFac / 10; lineStart = this.ActualHeight / 1.5; dc.DrawLine(linePenBeat, new Point(x + subxunit * i, lineStart), new Point(x + subxunit * i, this.ActualHeight)); } } } } }