Share via


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

[BrowsableAttribute(true)]
public event EventHandler BackgroundImageLayoutChanged
public:
[BrowsableAttribute(true)]
event EventHandler^ BackgroundImageLayoutChanged {
    void add(EventHandler^ value);
    void remove(EventHandler^ value);
}
[<BrowsableAttribute(true)>]
member BackgroundImageLayoutChanged : IEvent<EventHandler,
    EventArgs>
<BrowsableAttribute(True)>
Public Event BackgroundImageLayoutChanged As EventHandler

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 Handling and Raising 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 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;
        }
    }
}
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

See Also

SimpleShape Class
Microsoft.VisualBasic.PowerPacks Namespace
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)

Return to top