Ejemplo n.º 1
0
        public Result DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref DW.Underline underline, ComObject clientDrawingEffect)
        {
            D2D.RenderTarget render = clientDrawingContext as D2D.RenderTarget;
            if (render == null)
            {
                return(SharpDX.Result.Ok);
            }

            D2D.SolidColorBrush foreBrush = this.factory.GetSolidColorBrush(this.DefaultFore);
            DrawingEffect       effect    = clientDrawingEffect as DrawingEffect;

            if (clientDrawingEffect != null && effect != null)
            {
                foreBrush = this.factory.GetSolidColorBrush(effect.Fore);
                float thickness = effect.isBoldLine ? D2DRenderCommon.BoldThickness : D2DRenderCommon.NormalThickness;
                if (effect.Stroke == HilightType.Squiggle)
                {
                    SquilleLineMarker marker = new D2DSquilleLineMarker(render, this.factory.GetSolidColorBrush(effect.Fore), this.factory.GetStroke(effect.Stroke), 1);
                    marker.Draw(
                        baselineOriginX, baselineOriginY + underline.Offset,
                        underline.Width, underline.RunHeight
                        );
                }
                else
                {
                    LineMarker marker = new LineMarker(render, this.factory.GetSolidColorBrush(effect.Fore), this.factory.GetStroke(effect.Stroke), GetThickness(render, thickness));
                    marker.Draw(
                        baselineOriginX, baselineOriginY + underline.Offset,
                        underline.Width, 0
                        );
                }
            }
            if (effect == null)
            {
                render.DrawLine(new Vector2(baselineOriginX, baselineOriginY + underline.Offset),
                                new Vector2(baselineOriginX + underline.Width - 1, baselineOriginY + underline.Offset),
                                foreBrush,
                                GetThickness(render, underline.Thickness));
            }

            return(SharpDX.Result.Ok);
        }
Ejemplo n.º 2
0
        public Result DrawStrikethrough(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref DW.Strikethrough strikethrough, ComObject clientDrawingEffect)
        {
            D2D.RenderTarget render = clientDrawingContext as D2D.RenderTarget;
            if (render == null)
            {
                return(SharpDX.Result.Ok);
            }

            D2D.SolidColorBrush foreBrush = this.factory.GetSolidColorBrush(this.DefaultFore);
            DrawingEffect       effect    = clientDrawingEffect as DrawingEffect;

            if (clientDrawingEffect != null && clientDrawingEffect != null)
            {
                foreBrush = this.factory.GetSolidColorBrush(effect.Fore);
            }
            if (effect == null)
            {
                render.DrawLine(new Vector2(baselineOriginX, baselineOriginY + strikethrough.Offset),
                                new Vector2(baselineOriginX + strikethrough.Width - 1, baselineOriginY + strikethrough.Offset),
                                foreBrush,
                                GetThickness(render, strikethrough.Thickness));
            }
            return(Result.Ok);
        }