Region


public ref class Region
{
public:

Handle regionHandle;

Region()
{
 regionHandle = GdiPlus::CreateRegion();
}

Region(Handle region)
{
 regionHandle = region;
}

Region(Region^ region)
{
 regionHandle = GdiPlus::CloneRegion(region->regionHandle);
}

Region(RectangleF rect)
{
 regionHandle =  GdiPlus::CreateRegionRectangle(rect);
}


Region(Rectangle rect)
{
 regionHandle = GdiPlus::CreateRegionRectangle(rect);
}

Region(Path^ path)
{
 regionHandle =  GdiPlus::CreateRegionPath(path);
}

~Region()
{
  GdiPlus::DeleteRegion(regionHandle);
}

static operator Handle(Region^ regionToConvert) {return regionToConvert->regionHandle;}

static Region^ operator*(Transform^ tran, Region^ reg)
{
 Region^ Out = gcnew Region(reg);
 Out->Transform(gcnew Matrix(tran));
 return Out;
}

static Region^ operator&(Region^ regA, Region^ regB)
{
 Region^ Out = gcnew Region(regA);
 Out->Intersect(regB);
 return Out;
}

static Region^ operator|(Region^ regA, Region^ regB)
{
 Region^ Out = gcnew Region(regA);
 Out->Union(regB);
 return Out;
}

static Region^ operator^(Region^ regA, Region^ regB)
{
 Region^ Out = gcnew Region(regA);
 Out->Xor(regB);
 return Out;
}

void MakeInfinite()
{
 GdiPlus::SetInfinite(regionHandle);
}

void MakeEmpty()
{
 GdiPlus::SetEmpty(regionHandle);
}

void Intersect(RectangleF rect)
{
  GdiPlus::CombineRegionRectangle(regionHandle,
                                   rect, 
                                   (unsigned)CombineMode::Intersect);
}

void Intersect(Rectangle rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Intersect);
}

void  Intersect(Path^ path)
{
 GdiPlus::CombineRegionPath(regionHandle, 
                             path, 
                             (unsigned)CombineMode::Intersect);
}

void Intersect(Region^ region)
{
 GdiPlus::CombineRegionRegion(regionHandle, 
                               region, 
                               (unsigned)CombineMode::Intersect);
}

void Union(RectangleF rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Union);
}

void Union(Rectangle rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Union);
}

void Union(Path^ path)
{
 GdiPlus::CombineRegionPath(regionHandle, 
                             path, 
                             (unsigned)CombineMode::Union);
}

void Union(Region^ region)
{
 GdiPlus::CombineRegionRegion(regionHandle, 
                               region, 
                               (unsigned)CombineMode::Union);
}

void  Xor(RectangleF rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Xor);
}

void Xor(Rectangle rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Xor);
}

void Xor(Path^ path)
{
 GdiPlus::CombineRegionPath(regionHandle, 
                             path, 
                             (unsigned)CombineMode::Xor);
}

void Xor(Region^ region)
{
 GdiPlus::CombineRegionRegion(regionHandle, 
                               region, 
                               (unsigned)CombineMode::Xor);
}

void Exclude(RectangleF rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Exclude);
}

void Exclude(Rectangle rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Exclude);
}

void Exclude(Path^ path)
{
 GdiPlus::CombineRegionPath(regionHandle, 
                             path, 
                             (unsigned)CombineMode::Exclude);
}

void Exclude(Region^ region)
{
 GdiPlus::CombineRegionRegion(regionHandle,
                               region, 
                               (unsigned)CombineMode::Exclude);
}

void Complement(RectangleF rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Complement);
}

void Complement(Rectangle rect)
{
 GdiPlus::CombineRegionRectangle(regionHandle,
                                  rect, 
                                  (unsigned)CombineMode::Complement);
}

void Complement(Path^ path)
{
 GdiPlus::CombineRegionPath(regionHandle,
                             path, 
                             (unsigned)CombineMode::Complement);
}

void Complement(Region^ region)
{
 GdiPlus::CombineRegionRegion(regionHandle,
                               region, 
                               (unsigned)CombineMode::Complement);
}

void Translate(double dx, 
               double dy)
{
 GdiPlus::TranslateRegion(regionHandle, dx, dy);
}

void Translate(int dx, 
               int dy)
{
 GdiPlus::TranslateRegion(regionHandle, dx, dy);
}

void Transform(Matrix^ matrix)
{
 GdiPlus::TransformRegion(regionHandle, 
                           matrix);
}

RectangleF GetBounds(Graphics^ g);

Rectangle GetBoundsInteger(Graphics^ g);

bool IsEmpty(Graphics^ g);

bool IsInfinite(Graphics^ g);

bool Equals(Region^ region, 
               Graphics^ g);

bool IsVisible(PointF point)
{
 return GdiPlus::IsVisibleRegionPoint(regionHandle,
                                       point.X,
                                       point.Y, 
                                       Handle((void*)0));
}

bool IsVisible(PointF point, 
                  Graphics^ g);

bool IsVisible(RectangleF rect)
{
  return GdiPlus::IsVisibleRegionRectangle(regionHandle,
                                            rect.X,
                                            rect.Y,
                                            rect.Width,
                                            rect.Height,
                                            Handle((void*)0));
}

bool IsVisible(RectangleF rect, 
                  Graphics^ g);

bool IsVisible(Point point)
{
 return GdiPlus::IsVisibleRegionPoint(regionHandle,
                                       point.X,
                                       point.Y,
                                       Handle((void*)0));
}

bool IsVisible(Point point, 
                  Graphics^ g);

bool IsVisible(Rectangle rect)
{
 return GdiPlus::IsVisibleRegionRectangle(regionHandle,
                                           rect.X,
                                           rect.Y,
                                           rect.Width,
                                           rect.Height,
                                           Handle((void*)0));
}

bool IsVisible(Rectangle rect, 
                  Graphics^ g);

unsigned GetRegionScansCount(Matrix^ matrix)
{
 return GdiPlus::GetRegionScansCount(regionHandle,
                                      matrix);
}

Array<RectangleF>^ GetRegionScans(Matrix^ matrix)
{
 return  GdiPlus::GetRegionScans(regionHandle,
                                  matrix);
}

Array<Rectangle>^ GetRegionScansInteger(Matrix^ matrix)
{
 return  GdiPlus::GetRegionScansInteger(regionHandle,
                                         matrix);
}

};

Details

Name Space IPlusPlus::Drawing
Assembly IPlusPlus.Drawing.dll