/[dotgnu-pnet]/pnetlib/System.Drawing/Region.cs
ViewVC logotype

Diff of /pnetlib/System.Drawing/Region.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by neilcawse, Mon Jan 26 20:30:54 2004 UTC revision 1.11 by t3rmin4t0r, Thu Aug 18 18:29:37 2005 UTC
# Line 97  using System.Drawing.Toolkit; Line 97  using System.Drawing.Toolkit;
97  #endif  #endif
98  public sealed class Region : MarshalByRefObject, IDisposable  public sealed class Region : MarshalByRefObject, IDisposable
99  {  {
100            // Internal byte representation of the region
101            private RegionData rgnData;
102          // Overall extent of the region          // Overall extent of the region
103          private RectangleF extent;          private RectangleF extent;
104          // rectangles that make up the region sorted top to bottom, left to right          // rectangles that make up the region sorted top to bottom, left to right
# Line 105  public sealed class Region : MarshalByRe Line 107  public sealed class Region : MarshalByRe
107          // Constructors.          // Constructors.
108          public Region()          public Region()
109          {          {
110                    rgnData = new RegionData() ;
111                  MakeInfinite();                  MakeInfinite();
112          }          }
113    
         [TODO]  
114          public Region(GraphicsPath path)          public Region(GraphicsPath path)
115          {          {
116                  if(path == null)                  if(path == null)
117                  {                  {
118                          throw new ArgumentNullException("path");                          throw new ArgumentNullException("path");
119                  }                  }
120                  // TODO                  rgnData = new RegionData( path );
121          }          }
122    
123          public Region(Rectangle rect) : this( (RectangleF)rect)          public Region(Rectangle rect) : this( (RectangleF)rect)
# Line 123  public sealed class Region : MarshalByRe Line 125  public sealed class Region : MarshalByRe
125    
126          public Region(RectangleF rect)          public Region(RectangleF rect)
127          {          {
128                    rgnData = new RegionData( rect );
129                  if (rect.Width < 0)                  if (rect.Width < 0)
130                          rect = new RectangleF(rect.Right, rect.Top, -rect.Width, rect.Height);                          rect = new RectangleF(rect.Right, rect.Top, -rect.Width, rect.Height);
131                  if (rect.Height < 0)                  if (rect.Height < 0)
# Line 139  public sealed class Region : MarshalByRe Line 142  public sealed class Region : MarshalByRe
142                          // extent is already empty(0,0,0,0)                          // extent is already empty(0,0,0,0)
143                          rects = new RectangleF[0];                          rects = new RectangleF[0];
144                  }                  }
                   
145          }          }
146    
147          private Region(int initialRectSize)          private Region(int initialRectSize)
# Line 147  public sealed class Region : MarshalByRe Line 149  public sealed class Region : MarshalByRe
149                  rects = new RectangleF[initialRectSize];                  rects = new RectangleF[initialRectSize];
150          }          }
151    
152          [TODO]          public Region(RegionData otherRgnData)
         public Region(RegionData rgnData)  
153          {          {
154                  if(rgnData == null)                  if(otherRgnData == null)
155                  {                  {
156                          throw new ArgumentNullException("rgnData");                          throw new ArgumentNullException("rgnData");
157                  }                  }
158                  // TODO                  Region r = otherRgnData.ConstructRegion ( otherRgnData ) ;
159                    this.rects = r.rects ;
160                    this.extent = r.extent ;
161                    this.rgnData = r.GetRegionData() ;
162          }          }
163    
164          // Helpers, to replace missing "Math" class in some profiles.          // Helpers, to replace missing "Math" class in some profiles.
# Line 207  public sealed class Region : MarshalByRe Line 211  public sealed class Region : MarshalByRe
211          public Region Clone()          public Region Clone()
212          {          {
213                  Region newRegion = new Region();                  Region newRegion = new Region();
214                    newRegion.rgnData = rgnData.Clone();
215                  newRegion.rects = (RectangleF[])rects.Clone();                  newRegion.rects = (RectangleF[])rects.Clone();
216                  newRegion.extent = extent;                  newRegion.extent = extent;
217                  return newRegion;                  return newRegion;
# Line 230  public sealed class Region : MarshalByRe Line 235  public sealed class Region : MarshalByRe
235    
236          public void Complement(Region region)          public void Complement(Region region)
237          {          {
238                    rgnData.Complement( region ) ;
239                  Region subtract = Subtract(region, this);                  Region subtract = Subtract(region, this);
240                  extent = subtract.extent;                  extent = subtract.extent;
241                  rects = subtract.rects;                  rects = subtract.rects;
# Line 295  public sealed class Region : MarshalByRe Line 301  public sealed class Region : MarshalByRe
301    
302          public void Exclude(Region region)          public void Exclude(Region region)
303          {          {
304                    rgnData.Exclude( region ) ;
305                  Region subtract = Subtract(this, region);                  Region subtract = Subtract(this, region);
306                  extent = subtract.extent;                  extent = subtract.extent;
307                  rects = subtract.rects;                  rects = subtract.rects;
# Line 321  public sealed class Region : MarshalByRe Line 328  public sealed class Region : MarshalByRe
328          }          }
329    
330          // Get the raw region data for this region.          // Get the raw region data for this region.
         [TODO]  
331          public RegionData GetRegionData()          public RegionData GetRegionData()
332          {          {
333                  return null;                  return rgnData;
334          }          }
335    
336          // Get an array of rectangles that represents this region.          // Get an array of rectangles that represents this region.
# Line 367  public sealed class Region : MarshalByRe Line 373  public sealed class Region : MarshalByRe
373                    
374          public void Intersect(Region region)          public void Intersect(Region region)
375          {          {
376                    rgnData.Intersect(region);
377                  Intersect(this, region);                  Intersect(this, region);
378          }          }
379    
# Line 492  public sealed class Region : MarshalByRe Line 499  public sealed class Region : MarshalByRe
499          // Make this region empty.          // Make this region empty.
500          public void MakeEmpty()          public void MakeEmpty()
501          {          {
502                    rgnData.MakeEmpty() ;
503                  rects = new RectangleF[0];                  rects = new RectangleF[0];
504                  extent = Rectangle.Empty;                  extent = Rectangle.Empty;
505          }          }
# Line 499  public sealed class Region : MarshalByRe Line 507  public sealed class Region : MarshalByRe
507          // Make this region infinite.          // Make this region infinite.
508          public void MakeInfinite()          public void MakeInfinite()
509          {          {
510                    rgnData.MakeInfinite() ;
511                  const float maxCoord = 4194304; //Math.Pow(2, 22)                  const float maxCoord = 4194304; //Math.Pow(2, 22)
512                  extent = new RectangleF(-maxCoord, -maxCoord, 2 * maxCoord, 2 * maxCoord);                  extent = new RectangleF(-maxCoord, -maxCoord, 2 * maxCoord, 2 * maxCoord);
513                  rects = new RectangleF[1] { extent };                  rects = new RectangleF[1] { extent };
# Line 508  public sealed class Region : MarshalByRe Line 517  public sealed class Region : MarshalByRe
517          [TODO]          [TODO]
518          public void Transform(Matrix matrix)          public void Transform(Matrix matrix)
519          {          {
520                  // TODO                  rgnData.Transform( matrix ) ;
521                    // TODO: other state variables
522          }          }
523    
524          // Translate this matrix by a specific amount.          // Translate this matrix by a specific amount.
# Line 519  public sealed class Region : MarshalByRe Line 529  public sealed class Region : MarshalByRe
529                    
530          public void Translate(float dx, float dy)          public void Translate(float dx, float dy)
531          {          {
532                    rgnData.Translate( dx, dy ) ;
533                  for( int i = 0; i < rects.Length; i++)                  for( int i = 0; i < rects.Length; i++)
534                          rects[i].Offset(dx, dy);                          rects[i].Offset(dx, dy);
535                  if (rects.Length>0)                  if (rects.Length>0)
# Line 543  public sealed class Region : MarshalByRe Line 554  public sealed class Region : MarshalByRe
554                    
555          public void Union(Region region)          public void Union(Region region)
556          {          {
557                    rgnData.Union( region );
558                  Union (this, region);                  Union (this, region);
559          }          }
560    
# Line 1270  public sealed class Region : MarshalByRe Line 1282  public sealed class Region : MarshalByRe
1282                    
1283          public void Xor(Region region)          public void Xor(Region region)
1284          {          {
1285                    rgnData.Xor( region ) ;
1286                  Region reg1 = Subtract(this, region);                  Region reg1 = Subtract(this, region);
1287                  Union(reg1, Subtract(region, this));                  Union(reg1, Subtract(region, this));
1288                  extent = reg1.extent;                  extent = reg1.extent;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26