Ejemplo n.º 1
0
        public Result DrawGlyphRun(
            object clientDrawingContext,
            float baselineOriginX,
            float baselineOriginY,
            MeasuringMode measuringMode,
            GlyphRun glyphRun,
            GlyphRunDescription glyphRunDescription,
            ComObject clientDrawingEffect)
        {
            var wrapper = clientDrawingEffect as BrushWrapper;

            // TODO: Work out how to get the size below rather than passing new Size().
            var brush = (wrapper == null) ?
                        _foreground :
                        _context.CreateBrush(wrapper.Brush, new Size()).PlatformBrush;

            _renderTarget.DrawGlyphRun(
                new Vector2(baselineOriginX, baselineOriginY),
                glyphRun,
                brush,
                measuringMode);

            if (wrapper != null)
            {
                brush.Dispose();
            }

            return(Result.Ok);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a glyph run.
        /// </summary>
        /// <param name="foreground">The foreground.</param>
        /// <param name="glyphRun">The glyph run.</param>
        /// <param name="baselineOrigin"></param>
        public void DrawGlyphRun(IBrush foreground, GlyphRun glyphRun, Point baselineOrigin)
        {
            using (var brush = CreateBrush(foreground, glyphRun.Bounds.Size))
            {
                var glyphRunImpl = (GlyphRunImpl)glyphRun.GlyphRunImpl;

                _renderTarget.DrawGlyphRun(baselineOrigin.ToSharpDX(), glyphRunImpl.GlyphRun, brush.PlatformBrush, MeasuringMode.Natural);
            }
        }
Ejemplo n.º 3
0
        public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, D2D.MeasuringMode measuringMode, DW.GlyphRun glyphRun, DW.GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect)
        {
            D2D.RenderTarget render = clientDrawingContext as D2D.RenderTarget;
            if (render == null)
            {
                return(SharpDX.Result.Ok);
            }

            D2D.SolidColorBrush foreBrush = this.factory.GetSolidColorBrush(this.DefaultFore);
            bool isDrawGlyphRun           = true;

            if (clientDrawingEffect != null)
            {
                var drawingForeBrush = clientDrawingEffect as D2D.SolidColorBrush;
                var selectedEffect   = clientDrawingEffect as SelectedEffect;
                var drawingEffect    = clientDrawingEffect as DrawingEffect;

                if (drawingForeBrush != null)
                {
                    foreBrush = drawingForeBrush;
                }
                else if (selectedEffect != null)
                {
                    foreBrush = this.factory.GetSolidColorBrush(selectedEffect.Fore);
                }
                else if (drawingEffect != null)
                {
                    if (drawingEffect.Stroke == HilightType.Url)
                    {
                        foreBrush = this.factory.GetSolidColorBrush(drawingEffect.Fore);
                    }
                }
            }

            if (isDrawGlyphRun)
            {
                render.DrawGlyphRun(new Vector2(baselineOriginX, baselineOriginY),
                                    glyphRun,
                                    foreBrush,
                                    measuringMode);
            }

            return(SharpDX.Result.Ok);
        }
Ejemplo n.º 4
0
            public override SharpDX.Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, D2D1.MeasuringMode measuringMode,
                                                        DW.GlyphRun glyphRun, DW.GlyphRunDescription glyphRunDescription, ComObject effect)
            {
                var sb = _defaultBrush;

                if (effect != null && effect is D2D1.SolidColorBrush solidColorBrush)
                {
                    sb = solidColorBrush;
                }
                try
                {
                    _renderTarget.DrawGlyphRun(new Vector2(baselineOriginX, baselineOriginY), glyphRun, sb, measuringMode);
                    return(SharpDX.Result.Ok);
                }
                catch
                {
                    return(SharpDX.Result.Fail);
                }
            }