public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            var label = new Text();

            label.TranslationX   = location.X;
            label.TranslationY   = location.Y;
            label.Text           = text;
            label.FontFamily     = Fonts.Get(fontStyle).FontFamily;
            label.FontAttributes = Fonts.Get(fontStyle).Attributes;
            label.FontSize       = Fonts.Get(fontStyle).FontSize;
            label.TextColor      = X.Color.Black;
            label.FontStyle      = fontStyle;

            Canvas.Children.Add(label);
            OwnershipDictionary.Add(label, owner);
        }
コード例 #2
0
        public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                p1 = p1.Translate(CurrentScore.DefaultPageSettings);
                p2 = p2.Translate(CurrentScore.DefaultPageSettings);
                p3 = p3.Translate(CurrentScore.DefaultPageSettings);
                p4 = p4.Translate(CurrentScore.DefaultPageSettings);
            }

            Canvas.DrawBezier(ConvertPen(pen), new PointF((float)p1.X, (float)p1.Y), new PointF((float)p2.X, (float)p2.Y), new PointF((float)p3.X, (float)p3.Y), new PointF((float)p4.X, (float)p4.Y));
        }
        public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner)
        {
            renderingQueue.Enqueue(() => base.DrawArc(rect, startAngle, sweepAngle, pen, owner));

            if (renderingQueue.Count > BufferSize)
            {
                FlushBuffer();
            }
        }
コード例 #4
0
 public void DrawArc(Rectangle rect, double startAngle, double sweepAngle, MusicalSymbol owner)
 {
     DrawArc(rect, startAngle, sweepAngle, new Pen(CoalesceColor(owner), 1), owner);
 }
コード例 #5
0
        public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            var font = TypedSettings.GetFont(fontStyle);
            var baselineDesignUnits = font.FontFamily.GetCellAscent(font.Style);
            var baselinePixels      = (baselineDesignUnits * font.Size) / font.FontFamily.GetEmHeight(font.Style);

            Canvas.DrawString(text, font, new SolidBrush(ConvertColor(color)), new PointF((float)location.X - 4, (float)location.Y - baselinePixels));
        }
コード例 #6
0
 public abstract void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Point location, Size size, Color color, MusicalSymbol owner);
コード例 #7
0
        public Pen CreatePen(MusicalSymbol element, Func <ISMuFLFontMetadata, double> smuflProperty, double defaultProperty)
        {
            var thickness = IsSMuFLFont && Settings.MusicFontProfile.SMuFLMetadata != null?LinespacesToPixels(smuflProperty(Settings.MusicFontProfile.SMuFLMetadata)) : defaultProperty;

            return(new Pen(CoalesceColor(element), thickness));
        }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <param name="p3"></param>
 /// <param name="p4"></param>
 /// <param name="pen"></param>
 /// <param name="owner"></param>
 public abstract void DrawBezier(Point p1, Point p2, Point p3, Point p4, Pen pen, MusicalSymbol owner);
コード例 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <param name="p3"></param>
 /// <param name="p4"></param>
 /// <param name="pen"></param>
 /// <param name="owner"></param>
 public void DrawBezier(Point p1, Point p2, Point p3, Point p4, MusicalSymbol owner)
 {
     DrawBezier(p1, p2, p3, p4, new Pen(CoalesceColor(owner), 1), owner);
 }
コード例 #10
0
 /// <summary>
 /// Draws Bezier curve.
 /// </summary>
 /// <param name="x1">Start point X</param>
 /// <param name="y1">Start point Y</param>
 /// <param name="x2">Control point 1 X</param>
 /// <param name="y2">Control point 1 Y</param>
 /// <param name="x3">Control point 2 X</param>
 /// <param name="y3">Control point 2 Y</param>
 /// <param name="x4">End point X</param>
 /// <param name="y4">End point Y</param>
 /// <param name="owner">Owning symbol</param>
 public void DrawBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, MusicalSymbol owner)
 {
     DrawBezier(new Point(x1, y1), new Point(x2, y2), new Point(x3, y3), new Point(x4, y4), new Pen(CoalesceColor(owner), 1), owner);
 }
コード例 #11
0
 /// <summary>
 /// Draws Bezier curve.
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="x1">Start point X</param>
 /// <param name="y1">Start point Y</param>
 /// <param name="x2">Control point 1 X</param>
 /// <param name="y2">Control point 1 Y</param>
 /// <param name="x3">Control point 2 X</param>
 /// <param name="y3">Control point 2 Y</param>
 /// <param name="x4">End point X</param>
 /// <param name="y4">End point Y</param>
 /// <param name="pen">Pen settings</param>
 /// <param name="owner">Owning symbol</param>
 public void DrawBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, Pen pen, MusicalSymbol owner)
 {
     DrawBezier(new Point(x1, y1), new Point(x2, y2), new Point(x3, y3), new Point(x4, y4), pen, owner);
 }
コード例 #12
0
 /// <summary>
 /// Draws arc.
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="rect">Rectangle within which arc should be drawn</param>
 /// <param name="startAngle">Start angle</param>
 /// <param name="sweepAngle">Sweep angle</param>
 /// <param name="pen">Pen settings</param>
 /// <param name="owner">Owning symbol</param>
 public abstract void DrawArc(Rectangle rect, double startAngle, double sweepAngle, Pen pen, MusicalSymbol owner);
コード例 #13
0
        public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                p1 = p1.Translate(CurrentScore.DefaultPageSettings);
                p2 = p2.Translate(CurrentScore.DefaultPageSettings);
                p3 = p3.Translate(CurrentScore.DefaultPageSettings);
                p4 = p4.Translate(CurrentScore.DefaultPageSettings);
            }

            var bezierCurve = new BezierCurve();

            bezierCurve.Thickness    = pen.Thickness;
            bezierCurve.Color        = pen.Color;
            bezierCurve.TranslationX = p1.X;
            bezierCurve.TranslationY = p1.Y;
            bezierCurve.X2           = p2.X;
            bezierCurve.Y2           = p2.Y;
            bezierCurve.X3           = p3.X;
            bezierCurve.Y3           = p3.Y;
            bezierCurve.X4           = p4.X;
            bezierCurve.Y4           = p4.Y;

            Canvas.Children.Add(bezierCurve);
            OwnershipDictionary.Add(bezierCurve, owner);
        }
コード例 #14
0
        public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                rect = rect.Translate(CurrentScore.DefaultPageSettings);
            }

            var arc = new Arc();

            arc.TranslationX = rect.X;
            arc.TranslationY = rect.Y;
            arc.RX           = rect.Width;
            arc.RY           = rect.Height;
            arc.Thickness    = pen.Thickness;
            arc.StartAngle   = startAngle;
            arc.SweepAngle   = sweepAngle;
            arc.Color        = pen.Color;

            Canvas.Children.Add(arc);
            OwnershipDictionary.Add(arc, owner);
        }
コード例 #15
0
 /// <summary>
 /// Draws text (i.e. note heads, lyrics, articulation symbols) in default color in proper location with proper fontStyle.
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="text">Text to draw</param>
 /// <param name="fontStyle">Fontstyle of text</param>
 /// <param name="location">Location of text block</param>
 /// <param name="owner">Owning MusicalSymbol</param>
 public void DrawString(string text, MusicFontStyles fontStyle, Point location, MusicalSymbol owner)
 {
     DrawString(text, fontStyle, location, CoalesceColor(owner), owner);
 }
コード例 #16
0
 /// <summary>
 /// Draws line from startPoint to endPoint.
 /// </summary>
 /// <param name="startX">Start point X coordinate.</param>
 /// <param name="startY">Start point Y coordinate.</param>
 /// <param name="endX">End point Y coordinate.</param>
 /// <param name="endY">End point Y coordinate.</param>
 /// <param name="owner">Owner element</param>
 public void DrawLine(double startX, double startY, double endX, double endY, MusicalSymbol owner)
 {
     DrawLine(new Point(startX, startY), new Point(endX, endY), new Pen(CoalesceColor(owner), 1), owner);
 }
コード例 #17
0
 /// <summary>
 /// Draws text (i.e. note heads, lyrics, articulation symbols) in given color in proper location with proper fontStyle.
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="text">Text to draw</param>
 /// <param name="fontStyle">Fontstyle of text</param>
 /// <param name="location">Location of text block</param>
 /// <param name="color">Color of text</param>
 /// <param name="owner">Owning MusicalSymbol</param>
 public abstract void DrawString(string text, MusicFontStyles fontStyle, Point location, Color color, MusicalSymbol owner);
コード例 #18
0
 public void DrawLine(double startX, double startY, double endX, double endY, Pen pen, MusicalSymbol owner)
 {
     DrawLine(new Point(startX, startY), new Point(endX, endY), pen, owner);
 }
コード例 #19
0
 public void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Point location, Size size, MusicalSymbol owner)
 {
     DrawCharacterInBounds(character, fontStyle, location, size, CoalesceColor(owner), owner);
 }
コード例 #20
0
 /// <summary>
 /// Draws line from startPoint to endPoint.
 /// </summary>
 /// <param name="startPoint">Start point</param>
 /// <param name="endPoint">End point</param>
 /// <param name="owner">Owner element</param>
 public void DrawLine(Point startPoint, Point endPoint, MusicalSymbol owner)
 {
     DrawLine(startPoint, endPoint, new Pen(CoalesceColor(owner), 1), owner);
 }
コード例 #21
0
 /// <summary>
 /// Return musical symbol's color if musical symbol is not null and has custom color set. Otherwise returns renderer's default color.
 /// </summary>
 /// <param name="symbol">Musical symbol</param>
 /// <returns></returns>
 public Color CoalesceColor(MusicalSymbol symbol)
 {
     return(symbol?.CustomColor ?? Settings.DefaultColor);
 }
コード例 #22
0
 /// <summary>
 /// Draws line from startPoint to endPoint with specific pen.
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="startPoint">Start point</param>
 /// <param name="endPoint">End point</param>
 /// <param name="pen">Pen</param>
 /// <param name="owner">Owner element</param>
 public abstract void DrawLine(Point startPoint, Point endPoint, Pen pen, MusicalSymbol owner);
コード例 #23
0
        public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings);
                endPoint   = endPoint.Translate(CurrentScore.DefaultPageSettings);
            }

            Canvas.DrawLine(ConvertPen(pen), new PointF((float)startPoint.X, (float)startPoint.Y), new PointF((float)endPoint.X, (float)endPoint.Y));
        }
コード例 #24
0
 /// <summary>
 /// Draws text (i.e. note heads, lyrics, articulation symbols) in default color in proper location with proper fontStyle.
 /// </summary>
 /// <remarks>
 /// Be aware of owner.IsVisible property. You should decide how to implement invisibility, for example
 /// not draw anything at all, draw in transparent color, etc.
 /// </remarks>
 /// <param name="text">Text to draw</param>
 /// <param name="fontStyle">Fontstyle of text</param>
 /// <param name="owner">Owning MusicalSymbol</param>
 public void DrawString(string text, MusicFontStyles fontStyle, double x, double y, MusicalSymbol owner)
 {
     DrawString(text, fontStyle, new Point(x, y), CoalesceColor(owner), owner);
 }
コード例 #25
0
        public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                rect = rect.Translate(CurrentScore.DefaultPageSettings);
            }

            Canvas.DrawArc(ConvertPen(pen), new RectangleF((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height), (float)startAngle, (float)sweepAngle);
        }
コード例 #26
0
 public void DrawCharacter(char character, MusicFontStyles fontStyle, double x, double y, MusicalSymbol owner)
 {
     DrawString(character == '\0' ? "" : character.ToString(), fontStyle, x, y, owner);
 }
コード例 #27
0
        public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Size size, Primitives.Color color, MusicalSymbol owner)
        {
            if (!EnsureProperPage(owner))
            {
                return;
            }
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                location = location.Translate(CurrentScore.DefaultPageSettings);
            }

            var font = TypedSettings.GetFont(fontStyle);
            var path = new GraphicsPath();

            path.AddString(character.ToString(), font.FontFamily, (int)font.Style, Canvas.DpiY * font.Size / 72, new Point(0, 0), new StringFormat());
            var matrix     = new Matrix();
            var matrix2    = new Matrix();
            var pathBounds = path.GetBounds();
            var scaleX     = (float)size.Width / pathBounds.Width;
            var scaleY     = (float)size.Height / pathBounds.Height;

            matrix2.Translate((float)location.X - (float)LinespacesToPixels(2.5), (float)location.Y - (float)LinespacesToPixels(2.5));  //TODO: Sprawdzić czemu się źle przesuwa i usunąć linespacestopixels
            matrix.Scale(scaleX, scaleY);
            path.Transform(matrix);
            path.Transform(matrix2);
            Canvas.DrawPath(new Pen(ConvertColor(color)), path);
            Canvas.FillPath(new SolidBrush(ConvertColor(color)), path);
        }
コード例 #28
0
 public void DrawCharacter(char character, MusicFontStyles fontStyle, Point location, MusicalSymbol owner)
 {
     DrawString(character == '\0' ? "" : character.ToString(), fontStyle, location, owner);
 }
        public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner)
        {
            renderingQueue.Enqueue(() => base.DrawBezier(p1, p2, p3, p4, pen, owner));

            if (renderingQueue.Count > BufferSize)
            {
                FlushBuffer();
            }
        }
コード例 #30
0
        public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner)
        {
            if (Settings.RenderingMode != ScoreRenderingModes.Panorama)
            {
                startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings);
                endPoint   = endPoint.Translate(CurrentScore.DefaultPageSettings);
            }

            var line = new Line();

            line.TranslationX = startPoint.X;
            line.TranslationY = startPoint.Y;
            line.EndX         = endPoint.X;
            line.EndY         = endPoint.Y;
            line.Color        = pen.Color;
            line.Thickness    = pen.Thickness;

            Canvas.Children.Add(line);
            OwnershipDictionary.Add(line, owner);
        }