Exemple #1
0
        void Render()
        {
            if (resized)
            {
                Resize();
                resized = false;
            }

            d2dDeviceContext.BeginDraw();
            d2dDeviceContext.Clear(Color4.White);

            d2dDeviceContext.PushAxisAlignedClip(new RectangleF(5, 5, Child.Width - 10, Child.Height - 10), AntialiasMode.Aliased);
            d2dDeviceContext.Transform = Matrix3x2.Translation(Child.Width / 2f / Scale + Translation.X, Child.Height / 2f / Scale + Translation.Y) * Matrix3x2.Scaling(Scale);

            d2dDeviceContext.AntialiasMode = AntialiasMode.Aliased;
            d2dDeviceContext.DrawLine(new Vector2(0, int.MinValue), new Vector2(0, int.MaxValue), RasterDrawBrush, 1 / Scale);
            d2dDeviceContext.DrawLine(new Vector2(int.MinValue, 0), new Vector2(int.MaxValue, 0), RasterDrawBrush, 1 / Scale);
            d2dDeviceContext.AntialiasMode = AntialiasMode.PerPrimitive;

            RenderGeometry();

            d2dDeviceContext.Transform = Matrix3x2.Identity;
            d2dDeviceContext.PopAxisAlignedClip();

            d2dDeviceContext.EndDraw();
            swapChain.Present(0, PresentFlags.None);
        }
Exemple #2
0
        public void EndDraw()
        {
            // Remove the transform and clip applied in BeginDraw since
            // the target area can change on every update.
            d2dContext.Transform = Matrix3x2.Identity;
            d2dContext.PopAxisAlignedClip();

            // Remove the render target and end drawing.
            d2dContext.EndDraw();

            d2dContext.Target = null;

            // Query for ISurfaceImageSourceNative interface.
            using (var sisNative = ComObject.QueryInterface <ISurfaceImageSourceNative>(this))
                sisNative.EndDraw();
        }