Ejemplo n.º 1
0
        public async Task DrawConnection(IRootElementRenderer rootRenderer, NoteConnection connection, Beat from,
                                         Beat to, int stringIndex, Core.Style.VerticalDirection tiePosition)
        {
            var bounds = await
                         NoteConnectionRenderer.DrawConnection(rootRenderer, connection, from, to, stringIndex, tiePosition);

            var instructionPosition = (bounds.Left + bounds.Right) / 2;

            switch (connection)
            {
            case NoteConnection.Slide:
                this.AddConnectionInstruction(stringIndex, instructionPosition, "sl.");
                break;

            case NoteConnection.SlideInFromHigher:
            case NoteConnection.SlideInFromLower:
            case NoteConnection.SlideOutToHigher:
            case NoteConnection.SlideOutToLower:
                this.AddConnectionInstruction(stringIndex, instructionPosition, "gl.");
                break;

            case NoteConnection.Hammer:
                this.AddConnectionInstruction(stringIndex, instructionPosition, "h.");
                break;

            case NoteConnection.Pull:
                this.AddConnectionInstruction(stringIndex, instructionPosition, "p.");
                break;
            }
        }
Ejemplo n.º 2
0
        // from and to are absolute positions
        public Task <Rect> DrawTie(double from, double to, int stringIndex, Core.Style.VerticalDirection tiePosition, string instruction,
                                   double instructionY)
        {
            var spaceIndex = tiePosition == Core.Style.VerticalDirection.Under ? stringIndex + 1 : stringIndex;
            var y          = this.GetStringSpacePosition(spaceIndex);

            return(this.PrimitiveRenderer.DrawTie(from, to, y, tiePosition.ToOffBarDirection()));
        }
Ejemplo n.º 3
0
        public static VerticalDirection ToOffBarDirection(this Core.Style.VerticalDirection tiePosition)
        {
            switch (tiePosition)
            {
            case Core.Style.VerticalDirection.Above:
                return(VerticalDirection.Above);

            case Core.Style.VerticalDirection.Under:
                return(VerticalDirection.Under);

            default:
                throw new ArgumentOutOfRangeException(nameof(tiePosition), tiePosition, null);
            }
        }
Ejemplo n.º 4
0
        public static async Task <Rect> DrawTie(IRootElementRenderer rootRenderer, Beat from, Beat to, IEnumerable <int> stringIndices, Core.Style.VerticalDirection tiePosition)
        {
            if (to.IsRest || from.IsRest)
            {
                return(default(Rect));
            }

            Debug.Assert(from.VoicePart == to.VoicePart);

            var toContext   = rootRenderer.GetRenderer <Beat, BeatRenderer>(to).RenderingContext;
            var fromContext = rootRenderer.GetRenderer <Beat, BeatRenderer>(from).RenderingContext;

            var bounds = new BoundingBoxUnion();

            foreach (var stringIndex in stringIndices)
            {
                var currentBounds  = toContext.GetNoteBoundingBox(to.OwnerColumn.ColumnIndex, stringIndex);
                var previousBounds = fromContext.GetNoteBoundingBox(from.OwnerColumn.ColumnIndex, stringIndex);
                Debug.Assert(currentBounds != null, "currentBounds != null");
                Debug.Assert(previousBounds != null, "previousBounds != null");

                var fromX = previousBounds.Value.Right + toContext.Style.NoteMargin;
                var toX   = currentBounds.Value.Left - toContext.Style.NoteMargin;

                if (toContext.Owner == fromContext.Owner)   // both in same row
                {
                    bounds.AddBounds(await toContext.Owner.DrawTie(fromX, toX, stringIndex, tiePosition, null, 0));
                }
                else
                {
                    bounds.AddBounds(await toContext.Owner.DrawTie(toContext.Owner.Location.X + toContext.Owner.HeaderWidth,
                                                                   toX, stringIndex, tiePosition, null, 0));

                    await fromContext.Owner.DrawTie(fromX,
                                                    fromContext.Owner.BottomRight.X,
                                                    stringIndex, tiePosition, null, 0);
                }
            }

            Debug.Assert(bounds.HasAnyBounds);
            return(bounds.Bounds);
        }
Ejemplo n.º 5
0
 public static async Task DrawTie(IRootElementRenderer rootRenderer, Beat from, Beat to, int stringIndex, Core.Style.VerticalDirection tiePosition)
 {
     await NoteConnectionRenderer.DrawTie(rootRenderer, from, to, new[] { stringIndex }, tiePosition);
 }
Ejemplo n.º 6
0
        public static async Task <Rect> DrawConnection(IRootElementRenderer rootRenderer, NoteConnection connection, Beat from, Beat to, IEnumerable <int> stringIndices, Core.Style.VerticalDirection tiePosition)
        {
            switch (connection)
            {
            case NoteConnection.Slide:
            case NoteConnection.Hammer:
            case NoteConnection.Pull:
                return(await NoteConnectionRenderer.DrawTie(rootRenderer, @from, to, stringIndices, tiePosition));

            case NoteConnection.SlideInFromHigher:
            case NoteConnection.SlideInFromLower:
                return(await NoteConnectionRenderer.DrawGliss(rootRenderer, to, stringIndices, (GlissDirection)connection));

            case NoteConnection.SlideOutToHigher:
            case NoteConnection.SlideOutToLower:
                return(await NoteConnectionRenderer.DrawGliss(rootRenderer, from, stringIndices, (GlissDirection)connection));
            }

            return(default(Rect));
        }
Ejemplo n.º 7
0
 public static Task <Rect> DrawConnection(IRootElementRenderer rootRenderer, NoteConnection connection, Beat from,
                                          Beat to, int stringIndex, Core.Style.VerticalDirection tiePosition)
 {
     return(NoteConnectionRenderer.DrawConnection(rootRenderer, connection, from, to, new[] { stringIndex }, tiePosition));
 }