public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect) { var pathGeometry = new PathGeometry(_d2DFactory); var geometrySink = pathGeometry.Open(); var fontFace = glyphRun.FontFace; if (glyphRun.Indices.Length > 0) { fontFace.GetGlyphRunOutline(glyphRun.FontSize, glyphRun.Indices, glyphRun.Advances, glyphRun.Offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink); } geometrySink.Close(); geometrySink.Dispose(); fontFace.Dispose(); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix); _renderTarget.DrawGeometry(transformedGeometry, PenBrush, PenWidth, PenStyle); _renderTarget.FillGeometry(transformedGeometry, FontBrush); pathGeometry.Dispose(); transformedGeometry.Dispose(); return(SharpDX.Result.Ok); }
public Result DrawStrikethrough(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Strikethrough strikethrough, ComObject clientDrawingEffect) { var rect = new SharpDX.RectangleF(0, strikethrough.Offset, strikethrough.Width, strikethrough.Offset + strikethrough.Thickness); var rectangleGeometry = new RectangleGeometry(_d2DFactory, rect); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, rectangleGeometry, matrix); var brushColor = (Color4)Color.Black; if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (Color4)(clientDrawingEffect as ColorDrawingEffect).Color; } var brush = new SolidColorBrush(_renderTarget, brushColor); _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); rectangleGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(Result.Ok); }
public Result DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Underline underline, ComObject clientDrawingEffect) { var rect = new SharpDX.RectangleF(0, underline.Offset, underline.Width, underline.Offset + underline.Thickness); var rectangleGeometry = new RectangleGeometry(_d2DFactory, rect); RawMatrix3x2 matrix = new RawMatrix3x2( 1.0f, 0.0f, 0.0f, 1.0f, baselineOriginX, baselineOriginY ); var transformedGeometry = new TransformedGeometry(_d2DFactory, rectangleGeometry, matrix); var brushColor = (Color4)Color.Black; if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (Color4)(clientDrawingEffect as ColorDrawingEffect).Color; } var brush = new SolidColorBrush(_renderTarget, brushColor); _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); rectangleGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(SharpDX.Result.Ok); }
public Result DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Underline underline, ComObject clientDrawingEffect) { var rect = new SharpDX.RectangleF(0, underline.Offset, underline.Width, underline.Offset + underline.Thickness); var rectangleGeometry = new RectangleGeometry(_d2DFactory, rect); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, rectangleGeometry, matrix); var brushColor = new Color4(1, 0, 0, 0); if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (clientDrawingEffect as ColorDrawingEffect).Color; } var brush = new SolidColorBrush(_renderTarget, brushColor); _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); rectangleGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(SharpDX.Result.Ok); }
public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect) { if (clientDrawingEffect != null && clientDrawingEffect is SolidColorBrush) { SolidColorBrush brushx = clientDrawingEffect as SolidColorBrush; _renderTarget.DrawGlyphRun(new Vector2(baselineOriginX, baselineOriginY), glyphRun, brushx, measuringMode); return(Result.Ok); } var pathGeometry = new PathGeometry(_d2DFactory); var geometrySink = pathGeometry.Open(); var fontFace = glyphRun.FontFace; if (glyphRun.Indices.Length > 0) { fontFace.GetGlyphRunOutline(glyphRun.FontSize, glyphRun.Indices, glyphRun.Advances, glyphRun.Offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink); } geometrySink.Close(); geometrySink.Dispose(); fontFace.Dispose(); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix); var brushColor = (Color4)Color.Black; SolidColorBrush brush = null; if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (clientDrawingEffect as ColorDrawingEffect).Color; } brush = new SolidColorBrush(_renderTarget, brushColor); // _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); pathGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(SharpDX.Result.Ok); }
public Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect) { var pathGeometry = new PathGeometry(_d2DFactory); var geometrySink = pathGeometry.Open(); float[] advances; GlyphOffset[] offsets; var indecies = glyphRun.ToArrays(out advances, out offsets); var result = glyphRun.FontFace.GetGlyphRunOutline(glyphRun.FontSize, indecies, advances, offsets, glyphRun.IsSideways, glyphRun.BidiLevel % 2 != 0, geometrySink); geometrySink.Close(); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, pathGeometry, matrix); var brushColor = new Color4(1, 0, 0, 0); if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect) { brushColor = (clientDrawingEffect as ColorDrawingEffect).Color; } var brush = new SolidColorBrush(_renderTarget, brushColor); _renderTarget.DrawGeometry(transformedGeometry, brush); _renderTarget.FillGeometry(transformedGeometry, brush); pathGeometry.Dispose(); transformedGeometry.Dispose(); brush.Dispose(); return(SharpDX.Result.Ok); }
public Result DrawStrikethrough(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Strikethrough strikethrough, ComObject clientDrawingEffect) { var rect = new SharpDX.RectangleF(0, strikethrough.Offset, strikethrough.Width, strikethrough.Offset + strikethrough.Thickness); var rectangleGeometry = new RectangleGeometry(_d2DFactory, rect); var matrix = new Matrix3x2() { M11 = 1, M12 = 0, M21 = 0, M22 = 1, M31 = baselineOriginX, M32 = baselineOriginY }; var transformedGeometry = new TransformedGeometry(_d2DFactory, rectangleGeometry, matrix); _renderTarget.DrawGeometry(transformedGeometry, FontBrush); _renderTarget.FillGeometry(transformedGeometry, FontBrush); rectangleGeometry.Dispose(); transformedGeometry.Dispose(); return(Result.Ok); }