コード例 #1
0
        protected override void Render(Graphics gfx, SheetMusicRenderSettings settings, int width)
        {
            gfx.TranslateTransform(Margin, 0);

            foreach (var chord in layoutmeasure.Chords)
            {
                NoteRenderer.DrawChord(gfx, settings, Color.Black, Color.Blue, chord, true, width - (int)(2 * Margin));
            }

            DrawMeasureDivision(gfx, settings, width);
            gfx.TranslateTransform(-Margin, 0);
        }
コード例 #2
0
        void DrawCaret(
            Graphics gfx,
            SheetMusicRenderSettings settings,
            bool active,
            MusicTrack track,
            float scrollX
            )
        {
            var caretx =
                GetLeft(editor.Cursor.Caret.Focus, track) - scrollX;

            var caretunitx =
                GetLeft(editor.Cursor.Caret.Focus + editor.Cursor.Caret.Unit.Value, track) - scrollX;

            var caretstaff =
                track
                .Adornment
                .Staffs
                .Intersecting(editor.Cursor.Caret.Focus)
                .First()
                .Value;

            PitchTransform transform;

            var caretkey =
                track
                .Adornment
                .KeySignatures
                .Intersecting(editor.Cursor.Caret.Focus)
                .First()
                .Value
                .Key(editor.Cursor.Tone.Value, out transform);

            var carety =
                settings.YVal(caretstaff.GetHalfLine(caretkey));

            var caret_pen_x =
                new Pen(Color.DarkSeaGreen, active ? 2.5f : 1.2f);

            var caret_pen_y =
                new Pen(Color.Red, active ? 3f : 1.4f);

            gfx
            .DrawLine(
                caret_pen_x,
                caretx,
                0,
                caretx,
                settings.Height
                );

            gfx
            .DrawLine(
                caret_pen_y,
                caretx,
                carety,
                caretunitx,
                carety
                );

            var cursorcolor =
                active ?
                Color.FromArgb(200, Color.DeepSkyBlue) :
                Color.FromArgb(100, Color.Aquamarine);

            var cursor_focusduration =
                new Duration {
                Start  = editor.Cursor.Caret.Focus,
                Length = editor.Cursor.Caret.Unit.Value
            };

            var cursor_notelayout =
                new NoteLayout(
                    new PerceptualNote(
                        default(PerceptualNoteID),
                        cursor_focusduration,
                        PerceptualTime.Decompose(editor.Cursor.Caret.Unit.Value).First().Key,
                        track.Rhythm.Intersecting(cursor_focusduration).First(),
                        new Note(
                            default(NoteID),
                            cursor_focusduration,
                            editor.Cursor.Tone.Value
                            )
                        ),
                    settings
                    .Staff
                    .GetHalfLine(caretkey),
                    0,
                    0,
                    caretkey,
                    transform
                    );

            var cursor_chordlayout =
                new ChordLayout(cursor_notelayout);

            if (cursor_chordlayout.Length.Length > LengthClass.Whole)
            {
                cursor_chordlayout.StemDirection =
                    settings.Staff.GetStemDirection(cursor_notelayout.Key);

                cursor_chordlayout.StemSide =
                    cursor_chordlayout.StemDirection == NoteStemDirection.Down ?
                    NoteStemSide.Left :
                    NoteStemSide.Right;

                cursor_chordlayout.StemStartHalfLines =
                    cursor_chordlayout.StemDirection == NoteStemDirection.Down ?
                    cursor_notelayout.HalfLine - 5 :
                    cursor_notelayout.HalfLine + 5;
            }

            if (cursor_chordlayout.Length.Length > LengthClass.Quarter)
            {
                cursor_chordlayout.FreeFlags     = cursor_chordlayout.Length.Length - LengthClass.Quarter;
                cursor_chordlayout.FlagDirection = cursor_chordlayout.StemDirection == NoteStemDirection.Down ? FlagDirection.Left : FlagDirection.Right;
            }
            gfx.TranslateTransform(caretx, 0);

            NoteRenderer
            .DrawChord(
                gfx,
                settings,
                cursorcolor,
                Color.SeaGreen,
                cursor_chordlayout,
                false,
                500
                );

            gfx.TranslateTransform(-caretx, 0);
        }