using System.ComponentModel; using System.Text.Json.Serialization; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; using static QuikDawEditor.EDITING.MiscMethods; using static QuikDawEditor.EDITING.StaticProperties; using static QuikDawEditor.EDITING.MidiMethods; namespace QuikDawEditor.EditingClasses; public partial class Project : INotifyPropertyChanged { public void UpdateProjectGridLines() { GridLinesReverseTransform = new ScaleTransform(1 / ViewXZoomFac, 1); NotifyPropertyChanged(nameof(GridLinesBMP)); } public BitmapSource GridLinesBMP { get { BitmapSource bsource = null; double drawWidth = 0; GeometryCollection gcoll = new GeometryCollection(); switch (IsTimePlayScale) { case true: GridLinesViewPortWidth = MsecToPixelsZoomed(10000); drawWidth = MsecToPixels(10000); for (int relx = 0; relx < 10; relx++) gcoll.Add(new LineGeometry(new Point(relx * drawWidth / 10 * ViewXZoomFac, 0), new Point(relx * drawWidth / 10 * ViewXZoomFac, 300))); break; case false: GridLinesViewPortWidth = MsecToPixelsZoomed(MillisecondsPerBeat * BeatsPerMeasure); drawWidth = MsecToPixels(BeatsPerMeasure * MillisecondsPerBeat); for (int relx = 0; relx < BeatsPerMeasure; relx++) gcoll.Add(new LineGeometry(new Point(relx * drawWidth / BeatsPerMeasure * ViewXZoomFac, 0), new Point(relx * drawWidth / BeatsPerMeasure * ViewXZoomFac, 300))); break; } BitmapSource gridBMS = DrawGridLineGeometry(new Rect(0, 0, drawWidth, 300), new GeometryGroup() { Children = gcoll }); bsource = gridBMS; bsource.Freeze(); return bsource; } } private ScaleTransform _GridLinesReverseTransform; [JsonIgnore(Condition = JsonIgnoreCondition.Always)] public ScaleTransform GridLinesReverseTransform { get { return _GridLinesReverseTransform; } set { _GridLinesReverseTransform = value; NotifyPropertyChanged(nameof(GridLinesReverseTransform)); } } private double _GridLinesViewPortWidth = 0; [JsonIgnore(Condition = JsonIgnoreCondition.Always)] public double GridLinesViewPortWidth { get { return _GridLinesViewPortWidth; } set { _GridLinesViewPortWidth = value; NotifyPropertyChanged(nameof(GridLinesViewPortWidth)); } } [JsonIgnore(Condition = JsonIgnoreCondition.Always)] public double GridLinesViewPortHeight { get; set; } = 100; public bool addLines = false; FormattedText fText = null; Typeface typefaceMeasure = new Typeface(new FontFamily("Verdana"), FontStyles.Normal, FontWeights.Bold, FontStretches.Condensed); Typeface typefaceBeat = new Typeface(new FontFamily("Verdana"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); Pen linePenMeasure = new Pen(Brushes.Black, 1.2); Pen linePenBeat = new Pen(Brushes.Black, 0.6); }