Region

Region marshal by reference, disposable

System.Drawing (system.drawing.dll) sealed class

This class is used to define an arbitrary region on a 2D surface.

This is a resource-based entity (unlike the Rectangle and Point value types), and therefore requires careful lifetime management. You should Dispose() the object when you are finished with it to release the resources back to the system.

At its simplest, you can construct a Region from a Rectangle or RectangleF . More complex regions can be constructed from a System.Drawing.Drawing2D.GraphicsPath . For interop with the Win32 HRGN, you can use GetHrgn() and FromHrgn() .

You can then manipulate the region in a variety of ways, including logical operations with another Region , System.Drawing.Drawing2D.GraphicsPath , or Rectangle / RectangleF . It can also be made to represent no area at all with the MakeEmpty() method, or the whole of the infinite plane with MakeInfinite() . You can create the Complement() (the area of the supplied object that does not intersect with the Region) , Intersect() two regions, create Union() of two regions (the combined areas of both), and Xor() two regions (which is equivalent to the Union( ) Intersect() ).

You can also provide a Matrix and Transform() the region, or simply Translate() it. This is not an ambient transformation like the ones provided for a Pen or Graphics surfaceit actually manipulates the underlying System.Drawing.Drawing2D.RegionData .

There is an Equals() method, which determines whether two Region objects would be equivalent on a given Graphics surface, and you can determine whether a Point or any portion of a Rectangle ( expressed in a variety of ways) will intersect with the region on a particular Graphics surface.

 public sealed class  Region  : MarshalByRefObject : IDisposable {  // Public Constructors  public  Region  ();    public  Region  (System.Drawing.Drawing2D.GraphicsPath  path  );    public  Region  (Rectangle  rect  );    public  Region  (RectangleF  rect  );    public  Region  (System.Drawing.Drawing2D.RegionData  rgnData  );  // Public Static Methods  public static Region  FromHrgn  (IntPtr  hrgn  );  // Public Instance Methods  public Region  Clone  ();    public void  Complement  (System.Drawing.Drawing2D.GraphicsPath  path  );    public void  Complement  (Rectangle  rect  );    public void  Complement  (RectangleF  rect  );    public void  Complement  (Region  region  );    public void  Dispose  ();  // implements IDisposable  public bool  Equals  (Region  region  , Graphics  g  );    public void  Exclude  (System.Drawing.Drawing2D.GraphicsPath  path  );    public void  Exclude  (Rectangle  rect  );    public void  Exclude  (RectangleF  rect  );    public void  Exclude  (Region  region  );    public RectangleF  GetBounds  (Graphics  g  );    public IntPtr  GetHrgn  (Graphics  g  );    public RegionData  GetRegionData  ();    public RectangleF[ ]  GetRegionScans  (System.Drawing.Drawing2D.Matrix  matrix  );    public void  Intersect  (System.Drawing.Drawing2D.GraphicsPath  path  );    public void  Intersect  (Rectangle  rect  );    public void  Intersect  (RectangleF  rect  );    public void  Intersect  (Region  region  );    public bool  IsEmpty  (Graphics  g  );    public bool  IsInfinite  (Graphics  g  );    public bool  IsVisible  (int  x  , int  y  , Graphics  g  );    public bool  IsVisible  (int  x  , int  y  , int  width  , int  height  );    public bool  IsVisible  (int  x  , int  y  , int  width  , int  height  , Graphics  g  );    public bool  IsVisible  (Point  point  );    public bool  IsVisible  (PointF  point  );    public bool  IsVisible  (PointF  point  , Graphics  g  );    public bool  IsVisible  (Point  point  , Graphics  g  );    public bool  IsVisible  (Rectangle  rect  );    public bool  IsVisible  (RectangleF  rect  );    public bool  IsVisible  (RectangleF  rect  , Graphics  g  );    public bool  IsVisible  (Rectangle  rect  , Graphics  g  );    public bool  IsVisible  (float  x  , float  y  );    public bool  IsVisible  (float  x  , float  y  , Graphics  g  );    public bool  IsVisible  (float  x  , float  y  , float  width  , float  height  );    public bool  IsVisible  (float  x  , float  y  , float  width  , float  height  , Graphics  g  );    public void  MakeEmpty  ();    public void  MakeInfinite  ();    public void  Transform  (System.Drawing.Drawing2D.Matrix  matrix  );    public void  Translate  (int  dx  , int  dy  );    public void  Translate  (float  dx  , float  dy  );    public void  Union  (System.Drawing.Drawing2D.GraphicsPath  path  );    public void  Union  (Rectangle  rect  );    public void  Union  (RectangleF  rect  );    public void  Union  (Region  region  );    public void  Xor  (System.Drawing.Drawing2D.GraphicsPath  path  );    public void  Xor  (Rectangle  rect  );    public void  Xor  (RectangleF  rect  );    public void  Xor  (Region  region  );  // Protected Instance Methods  protected override void  Finalize  ();  // overrides object  } 

Hierarchy

System.Object System.MarshalByRefObject Region(System.IDisposable)

Returned By

Graphics.{Clip , MeasureCharacterRanges()} , System.Windows.Forms.Control.Region

Passed To

Graphics.{Clip , ExcludeClip() , FillRegion() , IntersectClip() , SetClip()} , System.Windows.Forms.Control.{Invalidate() , Region}



. Net Windows Forms in a Nutshell
.NET Windows Forms in a Nutshell
ISBN: 0596003382
EAN: 2147483647
Year: 2002
Pages: 794

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net