private void DrawGrid(IBrush brush, IDrawingContextImpl context)
 {
     for (var i = 0; i <= Cols; i++)
     {
         for (var j = 0; j <= Rows; j++)
         {
             context.DrawLine(new ImmutablePen(brush), new Point(i * Resolution, 0), new Point(i * Resolution, Height));
             context.DrawLine(new ImmutablePen(brush), new Point(0, j * Resolution), new Point(Width, j * Resolution));
         }
     }
 }
示例#2
0
 public override void Render(IDrawingContextImpl context)
 {
     context.Transform = Transform;
     context.DrawLine(Pen, P1, P2);
 }
示例#3
0
 public void DrawLine(Location from, Location to)
 {
     drawingContext.DrawLine(from, to);
 }
示例#4
0
 /// <summary>
 /// Draws a line.
 /// </summary>
 /// <param name="pen">The stroke pen.</param>
 /// <param name="p1">The first point of the line.</param>
 /// <param name="p2">The second point of the line.</param>
 public void DrawLine(Pen pen, Point p1, Point p2) => _impl.DrawLine(pen, p1, p2);
示例#5
0
        /// <summary>
        /// Draws the <see cref="TextDecoration"/> at given origin.
        /// </summary>
        /// <param name="drawingContext">The drawing context.</param>
        /// <param name="textDecoration">The text decoration.</param>
        /// <param name="origin">The origin.</param>
        private void DrawTextDecoration(IDrawingContextImpl drawingContext, ImmutableTextDecoration textDecoration, Point origin)
        {
            var textFormat = Style.TextFormat;

            var fontMetrics = Style.TextFormat.FontMetrics;

            var thickness = textDecoration.Pen?.Thickness ?? 1.0;

            switch (textDecoration.PenThicknessUnit)
            {
            case TextDecorationUnit.FontRecommended:
                switch (textDecoration.Location)
                {
                case TextDecorationLocation.Underline:
                    thickness = fontMetrics.UnderlineThickness;
                    break;

                case TextDecorationLocation.Strikethrough:
                    thickness = fontMetrics.StrikethroughThickness;
                    break;
                }
                break;

            case TextDecorationUnit.FontRenderingEmSize:
                thickness = textFormat.FontRenderingEmSize * thickness;
                break;
            }

            switch (textDecoration.Location)
            {
            case TextDecorationLocation.Overline:
                origin += new Point(0, textFormat.FontMetrics.Ascent);
                break;

            case TextDecorationLocation.Strikethrough:
                origin += new Point(0, -textFormat.FontMetrics.StrikethroughPosition);
                break;

            case TextDecorationLocation.Underline:
                origin += new Point(0, -textFormat.FontMetrics.UnderlinePosition);
                break;
            }

            switch (textDecoration.PenOffsetUnit)
            {
            case TextDecorationUnit.FontRenderingEmSize:
                origin += new Point(0, textDecoration.PenOffset * textFormat.FontRenderingEmSize);
                break;

            case TextDecorationUnit.Pixel:
                origin += new Point(0, textDecoration.PenOffset);
                break;
            }

            var pen = new ImmutablePen(
                textDecoration.Pen?.Brush ?? Style.Foreground.ToImmutable(),
                thickness,
                textDecoration.Pen?.DashStyle?.ToImmutable(),
                textDecoration.Pen?.LineCap ?? default,
                textDecoration.Pen?.LineJoin ?? PenLineJoin.Miter,
                textDecoration.Pen?.MiterLimit ?? 10.0);

            drawingContext.DrawLine(pen, origin, origin + new Point(GlyphRun.Bounds.Width, 0));
        }