예제 #1
0
 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);
     }
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
    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
        {
        }
    }
예제 #5
0
 public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush)
 {
     renderTarget.DrawLine(P1.ToPoint(), P2.ToPoint(), brush);
 }
예제 #6
0
 public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush) => renderTarget.DrawRectangle(Rect, brush);
예제 #7
0
 public CustomColorRenderer(ID2D1RenderTarget renderTarget, ID2D1SolidColorBrush defaultBrush)
 {
     _renderTarget = renderTarget;
     _defaultBrush = defaultBrush;
 }
예제 #8
0
 public override void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush)
 {
     renderTarget.DrawEllipse(Ellipse, brush, 1.0f);
 }
 internal D2D1SolidColorBrush(ID2D1SolidColorBrush brush)
 {
     this.brush = brush;
 }
예제 #10
0
 public abstract void Draw(ID2D1DeviceContext renderTarget, ID2D1SolidColorBrush brush);
 internal D2D1SolidColorBrush(ID2D1SolidColorBrush brush)
 {
     this.brush = brush;
 }