Esempio n. 1
0
        /// <inheritdoc/>
        public override void Draw(IDrawingContextImpl drawingContext, Point origin)
        {
            if (GlyphRun.GlyphIndices.Length == 0)
            {
                return;
            }

            if (Style.TextFormat.Typeface == null)
            {
                return;
            }

            if (Style.Foreground == null)
            {
                return;
            }

            drawingContext.DrawGlyphRun(Style.Foreground, GlyphRun, origin);

            if (Style.TextDecorations == null)
            {
                return;
            }

            foreach (var textDecoration in Style.TextDecorations)
            {
                DrawTextDecoration(drawingContext, textDecoration, origin);
            }
        }
Esempio n. 2
0
    public void RenderFps(IDrawingContextImpl context, string aux)
    {
        var now     = _stopwatch.Elapsed;
        var elapsed = now - _lastFpsUpdate;

        ++_framesThisSecond;
        ++_totalFrames;

        if (elapsed.TotalSeconds > 1)
        {
            _fps = (int)(_framesThisSecond / elapsed.TotalSeconds);
            _framesThisSecond = 0;
            _lastFpsUpdate    = now;
        }

        var    fpsLine = $"Frame #{_totalFrames:00000000} FPS: {_fps:000} " + aux;
        double width   = 0;
        double height  = 0;

        foreach (var ch in fpsLine)
        {
            var run = _runs[ch - FirstChar];
            width += run.Size.Width;
            height = Math.Max(height, run.Size.Height);
        }

        var rect = new Rect(0, 0, width + 3, height + 3);

        context.DrawRectangle(Brushes.Black, null, rect);

        double offset = 0;

        foreach (var ch in fpsLine)
        {
            var run = _runs[ch - FirstChar];
            context.Transform = Matrix.CreateTranslation(offset, 0);
            context.DrawGlyphRun(Brushes.White, run);
            offset += run.Size.Width;
        }
    }
Esempio n. 3
0
 /// <inheritdoc/>
 public override void Render(IDrawingContextImpl context)
 {
     context.Transform = Transform;
     context.DrawGlyphRun(Foreground, GlyphRun, BaselineOrigin);
 }