Region.Exclude Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Перегрузки
Exclude(Region) |
Обновляет область Region, чтобы включить только часть ее внутренней области, не пересекающуюся с заданным контуром Region. |
Exclude(GraphicsPath) |
Обновляет область Region, чтобы включить только часть ее внутренней области, не пересекающуюся с заданным контуром GraphicsPath. |
Exclude(Rectangle) |
Обновляет область Region, чтобы включить только часть ее внутренней области, не пересекающуюся с заданной структурой Rectangle. |
Exclude(RectangleF) |
Обновляет область Region, чтобы включить только часть ее внутренней области, не пересекающуюся с заданной структурой RectangleF. |
Exclude(Region)
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
public:
void Exclude(System::Drawing::Region ^ region);
public void Exclude (System.Drawing.Region region);
member this.Exclude : System.Drawing.Region -> unit
Public Sub Exclude (region As Region)
Параметры
Исключения
region
имеет значение null
.
Примеры
Примеры кода см. в методах Exclude(RectangleF) и Complement(Region) .
Применяется к
Exclude(GraphicsPath)
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
Обновляет область Region, чтобы включить только часть ее внутренней области, не пересекающуюся с заданным контуром GraphicsPath.
public:
void Exclude(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Exclude (System.Drawing.Drawing2D.GraphicsPath path);
member this.Exclude : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Exclude (path As GraphicsPath)
Параметры
- path
- GraphicsPath
Контур GraphicsPath, исключаемый из области Region.
Исключения
path
имеет значение null
.
Примеры
В следующем примере кода демонстрируется Region конструктор и методы Exclude и Dispose .
Этот пример предназначен для использования с Windows Forms. Вставьте код в форму и вызовите FillRegionExcludingPath
метод при обработке события формы Paint , передавая e
как PaintEventArgs.
private:
void FillRegionExcludingPath( PaintEventArgs^ e )
{
// Create the region using a rectangle.
System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( Rectangle(20,20,100,100) );
// Create the GraphicsPath.
System::Drawing::Drawing2D::GraphicsPath^ path = gcnew System::Drawing::Drawing2D::GraphicsPath;
// Add a circle to the graphics path.
path->AddEllipse( 50, 50, 25, 25 );
// Exclude the circle from the region.
myRegion->Exclude( path );
// Retrieve a Graphics object from the form.
Graphics^ formGraphics = e->Graphics;
// Fill the region in blue.
formGraphics->FillRegion( Brushes::Blue, myRegion );
// Dispose of the path and region objects.
delete path;
delete myRegion;
}
private void FillRegionExcludingPath(PaintEventArgs e)
{
// Create the region using a rectangle.
Region myRegion = new Region(new Rectangle(20, 20, 100, 100));
// Create the GraphicsPath.
System.Drawing.Drawing2D.GraphicsPath path =
new System.Drawing.Drawing2D.GraphicsPath();
// Add a circle to the graphics path.
path.AddEllipse(50, 50, 25, 25);
// Exclude the circle from the region.
myRegion.Exclude(path);
// Retrieve a Graphics object from the form.
Graphics formGraphics = e.Graphics;
// Fill the region in blue.
formGraphics.FillRegion(Brushes.Blue, myRegion);
// Dispose of the path and region objects.
path.Dispose();
myRegion.Dispose();
}
Private Sub FillRegionExcludingPath(ByVal e As PaintEventArgs)
' Create the region using a rectangle.
Dim myRegion As New Region(New Rectangle(20, 20, 100, 100))
' Create the GraphicsPath.
Dim path As New System.Drawing.Drawing2D.GraphicsPath
' Add a circle to the graphics path.
path.AddEllipse(50, 50, 25, 25)
' Exclude the circle from the region.
myRegion.Exclude(path)
' Retrieve a Graphics object from the form.
Dim formGraphics As Graphics = e.Graphics
' Fill the region in blue.
formGraphics.FillRegion(Brushes.Blue, myRegion)
' Dispose of the path and region objects.
path.Dispose()
myRegion.Dispose()
End Sub
Применяется к
Exclude(Rectangle)
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
public:
void Exclude(System::Drawing::Rectangle rect);
public void Exclude (System.Drawing.Rectangle rect);
member this.Exclude : System.Drawing.Rectangle -> unit
Public Sub Exclude (rect As Rectangle)
Параметры
Примеры
Пример кода см. в описании Exclude(RectangleF) метода .
Применяется к
Exclude(RectangleF)
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
- Исходный код:
- Region.cs
Обновляет область Region, чтобы включить только часть ее внутренней области, не пересекающуюся с заданной структурой RectangleF.
public:
void Exclude(System::Drawing::RectangleF rect);
public void Exclude (System.Drawing.RectangleF rect);
member this.Exclude : System.Drawing.RectangleF -> unit
Public Sub Exclude (rect As RectangleF)
Параметры
- rect
- RectangleF
Структура RectangleF, исключаемая из этой области Region.
Примеры
Следующий пример предназначен для использования с Windows Forms и требует PaintEventArgse
, который является параметром обработчика Paint событий. Код выполняет следующие действия.
Создает прямоугольник и рисует его на экране черным цветом
Создает второй прямоугольник, пересекающийся с первым, и рисует его на экране красным цветом.
Создает область с помощью первого прямоугольника.
Возвращает неисключаемую область области при объединении со вторым прямоугольником.
Заполняет неисключаемую область синим цветом и рисует ее на экране.
Обратите внимание, что область области, которая не пересекается с прямоугольником, окрашена в синий цвет.
public:
void Exclude_RectF_Example( 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 complementRect = RectangleF(90,30,100,100);
e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( complementRect ) );
// Create a region using the first rectangle.
System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );
// Get the nonexcluded area of myRegion when combined with
// complementRect.
myRegion->Exclude( complementRect );
// Fill the nonexcluded area of myRegion with blue.
SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
e->Graphics->FillRegion( myBrush, myRegion );
}
public void Exclude_RectF_Example(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 complementRect = new RectangleF(90, 30, 100, 100);
e.Graphics.DrawRectangle(Pens.Red,
Rectangle.Round(complementRect));
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Get the nonexcluded area of myRegion when combined with
// complementRect.
myRegion.Exclude(complementRect);
// Fill the nonexcluded area of myRegion with blue.
SolidBrush myBrush = new SolidBrush(Color.Blue);
e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Exclude_RectF_Example(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 complementRect As New RectangleF(90, 30, 100, 100)
e.Graphics.DrawRectangle(Pens.Red, _
Rectangle.Round(complementRect))
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Get the nonexcluded area of myRegion when combined with
' complementRect.
myRegion.Exclude(complementRect)
' Fill the nonexcluded area of myRegion with blue.
Dim myBrush As New SolidBrush(Color.Blue)
e.Graphics.FillRegion(myBrush, myRegion)
End Sub
Применяется к
Обратная связь
https://aka.ms/ContentUserFeedback.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделеОтправить и просмотреть отзыв по