Infragistics(R) NetAdvantage(R) Windows Forms
ShapeImage Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.Misc Namespace > UltraButton Class : ShapeImage Property

Gets/sets the image used to generate the shape for the control.

Syntax

Visual Basic (Declaration) 
Public Property ShapeImage As Image
C# 
public Image ShapeImage {get; set;}

Example

The following sample demonstrates using the ShapeImage functionality of the UltraButton.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Misc

Private Sub CreateShapeImage(ByVal button As Infragistics.Win.Misc.UltraButton)
    ' create a bitmap that will be used to provide the shape
    ' of the button.
    Dim bitmap As Bitmap = New Bitmap(100, 100)

    ' create a temporary graphics object so we can render into it
    Dim g As Graphics

    Try
        g = Graphics.FromImage(bitmap)

        ' draw the background in white. whatever color
        ' is in the lower left hand pixel will be assumed
        ' to be transparent
        g.Clear(Color.White)

        ' draw our circle in a different color
        g.DrawEllipse(Pens.Black, 0, 0, 99, 99)

        ' make sure to fill it in or the only displayed
        ' part of the button will be the outline of the
        ' circle
        g.FillEllipse(Brushes.Black, 0, 0, 99, 99)
    Finally
        g.Dispose()
    End Try

    ' set the shape
    button.ShapeImage = bitmap

    ' autosize to the shape image
    button.AutoSize = True
End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Misc;

private void CreateShapeImage(Infragistics.Win.Misc.UltraButton button)
{
	// create a bitmap that will be used to provide the shape
	// of the button.
	Bitmap bitmap = new Bitmap(100,100);

	// create a temporary graphics object so we can render into it
	using (Graphics g = Graphics.FromImage(bitmap))
	{
		// draw the background in white. whatever color
		// is in the lower left hand pixel will be assumed
		// to be transparent
		g.Clear( Color.White );

		// draw our circle in a different color
		g.DrawEllipse( Pens.Black , 0, 0, 99, 99 );

		// make sure to fill it in or the only displayed
		// part of the button will be the outline of the
		// circle
		g.FillEllipse( Brushes.Black, 0, 0, 99, 99 );
	}

	// set the shape
	button.ShapeImage = bitmap;

	// autosize to the shape image
	button.AutoSize = true;
}

Remarks

The ShapeImage property is used to create a non-rectangular shaped button. The image specified for this property is used to create the region for the button control as well as being used to render the borders of the button. The color in the lower left hand pixel of the image is used to determine which color will be "masked" out - that is, which color will determine the areas of the image that are considered transparent. All pixels that do not match this color are considered to be opaque and will make up the displayed area of the button.

See Also