packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct2D/ChartDemo/Window1.xaml.cs
/// <summary>
/// Create the grid pattern (squares) brush 
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
Create the grid pattern (squares) brush
Create the grid pattern ( squares ) brush
BitmapBrush CreateGridPatternBrush(RenderTarget target)
        {
            BitmapRenderTarget compatibleRenderTarget =
                target.CreateCompatibleRenderTarget(CompatibleRenderTargetOptions.None, new SizeF(10.0f, 10.0f));
            SolidColorBrush spGridBrush = compatibleRenderTarget.CreateSolidColorBrush(new ColorF(0.93f, 0.94f, 0.96f, 1.0f));
            compatibleRenderTarget.BeginDraw();
            compatibleRenderTarget.FillRectangle(new RectF(0.0f, 0.0f, 10.0f, 1.0f), spGridBrush);
            compatibleRenderTarget.FillRectangle(new RectF(0.0f, 0.1f, 1.0f, 10.0f), spGridBrush);
            compatibleRenderTarget.EndDraw();
            D2DBitmap spGridBitmap;
            spGridBitmap = compatibleRenderTarget.Bitmap;
            BitmapBrushProperties brushProperties = new BitmapBrushProperties(ExtendMode.Wrap, ExtendMode.Wrap, BitmapInterpolationMode.Linear);
            return renderTarget.CreateBitmapBrush(spGridBitmap, brushProperties);
        }
BitmapBrush CreateGridPatternBrush ( RenderTarget target ) { BitmapRenderTarget compatibleRenderTarget = target . CreateCompatibleRenderTarget ( CompatibleRenderTargetOptions . None , new SizeF ( 10.0f , 10.0f ) ) ; SolidColorBrush spGridBrush = compatibleRenderTarget . CreateSolidColorBrush ( new ColorF ( 0.93f , 0.94f , 0.96f , 1.0f ) ) ; compatibleRenderTarget . BeginDraw ( ) ; compatibleRenderTarget . FillRectangle ( new RectF ( 0.0f , 0.0f , 10.0f , 1.0f ) , spGridBrush ) ; compatibleRenderTarget . FillRectangle ( new RectF ( 0.0f , 0.1f , 1.0f , 10.0f ) , spGridBrush ) ; compatibleRenderTarget . EndDraw ( ) ; D2DBitmap spGridBitmap ; spGridBitmap = compatibleRenderTarget . Bitmap ; BitmapBrushProperties brushProperties = new BitmapBrushProperties ( ExtendMode . Wrap , ExtendMode . Wrap , BitmapInterpolationMode . Linear ) ; return renderTarget . CreateBitmapBrush ( spGridBitmap , brushProperties ) ; }
Create the grid pattern (squares) brush
Create the grid pattern ( squares ) brush
// Create a compatible render target. //// Draw a pattern. //// Retrieve the bitmap from the render target. //// Choose the tiling mode for the bitmap brush. //// Create the bitmap brush.
None
target
RenderTarget
None