/// <summary> /// Draws extra ledger line(s) when the specified note falls above/below the staff. /// </summary> /// <param name="notePos"></param> /// <param name="note"></param> /// <param name="octave"></param> /// <param name="duration"></param> /// <param name="noteLeft"></param> /// <param name="partIndex"></param> private void DrawExtraLedgerLines(double notePos, Note note, Octave octave, DurationCFugue duration, double noteLeftMargin, int verticalOffset, byte partIndex) { double x1 = noteLeftMargin - 4; double x2 = noteLeftMargin + LayoutController.ElementWidth["N" + duration]; double y = notePos + verticalOffset * LayoutController.stepLedgerLine / 2; DrawLine(x1, x2, y, partIndex); Clef clef = Parameters.Clefs[partIndex]; // Now add the extra lines. if (octave == Octave.Octave3 && note == Note.C) { y = LayoutController.GetNotePos(Note.E, Octave.Octave3, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else if (octave == Octave.Octave7) { if (note == Note.C || note == Note.D) { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else if (note == Note.E || note == Note.F) { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.C, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else if (note == Note.G || note == Note.A) { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.C, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.E, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); } else { y = LayoutController.GetNotePos(Note.A, Octave.Octave6, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.C, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.E, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); y = LayoutController.GetNotePos(Note.G, Octave.Octave7, clef, partIndex); DrawLine(x1, x2, y, partIndex); } } }
private void DrawNote(Note note, DurationCFugue duration, bool dot, Octave[] actOctave, char orientation, string hasAcc, bool hasTie, byte partIndex) { double height = LayoutController.ElementHeight["N" + duration]; Octave actualOctave = actOctave[partIndex]; double notePos = LayoutController.GetNotePos(note, actualOctave, Parameters.Clefs[partIndex], partIndex); double top = LayoutController.GetNoteTopMargin(notePos, height, orientation, partIndex); double noteLeftMargin = leftMargin; if (hasAcc != "") { DrawAccidental(notePos, hasAcc, orientation, partIndex); noteLeftMargin += LayoutController.accidentalOffset; } if (hasTie) { double notePosOffset = notePos + LayoutController.GetTieOffset(note, actualOctave, partIndex); DrawTie(layoutInterval + 2 * unitElementWidth, noteLeftMargin - layoutInterval - unitElementWidth, notePosOffset, orientation, partIndex); } Image image = new Image(); image.HorizontalAlignment = HorizontalAlignment.Left; image.Source = LayoutController.GetNote(duration, dot, orientation); image.Height = height; image.Margin = new Thickness(noteLeftMargin, top, 0, 0); staffGrid.Children.Add(image); Grid.SetRow(image, partIndex); string has = LayoutController.HasLine(note, actualOctave); if (has != "") { DrawExtraLedgerLines(notePos, note, actualOctave, duration, noteLeftMargin, Convert.ToInt32(has), partIndex); } }