Export (0) Print
Expand All

WrapMode Enumeration

Specifies how a texture or gradient is tiled when it is smaller than the area being filled.

Namespace: System.Drawing.Drawing2D
Assembly: System.Drawing (in system.drawing.dll)

public enum WrapMode
public enum WrapMode
public enum WrapMode

 Member nameDescription
ClampThe texture or gradient is not tiled. 
TileTiles the gradient or texture. 
TileFlipXReverses the texture or gradient horizontally and then tiles the texture or gradient. 
TileFlipXYReverses the texture or gradient horizontally and vertically and then tiles the texture or gradient. 
TileFlipYReverses the texture or gradient vertically and then tiles the texture or gradient. 

Brushes use this enumeration to determine how shapes are filled. To see examples of the effects the WrapMode enumeration values have on a tiled image, see How to: Tile a Shape with an Image.

The following code example demonstrates how to obtain a new bitmap using the FromFile method. It also demonstrates a TextureBrush and the WrapMode enumeration. This example is designed to be used with Windows Forms. Create a form containing a button named Button2. Paste the code into the form and associate the Button2_Click method with the button's Click event.

private void Button2_Click(System.Object sender, System.EventArgs e)
{
    try
    {
        Bitmap image1 = (Bitmap) Image.FromFile(@"C:\Documents and Settings\" +
            @"All Users\Documents\My Music\music.bmp", true);

        TextureBrush texture = new TextureBrush(image1);
        texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
        Graphics formGraphics = this.CreateGraphics();
        formGraphics.FillEllipse(texture, 
            new RectangleF(90.0F, 110.0F, 100, 100));
        formGraphics.Dispose();

    }
    catch(System.IO.FileNotFoundException)
    {
        MessageBox.Show("There was an error opening the bitmap." +
            "Please check the path.");
    }

}

private void button2_Click(Object sender, System.EventArgs e)
{
    try {
        Bitmap image1 = ((Bitmap)(Image.FromFile(
            "C:\\Documents and Settings\\"  
            + "All Users\\Documents\\My Music\\music.bmp", true)));
        TextureBrush texture = new TextureBrush(image1);

        texture.set_WrapMode(System.Drawing.Drawing2D.WrapMode.Tile);

        Graphics formGraphics = this.CreateGraphics();

        formGraphics.FillEllipse(texture, new RectangleF(90, 110, 100,100));
        formGraphics.Dispose();
    }
    catch (System.IO.FileNotFoundException exp) {
        MessageBox.Show(("There was an error opening the bitmap."  
            + "Please check the path."));
    }
} //button2_Click

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft