Rectangle Konstruktory

Definice

Inicializuje novou instanci Rectangle třídy se zadaným umístěním a velikostí.

Přetížení

Name Description
Rectangle(Point, Size)

Inicializuje novou instanci Rectangle třídy se zadaným umístěním a velikostí.

Rectangle(Int32, Int32, Int32, Int32)

Inicializuje novou instanci Rectangle třídy se zadaným umístěním a velikostí.

Rectangle(Point, Size)

Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs

Inicializuje novou instanci Rectangle třídy se zadaným umístěním a velikostí.

public:
 Rectangle(System::Drawing::Point location, System::Drawing::Size size);
public Rectangle(System.Drawing.Point location, System.Drawing.Size size);
new System.Drawing.Rectangle : System.Drawing.Point * System.Drawing.Size -> System.Drawing.Rectangle
Public Sub New (location As Point, size As Size)

Parametry

location
Point

A Point , který představuje levý horní roh obdélníkové oblasti.

size
Size

A Size představující šířku a výšku obdélníkové oblasti.

Platí pro

Rectangle(Int32, Int32, Int32, Int32)

Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs
Zdroj:
Rectangle.cs

Inicializuje novou instanci Rectangle třídy se zadaným umístěním a velikostí.

public:
 Rectangle(int x, int y, int width, int height);
public Rectangle(int x, int y, int width, int height);
new System.Drawing.Rectangle : int * int * int * int -> System.Drawing.Rectangle
Public Sub New (x As Integer, y As Integer, width As Integer, height As Integer)

Parametry

x
Int32

Souřadnice x levého horního rohu obdélníku.

y
Int32

Souřadnice y levého horního rohu obdélníku.

width
Int32

Šířka obdélníku.

height
Int32

Výška obdélníku.

Příklady

Následující příklad kódu ukazuje Rectangle, , IntersectIsEmptya IntersectsWith členové. Tento příklad by měl být použit s formulářem Windows. Vložte tento kód do formuláře a zavolejte tuto metodu při zpracování události formuláře Paint a předejte e jako PaintEventArgs.

private:
   void InstanceRectangleIntersection( PaintEventArgs^ e )
   {
      Rectangle rectangle1 = Rectangle(50,50,200,100);
      Rectangle rectangle2 = Rectangle(70,20,100,200);
      e->Graphics->DrawRectangle( Pens::Black, rectangle1 );
      e->Graphics->DrawRectangle( Pens::Red, rectangle2 );
      if ( rectangle1.IntersectsWith( rectangle2 ) )
      {
         rectangle1.Intersect( rectangle2 );
         if (  !rectangle1.IsEmpty )
         {
            e->Graphics->FillRectangle( Brushes::Green, rectangle1 );
         }
      }
   }
private void InstanceRectangleIntersection(PaintEventArgs e)
{

    Rectangle rectangle1 = new Rectangle(50, 50, 200, 100);
    Rectangle rectangle2 = new Rectangle(70, 20, 100, 200);

    e.Graphics.DrawRectangle(Pens.Black, rectangle1);
    e.Graphics.DrawRectangle(Pens.Red, rectangle2);

    if (rectangle1.IntersectsWith(rectangle2))
    {
        rectangle1.Intersect(rectangle2);
        if (!rectangle1.IsEmpty)
        {
            e.Graphics.FillRectangle(Brushes.Green, rectangle1);
        }
    }
}
  Private Sub InstanceRectangleIntersection( _
      ByVal e As PaintEventArgs)

      Dim rectangle1 As New Rectangle(50, 50, 200, 100)
      Dim rectangle2 As New Rectangle(70, 20, 100, 200)

      e.Graphics.DrawRectangle(Pens.Black, rectangle1)
      e.Graphics.DrawRectangle(Pens.Red, rectangle2)

      If (rectangle1.IntersectsWith(rectangle2)) Then
          rectangle1.Intersect(rectangle2)
          If Not (rectangle1.IsEmpty) Then
              e.Graphics.FillRectangle(Brushes.Green, rectangle1)
          End If
      End If
  End Sub

Platí pro