SimpleShape.BackgroundImageLayoutChanged Event

 

Occurs when the BackgroundImageLayout property of a shape is changed.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

[BrowsableAttribute(true)]
public event EventHandler BackgroundImageLayoutChanged

This event is raised if the BackgroundImageLayout property is changed by either a programmatic modification or user interaction.

For more information about how to handle events, see Handling and Raising Events.

The following example shows how to respond to the BackgroundImageLayoutChanged event in an event handler. This example requires that you have a RectangleShape control named RectangleShape1 on a form.

private void rectangleShape1_BackgroundImageLayoutChanged(object sender, 
    System.EventArgs e)
{
    // If the image is centered, check its size.
    if (rectangleShape1.BackgroundImageLayout == ImageLayout.Center)
    {
        SizeF imageSize;
        imageSize = rectangleShape1.BackgroundImage.PhysicalDimension;
        // If the image is smaller than the shape, change the BackColor.
        if (imageSize.Height < rectangleShape1.ClientSize.Height || 
            imageSize.Width < rectangleShape1.ClientSize.Width)
        {
            rectangleShape1.BackColor = Color.Black;
        }
    }
}
Return to top
Show: