SharpDX.DirectWrite.TextLayout.SetDrawingEffect C# (CSharp) Method

SetDrawingEffect() public method

Sets the application-defined drawing effect.
An SharpDX.Direct2D1.Brush, such as a color or gradient brush, can be set as a drawing effect if you are using the RenderTarget.DrawTextLayout(System.Drawing.PointF,SharpDX.DirectWrite.TextLayout,SharpDX.Direct2D1.Brush,SharpDX.Direct2D1.DrawTextOptions) to draw text and that brush will be used to draw the specified range of text. This drawing effect is associated with the specified range and will be passed back to the application by way of the callback when the range is drawn at drawing time.
public SetDrawingEffect ( SharpDX drawingEffect, SharpDX textRange ) : void
drawingEffect SharpDX Application-defined drawing effects that apply to the range. This data object will be passed back to the application's drawing callbacks for final rendering.
textRange SharpDX The text range to which this change applies.
return void
        public void SetDrawingEffect(SharpDX.ComObject drawingEffect, SharpDX.DirectWrite.TextRange textRange)
        {
            var drawingEffectPtr = Utilities.GetIUnknownForObject(drawingEffect);
            SetDrawingEffect(drawingEffectPtr, textRange);
            if (drawingEffectPtr != IntPtr.Zero)
                Marshal.Release(drawingEffectPtr);
        }

Usage Example

 private void DrawText(string text, float locX, float locY, D2D1.Brush fg, D2D1.Brush bg, string font = "", float size = 0)
 {
     using (TextFormat = new DW.TextFormat(DWFactory, font == "" ? Config.CooldownBarTextFont : font, size == 0 ? Config.CooldownBarTextFontSize : size)) {
         TextFormat.WordWrapping = DW.WordWrapping.NoWrap;
         using (DW.TextLayout TextLayout = new DW.TextLayout(DWFactory, text, TextFormat, 500, 500)) {
             using (TextBrush = new TextBrush(fg, bg)) {
                 using (TextRenderer = new TextRenderer(Render, TextBrush)) {
                     TextLayout.SetDrawingEffect(TextBrush, new DW.TextRange(10, 20));
                     TextLayout.Draw(TextRenderer, locX, locY);
                 }
             }
         }
     }
 }
All Usage Examples Of SharpDX.DirectWrite.TextLayout::SetDrawingEffect