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)

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Event BackgroundImageLayoutChanged As EventHandler
[BrowsableAttribute(true)]
public event EventHandler BackgroundImageLayoutChanged
[BrowsableAttribute(true)]
public:
 event EventHandler^ BackgroundImageLayoutChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
[<BrowsableAttribute(true)>]
member BackgroundImageLayoutChanged : IEvent<EventHandler,
    EventArgs>
JScript does not support events.

Remarks

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 Consuming Events.

Examples

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 Sub RectangleShape1_BackgroundImageLayoutChanged(
  ) Handles RectangleShape1.BackgroundImageLayoutChanged

    ' If the image is centered, check its size.
    If RectangleShape1.BackgroundImageLayout = ImageLayout.Center Then
        Dim imageSize As SizeF
        imageSize = RectangleShape1.BackgroundImage.PhysicalDimension
        ' If the image is smaller than the shape, change the BackColor.
        If imageSize.Height < RectangleShape1.ClientSize.Height OrElse
          imageSize.Width < RectangleShape1.ClientSize.Width Then
            RectangleShape1.BackColor = Color.Black
        End If
    End If
End Sub
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;
        }
    }
}

.NET Framework Security

See Also

Reference

SimpleShape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

Introduction to the Line and Shape Controls (Visual Studio)

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)