Freigeben über


Shape.Region-Eigenschaft

Ruft den einem Line- oder Shape-Steuerelement zugeordneten Fensterbereich ab oder legt diesen fest.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property Region As Region
[BrowsableAttribute(false)]
public Region Region { get; set; }
[BrowsableAttribute(false)]
public:
property Region^ Region {
    Region^ get ();
    void set (Region^ value);
}
[<BrowsableAttribute(false)>]
member Region : Region with get, set
function get Region () : Region 
function set Region (value : Region)

Eigenschaftswert

Typ: Region
Die dem Steuerelement zugeordnete Fenster-Region.

Hinweise

Die Fensterbereich ist eine Sammlung von Pixel im Fenster, in dem das Betriebssystem Zeichnen kann. Das Betriebssystem wird nicht einen beliebigen Teil eines Fensters angezeigt, die außerhalb des Bereichs des Fensters. Die Koordinaten des Bereichs eines Steuerelements werden relativ zu der oberen linken Ecke des Steuerelements, nicht den Clientbereich des Steuerelements.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie die Region -Eigenschaft ändern einer RectangleShape in eine halbtransparente Ellipse. In diesem Beispiel benötigen Sie ein RectangleShape mit dem Namen RectangleShape1 in einem Formular. Um halbtransparente auswirkt, weisen Sie ein Bild, um die BackgroundImage -Eigenschaft des Formulars.

Private Sub RectangleShape1_Paint(
    ByVal sender As Object, 
    ByVal e As System.Windows.Forms.PaintEventArgs
  ) Handles RectangleShape1.Paint

    Dim shapePath As New System.Drawing.Drawing2D.GraphicsPath

    ' Set a new rectangle to the same size as the RectangleShape's  
    ' ClientRectangle property. 
    Dim newRectangle As Rectangle = RectangleShape1.ClientRectangle

    ' Decrease the size of the rectangle.
    newRectangle.Inflate(-10, -10)

    ' Draw the new rectangle's border.
    e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle)

    ' Create a semi-transparent brush. 
    Dim br As New SolidBrush(Color.FromArgb(128, 0, 0, 255))

    ' Fill the new rectangle.
    e.Graphics.FillEllipse(br, newRectangle)
    'Increase the size of the rectangle to include the border.
    newRectangle.Inflate(1, 1)

    ' Create an oval region within the new rectangle.
    shapePath.AddEllipse(newRectangle)
    e.Graphics.DrawPath(Pens.Black, shapePath)

    ' Set the RectangleShape's Region property to the newly created  
    ' oval region.
    RectangleShape1.Region = New System.Drawing.Region(shapePath)
End Sub
private void rectangleShape1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{

    System.Drawing.Drawing2D.GraphicsPath shapePath = new System.Drawing.Drawing2D.GraphicsPath();

    // Set a new rectangle to the same size as the RectangleShape's  
    // ClientRectangle property.
    Rectangle newRectangle = rectangleShape1.ClientRectangle;

    // Decrease the size of the rectangle.
    newRectangle.Inflate(-10, -10);

    // Draw the new rectangle's border.
    e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle);

    // Create a semi-transparent brush.
    SolidBrush br = new SolidBrush(Color.FromArgb(128, 0, 0, 255));

    // Fill the new rectangle.
    e.Graphics.FillEllipse(br, newRectangle);
    //Increase the size of the rectangle to include the border.
    newRectangle.Inflate(1, 1);

    // Create an oval region within the new rectangle.
    shapePath.AddEllipse(newRectangle);
    e.Graphics.DrawPath(Pens.Black, shapePath);

    // Set the RectangleShape's Region property to the newly created  
    // oval region.
    rectangleShape1.Region = new System.Drawing.Region(shapePath);
}

.NET Framework-Sicherheit

Siehe auch

Referenz

Shape Klasse

Microsoft.VisualBasic.PowerPacks-Namespace

Weitere Ressourcen

Gewusst wie: Zeichnen von Linien mit dem LineShape-Steuerelement (Visual Studio)

Gewusst wie: Zeichnen von Formen mit dem OvalShape-Steuerelement und dem RectangleShape-Steuerelement (Visual Studio)

Einführung in das Line-Steuerelement und das Shape-Steuerelement (Visual Studio)