Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D2D1LayerParameters"/> struct.
 /// </summary>
 /// <param name="contentBounds">The content bounds of the layer. Content outside these bounds is not guaranteed to render.</param>
 /// <param name="geometricMask">The geometric mask specifies the area of the layer that is composited into the render target.</param>
 /// <param name="maskAntialiasMode">A value that specifies the antialiasing mode for the geometricMask.</param>
 /// <param name="maskTransform">A value that specifies the transform that is applied to the geometric mask when composing the layer.</param>
 /// <param name="opacity">An opacity value that is applied uniformly to all resources in the layer when compositing to the target.</param>
 /// <param name="opacityBrush">A brush that is used to modify the opacity of the layer. The brush is mapped to the layer, and the alpha channel of each mapped brush pixel is multiplied against the corresponding layer pixel.</param>
 /// <param name="layerOptions">A value that specifies whether the layer intends to render text with ClearType antialiasing.</param>
 public D2D1LayerParameters(
     D2D1RectF contentBounds,
     D2D1Geometry geometricMask,
     D2D1AntialiasMode maskAntialiasMode,
     D2D1Matrix3X2F maskTransform,
     float opacity,
     D2D1Brush opacityBrush,
     D2D1LayerOptions layerOptions)
 {
     this.contentBounds     = contentBounds;
     this.geometricMask     = geometricMask == null ? null : geometricMask.GetHandle <ID2D1Geometry>();
     this.maskAntialiasMode = maskAntialiasMode;
     this.maskTransform     = maskTransform;
     this.opacity           = opacity;
     this.opacityBrush      = opacityBrush == null ? null : opacityBrush.GetHandle <ID2D1Brush>();
     this.layerOptions      = layerOptions;
 }
        public void DrawLine(D2D1Point2F point0, D2D1Point2F point1, D2D1Brush brush, float strokeWidth, D2D1StrokeStyle strokeStyle)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawLine(point0, point1, brush.GetHandle<ID2D1Brush>(), strokeWidth, strokeStyle == null ? null : strokeStyle.GetHandle<ID2D1StrokeStyle>());
        }
        public void DrawLine(D2D1Point2F point0, D2D1Point2F point1, D2D1Brush brush)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawLine(point0, point1, brush.GetHandle<ID2D1Brush>(), 1.0f, null);
        }
        public void DrawGlyphRun(D2D1Point2F baselineOrigin, DWriteGlyphRun glyphRun, D2D1Brush foregroundBrush, DWriteMeasuringMode measuringMode)
        {
            if (foregroundBrush == null)
            {
                throw new ArgumentNullException("foregroundBrush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawGlyphRun(baselineOrigin, ref glyphRun, foregroundBrush.GetHandle<ID2D1Brush>(), measuringMode);
        }
        public void DrawTextLayout(D2D1Point2F origin, DWriteTextLayout textLayout, D2D1Brush defaultForegroundBrush, D2D1DrawTextOptions options)
        {
            if (textLayout == null)
            {
                throw new ArgumentNullException("textLayout");
            }

            if (defaultForegroundBrush == null)
            {
                throw new ArgumentNullException("defaultForegroundBrush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawTextLayout(origin, (IDWriteTextLayout)textLayout.Handle, defaultForegroundBrush.GetHandle<ID2D1Brush>(), options);
        }
        public void DrawText(string text, DWriteTextFormat textFormat, D2D1RectF layoutRect, D2D1Brush defaultForegroundBrush, D2D1DrawTextOptions options, DWriteMeasuringMode measuringMode)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (textFormat == null)
            {
                throw new ArgumentNullException("textFormat");
            }

            if (defaultForegroundBrush == null)
            {
                throw new ArgumentNullException("defaultForegroundBrush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawText(text, (uint)text.Length, (IDWriteTextFormat)textFormat.Handle, ref layoutRect, defaultForegroundBrush.GetHandle<ID2D1Brush>(), options, measuringMode);
        }
        public void FillOpacityMask(D2D1Bitmap opacityMask, D2D1Brush brush, D2D1OpacityMaskContent content, D2D1RectF destinationRectangle, D2D1RectF sourceRectangle)
        {
            if (opacityMask == null)
            {
                throw new ArgumentNullException("opacityMask");
            }

            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            GCHandle destinationRectangleHandle = GCHandle.Alloc(destinationRectangle, GCHandleType.Pinned);
            GCHandle sourceRectangleHandle = GCHandle.Alloc(sourceRectangle, GCHandleType.Pinned);

            try
            {
                this.GetHandle<ID2D1RenderTarget>().FillOpacityMask(opacityMask.GetHandle<ID2D1Bitmap>(), brush.GetHandle<ID2D1Brush>(), content, destinationRectangleHandle.AddrOfPinnedObject(), sourceRectangleHandle.AddrOfPinnedObject());
            }
            finally
            {
                destinationRectangleHandle.Free();
                sourceRectangleHandle.Free();
            }
        }
        public void FillRoundedRectangle(D2D1RoundedRect roundedRect, D2D1Brush brush)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().FillRoundedRectangle(ref roundedRect, brush.GetHandle<ID2D1Brush>());
        }
        public void FillMesh(D2D1Mesh mesh, D2D1Brush brush)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException("mesh");
            }

            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().FillMesh(mesh.GetHandle<ID2D1Mesh>(), brush.GetHandle<ID2D1Brush>());
        }
        public void FillGeometry(D2D1Geometry geometry, D2D1Brush brush, D2D1Brush opacityBrush)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException("geometry");
            }

            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().FillGeometry(geometry.GetHandle<ID2D1Geometry>(), brush.GetHandle<ID2D1Brush>(), opacityBrush == null ? null : opacityBrush.GetHandle<ID2D1Brush>());
        }
        public void DrawGeometry(D2D1Geometry geometry, D2D1Brush brush, float strokeWidth, D2D1StrokeStyle strokeStyle)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException("geometry");
            }

            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawGeometry(geometry.GetHandle<ID2D1Geometry>(), brush.GetHandle<ID2D1Brush>(), strokeWidth, strokeStyle == null ? null : strokeStyle.GetHandle<ID2D1StrokeStyle>());
        }
        public void DrawGeometry(D2D1Geometry geometry, D2D1Brush brush)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException("geometry");
            }

            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawGeometry(geometry.GetHandle<ID2D1Geometry>(), brush.GetHandle<ID2D1Brush>(), 1.0f, null);
        }
        public void FillEllipse(D2D1Ellipse ellipse, D2D1Brush brush)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().FillEllipse(ref ellipse, brush.GetHandle<ID2D1Brush>());
        }
        public void DrawEllipse(D2D1Ellipse ellipse, D2D1Brush brush, float strokeWidth, D2D1StrokeStyle strokeStyle)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawEllipse(ref ellipse, brush.GetHandle<ID2D1Brush>(), strokeWidth, strokeStyle == null ? null : strokeStyle.GetHandle<ID2D1StrokeStyle>());
        }
        public void DrawRectangle(D2D1RectF rect, D2D1Brush brush, float strokeWidth)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawRectangle(ref rect, brush.GetHandle<ID2D1Brush>(), strokeWidth, null);
        }
        public void FillOpacityMask(D2D1Bitmap opacityMask, D2D1Brush brush, D2D1OpacityMaskContent content)
        {
            if (opacityMask == null)
            {
                throw new ArgumentNullException("opacityMask");
            }

            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().FillOpacityMask(opacityMask.GetHandle<ID2D1Bitmap>(), brush.GetHandle<ID2D1Brush>(), content, IntPtr.Zero, IntPtr.Zero);
        }
        public void DrawRoundedRectangle(D2D1RoundedRect roundedRect, D2D1Brush brush, float strokeWidth, D2D1StrokeStyle strokeStyle)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            this.GetHandle<ID2D1RenderTarget>().DrawRoundedRectangle(ref roundedRect, brush.GetHandle<ID2D1Brush>(), strokeWidth, strokeStyle == null ? null : strokeStyle.GetHandle<ID2D1StrokeStyle>());
        }