示例#1
0
        public void CreateRenderTarget(SharpDX.WIC.Bitmap wicBitmap)
        {
            if (renderTarget != null)
            {
                return;
            }
            float dpiX = 96, dpiY = 96;

            using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero))
            {
                dpiX = graphics.DpiX;
                dpiY = graphics.DpiY;
            }

            var renderTargetProperties = new RenderTargetProperties(
                RenderTargetType.Default,
                new SharpDX.Direct2D1.PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Unknown),
                dpiX, dpiY, RenderTargetUsage.GdiCompatible, FeatureLevel.Level_DEFAULT);

            renderTarget = new WicRenderTarget(d2dFactory, wicBitmap, renderTargetProperties);

            IntPtr gdirtPtr;

            renderTarget.QueryInterface(Guid.Parse("e0db51c3-6f77-4bae-b3d5-e47509b35838"), out gdirtPtr);
            gdiRenderTarget = new GdiInteropRenderTarget(gdirtPtr);
        }
示例#2
0
        public void CreateRenderTarget(Control control)
        {
            if (renderTarget != null)
            {
                return;
            }

            var properties = new HwndRenderTargetProperties
            {
                Hwnd           = control.Handle,
                PixelSize      = new Size2(control.Width, control.Height),
                PresentOptions = PresentOptions.Immediately | PresentOptions.RetainContents
            };


            RenderTargetProperties rtProps = new RenderTargetProperties();

            rtProps.Usage = RenderTargetUsage.GdiCompatible;

            renderTarget = new WindowRenderTarget(d2dFactory, rtProps, properties)
            {
                AntialiasMode     = AntialiasMode.PerPrimitive,
                TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Cleartype
            };


            IntPtr gdirtPtr;

            renderTarget.QueryInterface(Guid.Parse("e0db51c3-6f77-4bae-b3d5-e47509b35838"), out gdirtPtr);
            gdiRenderTarget = new GdiInteropRenderTarget(gdirtPtr);
        }
示例#3
0
 public override void Dispose()
 {
     if (gdiRenderTarget != null)
     {
         gdiRenderTarget.Dispose();
     }
     gdiRenderTarget = null;
     base.Dispose();
 }
 protected override void OnPostDraw()
 {
     using (GdiInteropRenderTarget gdi = XResource.RenderTarget.QueryInterface <GdiInteropRenderTarget>())
     {
         var hdc = gdi.GetDC(DeviceContextInitializeMode.Copy);
         layeredWindowCtx.Draw(Handle, hdc);
         gdi.ReleaseDC(null);
     }
 }
示例#5
0
 protected internal override void ChangeRenderTarget(RenderTarget newRenderTarget)
 {
     if (RenderTargetSupportsGDI(newRenderTarget))
     {
         gdiRenderTarget = newRenderTarget.GdiInteropRenderTarget;
     }
     else if (gdiRenderTarget != null)
     {
         gdiRenderTarget.Dispose();
         gdiRenderTarget = null;
     }
 }
示例#6
0
        public GDIEllipsesShape(RenderTarget initialRenderTarget, Random random, D2DFactory d2DFactory, D2DBitmap bitmap, int count)
            : base(initialRenderTarget, random, d2DFactory, bitmap)
        {
            for (int i = 0; i < count; i++)
            {
                ellipses.Add(RandomGdiEllipse());
            }

            if (RenderTargetSupportsGDI(RenderTarget))
            {
                gdiRenderTarget = RenderTarget.GdiInteropRenderTarget;
            }
        }
示例#7
0
        public GDIEllipsesShape(RenderTarget initialRenderTarget, Random random, D2DFactory d2DFactory, D2DBitmap bitmap, int count)
            : base(initialRenderTarget, random, d2DFactory, bitmap)
        {
            for(int i = 0; i < count; i++)
            {
                ellipses.Add(RandomGdiEllipse());
            }

            if (RenderTargetSupportsGDI(RenderTarget))
            {
                gdiRenderTarget = RenderTarget.GetGdiInteropRenderTarget();
            }
        }
示例#8
0
        public override void Dispose()
        {
            if (gdiRenderTarget != null)
            {
                gdiRenderTarget.Dispose();
                gdiRenderTarget = null;
            }

            if (renderTarget != null)
            {
                renderTarget.Dispose();
                renderTarget = null;
            }
        }
示例#9
0
 protected internal override void ChangeRenderTarget(RenderTarget newRenderTarget)
 {
     if (RenderTargetSupportsGDI(newRenderTarget))
     {
         gdiRenderTarget = newRenderTarget.GetGdiInteropRenderTarget();
     }
     else if (gdiRenderTarget != null)
     {
         gdiRenderTarget.Dispose();
         gdiRenderTarget = null;
     }
 }
示例#10
0
 public override void Dispose()
 {
     if (gdiRenderTarget != null)
         gdiRenderTarget.Dispose();
     gdiRenderTarget = null;
     base.Dispose();
 }