Uređivanje

Dijeli putem


Region.Xor Method

Definition

Updates this Region object to the union minus the intersection of itself with the specified GraphicsPath object.

Overloads

Xor(GraphicsPath)

Updates this Region to the union minus the intersection of itself with the specified GraphicsPath.

Xor(Rectangle)

Updates this Region to the union minus the intersection of itself with the specified Rectangle structure.

Xor(RectangleF)

Updates this Region to the union minus the intersection of itself with the specified RectangleF structure.

Xor(Region)

Updates this Region to the union minus the intersection of itself with the specified Region.

Xor(GraphicsPath)

Source:
Region.cs
Source:
Region.cs

Updates this Region to the union minus the intersection of itself with the specified GraphicsPath.

public:
 void Xor(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Xor (System.Drawing.Drawing2D.GraphicsPath path);
member this.Xor : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Xor (path As GraphicsPath)

Parameters

path
GraphicsPath

The GraphicsPath to Xor with this Region.

Exceptions

path is null.

Examples

For a code example, see the Xor(RectangleF) and Complement(GraphicsPath) methods.

Applies to

Xor(Rectangle)

Source:
Region.cs
Source:
Region.cs

Updates this Region to the union minus the intersection of itself with the specified Rectangle structure.

public:
 void Xor(System::Drawing::Rectangle rect);
public void Xor (System.Drawing.Rectangle rect);
member this.Xor : System.Drawing.Rectangle -> unit
Public Sub Xor (rect As Rectangle)

Parameters

rect
Rectangle

The Rectangle structure to Xor with this Region.

Examples

For a code example, see the Xor(RectangleF) method.

Applies to

Xor(RectangleF)

Source:
Region.cs
Source:
Region.cs

Updates this Region to the union minus the intersection of itself with the specified RectangleF structure.

public:
 void Xor(System::Drawing::RectangleF rect);
public void Xor (System.Drawing.RectangleF rect);
member this.Xor : System.Drawing.RectangleF -> unit
Public Sub Xor (rect As RectangleF)

Parameters

rect
RectangleF

The RectangleF structure to Xor(GraphicsPath) with this Region.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates the first rectangle and draws it to the screen in black.

  • Creates a second rectangle and draws it to the screen in red.

  • Creates a region using the first rectangle.

  • Gets the Xor area for myRegion when combined with complementRect.

  • Fills the Xor area with blue and draws it to the screen.

Notice that both rectangles are filled with blue, except for the area of overlap.

void XorExample( PaintEventArgs^ e )
{
   // Create the first rectangle and draw it to the screen in black.
   Rectangle regionRect = Rectangle(20,20,100,100);
   e->Graphics->DrawRectangle( Pens::Black, regionRect );

   // create the second rectangle and draw it to the screen in red.
   RectangleF xorRect = RectangleF(90,30,100,100);
   e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( xorRect ) );

   // Create a region using the first rectangle.
   System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

   // Get the area of overlap for myRegion when combined with
   // complementRect.
   myRegion->Xor( xorRect );

   // Fill the Xor area of myRegion with blue.
   SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
   e->Graphics->FillRegion( myBrush, myRegion );
}
public void XorExample(PaintEventArgs e)
{
             
    // Create the first rectangle and draw it to the screen in black.
    Rectangle regionRect = new Rectangle(20, 20, 100, 100);
    e.Graphics.DrawRectangle(Pens.Black, regionRect);
             
    // create the second rectangle and draw it to the screen in red.
    RectangleF xorRect = new RectangleF(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red,
        Rectangle.Round(xorRect));
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the area of overlap for myRegion when combined with
             
    // complementRect.
    myRegion.Xor(xorRect);
             
    // Fill the Xor area of myRegion with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub XorExample(ByVal e As PaintEventArgs)

    ' Create the first rectangle and draw it to the screen in black.
    Dim regionRect As New Rectangle(20, 20, 100, 100)
    e.Graphics.DrawRectangle(Pens.Black, regionRect)

    ' create the second rectangle and draw it to the screen in red.
    Dim xorRect As New RectangleF(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(xorRect))

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Get the area of overlap for myRegion when combined with
    ' complementRect.
    myRegion.Xor(xorRect)

    ' Fill the intersection area of myRegion with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

Applies to

Xor(Region)

Source:
Region.cs
Source:
Region.cs

Updates this Region to the union minus the intersection of itself with the specified Region.

public:
 void Xor(System::Drawing::Region ^ region);
public void Xor (System.Drawing.Region region);
member this.Xor : System.Drawing.Region -> unit
Public Sub Xor (region As Region)

Parameters

region
Region

The Region to Xor with this Region.

Exceptions

region is null.

Examples

For a code example, see the Xor(RectangleF) and Complement(GraphicsPath) methods.

Applies to