public void InitializeDevice(IntPtr windowHandle) { D3Device = DirectXTools.CreateD3Device(); { RenderTarget = DirectXTools.CreateRenderTarget(Direct2DFactory, D3Device); _solidBrush = RenderTarget.CreateSolidColorBrush(Color4.Black); SwapChain = DirectXTools.CreateSwapChainForHwnd(D3Device, windowHandle); DirectXTools.CreateDeviceSwapChainBitmap(SwapChain, RenderTarget); Bitmaps.SetRenderTarget(RenderTarget); TextLayouts.SetRenderTarget(RenderTarget); } }
public void InitializeDeviceGdiCompatible(IntPtr windowHandle, int width, int height) { D3Device = DirectXTools.CreateD3Device(); { RenderTarget = DirectXTools.CreateRenderTarget(Direct2DFactory, D3Device); _solidBrush = RenderTarget.CreateSolidColorBrush(Color4.Black); SwapChain = DirectXTools.CreateSwapChainForHwnd(D3Device, windowHandle); //DirectXTools.CreateDeviceSwapChainBitmap(SwapChain, RenderTarget); DirectXTools.CreateDeviceContextCPUBitmap(RenderTarget, width, height); Bitmaps.SetRenderTarget(RenderTarget); TextLayouts.SetRenderTarget(RenderTarget); } }
public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush) { var lines = new[] { new [] { Points[0], Points[1] }, new [] { Points[1], Points[2] }, new [] { Points[2], Points[3] }, new [] { Points[3], Points[0] }, }; foreach (var line in lines) { renderTarget.DrawLine(line[0].ToPoint(), line[1].ToPoint(), brush, 2.0f); } }
public override void DrawGlyphRun(IntPtr clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, IUnknown clientDrawingEffect) { ID2D1SolidColorBrush brush = _defaultBrush; if (clientDrawingEffect is ComObject comObject) { brush = comObject.QueryInterfaceOrNull <ID2D1SolidColorBrush>(); } try { _renderTarget.DrawGlyphRun( new System.Drawing.PointF(baselineOriginX, baselineOriginY), glyphRun, brush, measuringMode); } catch { } }
public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush) { renderTarget.DrawLine(P1.ToPoint(), P2.ToPoint(), brush); }
public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush) => renderTarget.DrawRectangle(Rect, brush);
public CustomColorRenderer(ID2D1RenderTarget renderTarget, ID2D1SolidColorBrush defaultBrush) { _renderTarget = renderTarget; _defaultBrush = defaultBrush; }
public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush) { renderTarget.DrawEllipse(Ellipse, brush, 1.0f); }
internal D2D1SolidColorBrush(ID2D1SolidColorBrush brush) { this.brush = brush; }
public abstract void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush);