Region.Xor 方法

定義

更新這個 Region 物件為聯集減去它與指定的 GraphicsPath 物件的交集。

多載

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 更新為聯集減去其本身與指定 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)

參數

path
GraphicsPath

要與這個 GraphicsPathXorRegion

例外狀況

pathnull

範例

如需程式代碼範例,請參閱 Xor(RectangleF)Complement(GraphicsPath) 方法。

適用於

Xor(Rectangle)

來源:
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

要與這個 RectangleXorRegion 結構。

範例

如需程式代碼範例,請參閱 Xor(RectangleF) 方法。

適用於

Xor(RectangleF)

來源:
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)

參數

rect
RectangleF

要與這個 RectangleFXor(GraphicsPath)Region 結構。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 建立第一個矩形,並將它繪製到黑色的畫面。

  • 建立第二個矩形,並將它繪製到紅色的畫面。

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

  • 取得與 結合complementRect時的區域。XormyRegion

  • 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 更新為聯集減去其本身與指定 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

要與這個 RegionXorRegion

例外狀況

regionnull

範例

如需程式代碼範例,請參閱 Xor(RectangleF)Complement(GraphicsPath) 方法。

適用於