private void Draw() { LayoutStyle.NotesLayoutStyle notesStyle = ViewModel.ViewModelLocator.Instance.Main.CurrentLayout.LayoutStyle.NotesStyle; DrawingVisual dravingVisualStem = new DrawingVisual(); using (DrawingContext dc = dravingVisualStem.RenderOpen()) { dc.DrawLine(new Pen(note.Color, notesStyle.StemThickness * sizeFactor), startPoint, endPoint); } //! check if added previously to prevent unnecessary remove+add calls bool stemVisualAdded = false; if (stemVisual == null) { stemVisual = new DrawingVisualHost(); stemVisual.Tag = "stem"; } else { stemVisual.ClearVisuals(); stemVisualAdded = true; //! no need to add to noteVisual } //! stemVisual.AddVisual(dravingVisualStem); //! add visual to noteVisual (one time only) if (!stemVisualAdded) { note.AddStem(stemVisual); } }
private void Draw(bool updatePositions = false) { DrawingVisual staffLineVisual = new DrawingVisual(); Pen pen = new Pen(Color, LineThickness); if (updatePositions || _yOffsets.Count == 0) { GenerateStaffLinesPositions(); } using (DrawingContext dc = staffLineVisual.RenderOpen()) { for (int i = 1; i <= _linesCount; i++) { dc.DrawLine(pen, new Point(0.0, _yOffsets[i]), new Point(Width, _yOffsets[i])); } } _visual.ClearVisuals(); _visual.AddVisual(staffLineVisual); }
private void CreateStaffLine() { Point p = new Point(0, layout.PageProperties.StaffHeight.MMToWPFUnit()); staffLinesCoords = new double[stavesCount]; staffLinesYpositions = new Dictionary <int, double[]>(); if (visualObject.Count != 0) { visualObject.ClearVisuals(); } for (uint i = 0; i < stavesCount; i++) { p.Y += (stavesDistance.TenthsToWPFUnit() + layout.PageProperties.StaffHeight.MMToWPFUnit()) * i; DrawableStaffLine staff = new DrawableStaffLine(layout.PageProperties, measureWidth, offsetPoint: p); staffLinesYpositions.Add((int)i + 1, staff.LinesYpositions); staffLinesCoords[i] = p.Y; visualObject.AddVisual(staff.PartialObjectVisual); } }