Język

Rectangle Konstruktory

Definicja

Inicjuje nowe wystąpienie Rectangle klasy z określoną lokalizacją i rozmiarem.

Przeciążenia

Nazwa Opis
Rectangle(Point, Size)

Inicjuje nowe wystąpienie Rectangle klasy z określoną lokalizacją i rozmiarem.

Rectangle(Int32, Int32, Int32, Int32)

Inicjuje nowe wystąpienie Rectangle klasy z określoną lokalizacją i rozmiarem.

Rectangle(Point, Size)

Źródło:
Rectangle.cs
Źródło:
Rectangle.cs
Źródło:
Rectangle.cs
Źródło:
Rectangle.cs
Źródło:
Rectangle.cs

Inicjuje nowe wystąpienie Rectangle klasy z określoną lokalizacją i rozmiarem.

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

Element Point reprezentujący lewy górny róg prostokątnego regionu.

size
Size

Obiekt Size reprezentujący szerokość i wysokość prostokątnego regionu.

Dotyczy

Rectangle(Int32, Int32, Int32, Int32)

Źródło:
Rectangle.cs
Źródło:
Rectangle.cs
Źródło:
Rectangle.cs
Źródło:
Rectangle.cs
Źródło:
Rectangle.cs

Inicjuje nowe wystąpienie Rectangle klasy z określoną lokalizacją i rozmiarem.

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

Współrzędna x lewego górnego rogu prostokąta.

y
Int32

Współrzędna y lewego górnego rogu prostokąta.

width
Int32

Szerokość prostokąta.

height
Int32

Wysokość prostokąta.

Przykłady

W poniższym przykładzie kodu przedstawiono Rectangleelementy członkowskie , Intersect, IsEmptyi IntersectsWith . Ten przykład powinien być używany z formularzem Windows. Wklej ten kod do formularza i wywołaj tę metodę podczas obsługi zdarzenia formularza Paint , przekazując 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

Dotyczy