|
Revision 746, 2.0 kB
(checked in by mfenniak, 2 years ago)
|
--
|
| Line | |
|---|
| 1 |
using System; |
|---|
| 2 |
using System.Collections.Generic; |
|---|
| 3 |
using System.Text; |
|---|
| 4 |
using System.Drawing; |
|---|
| 5 |
|
|---|
| 6 |
namespace Pybrary.Plot |
|---|
| 7 |
{ |
|---|
| 8 |
public struct AdvancedRect |
|---|
| 9 |
{ |
|---|
| 10 |
public PointF TopLeft; |
|---|
| 11 |
public PointF BottomRight; |
|---|
| 12 |
|
|---|
| 13 |
public AdvancedRect(PointF topLeft, PointF bottomRight) |
|---|
| 14 |
{ |
|---|
| 15 |
TopLeft = topLeft; |
|---|
| 16 |
BottomRight = bottomRight; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
public AdvancedRect(RectangleF orig) |
|---|
| 20 |
{ |
|---|
| 21 |
TopLeft = new PointF(orig.X, orig.Y); |
|---|
| 22 |
BottomRight = new PointF(orig.Width + orig.X, orig.Height + orig.Y); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
public AdvancedRect(AdvancedRect orig) |
|---|
| 26 |
{ |
|---|
| 27 |
TopLeft = new PointF(orig.TopLeft.X, orig.TopLeft.Y); |
|---|
| 28 |
BottomRight = new PointF(orig.BottomRight.X, orig.BottomRight.Y); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
public AdvancedRect Clone() |
|---|
| 32 |
{ |
|---|
| 33 |
return new AdvancedRect(this); |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
public float Width |
|---|
| 37 |
{ |
|---|
| 38 |
get |
|---|
| 39 |
{ |
|---|
| 40 |
return BottomRight.X - TopLeft.X; |
|---|
| 41 |
} |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
public float Height |
|---|
| 45 |
{ |
|---|
| 46 |
get |
|---|
| 47 |
{ |
|---|
| 48 |
return BottomRight.Y - TopLeft.Y; |
|---|
| 49 |
} |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
public Rectangle Rect2 |
|---|
| 53 |
{ |
|---|
| 54 |
get |
|---|
| 55 |
{ |
|---|
| 56 |
return new Rectangle((int)TopLeft.X, (int)TopLeft.Y, (int)Width, (int)Height); |
|---|
| 57 |
} |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
public RectangleF Rect |
|---|
| 61 |
{ |
|---|
| 62 |
get |
|---|
| 63 |
{ |
|---|
| 64 |
return new RectangleF(TopLeft, this.Size); |
|---|
| 65 |
} |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
public SizeF Size |
|---|
| 69 |
{ |
|---|
| 70 |
get |
|---|
| 71 |
{ |
|---|
| 72 |
return new SizeF(this.Width, this.Height); |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
public PointF Center |
|---|
| 77 |
{ |
|---|
| 78 |
get |
|---|
| 79 |
{ |
|---|
| 80 |
return new PointF( |
|---|
| 81 |
(TopLeft.X + BottomRight.X) / 2, |
|---|
| 82 |
(TopLeft.Y + BottomRight.Y) / 2 |
|---|
| 83 |
); |
|---|
| 84 |
} |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
} |
|---|
| 88 |
} |
|---|