Region.Xor 方法

定義

將此 Region 物件更新為聯集,減去自身與指定 GraphicsPath 物件的交集。

多載

名稱 Description
Xor(GraphicsPath)

將此 Region 更新為聯集,減去自身與指定 GraphicsPath的交集。

Xor(Rectangle)

將此 Region 更新為聯集,去除自身與指定 Rectangle 結構的交集。

Xor(RectangleF)

將此 Region 更新為聯集,去除自身與指定 RectangleF 結構的交集。

Xor(Region)

將此 Region 更新為聯集,減去自身與指定 Region的交集。

Xor(GraphicsPath)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將此 Region 更新為聯集,減去自身與指定 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)

參數

例外狀況

pathnull

範例

關於程式碼範例,請參見 and Xor(RectangleF) 方法。Complement(GraphicsPath)

適用於

Xor(Rectangle)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將此 Region 更新為聯集,去除自身與指定 Rectangle 結構的交集。

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)

參數

rect
Rectangle

Rectangle結構 與XorRegion

範例

程式碼範例請參見該 Xor(RectangleF) 方法。

適用於

Xor(RectangleF)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將此 Region 更新為聯集,去除自身與指定 RectangleF 結構的交集。

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)

參數

範例

以下程式碼範例是為 Windows Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 此程式碼會執行下列動作:

  • 建立第一個矩形,並以黑色繪製到螢幕上。

  • 建立第二個矩形,並以紅色畫到螢幕上。

  • 用第一個矩形建立一個區域。

  • 結合 Xor時得到 myRegioncomplementRect面積。

  • 用藍色填滿 Xor 區域並吸引到螢幕上。

注意兩個矩形都被藍色填滿,只有重疊區域例外。

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

適用於

Xor(Region)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs

將此 Region 更新為聯集,減去自身與指定 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)

參數

region
Region

Region Xor Region這個 。

例外狀況

regionnull

範例

關於程式碼範例,請參見 and Xor(RectangleF) 方法。Complement(GraphicsPath)

適用於