IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
Rectangle.cs
Go to the documentation of this file.
3
5{
6 namespace Detail
7 {
13
17 public class RectangleT<TPosition, TSize>
18 {
26 {
27 Position = position;
28 Size = size;
29 }
30
39 public RectangleT(TPosition x, TPosition y, TSize width, TSize height)
40 {
41 Position = new PointT<TPosition>(x, y);
42 Size = new SizeT<TSize>(width, height);
43 }
44
48 public TPosition X => Position.X;
49
53 public TPosition Y => Position.Y;
54
58 public TSize Width => Size.Width;
59
63 public TSize Height => Size.Height;
64
69
73 public SizeT<TSize> Size { get; }
74
80 public override bool Equals(object? obj)
81 {
82 if (obj is null)
83 {
84 return false;
85 }
86
87 if (ReferenceEquals(this, obj))
88 {
89 return true;
90 }
91
92 if (obj is not RectangleT<TPosition, TSize> other)
93 {
94 return false;
95 }
96
97 return Equals(other);
98 }
99
105 private bool Equals(RectangleT<TPosition, TSize> other)
106 {
107 return Position.Equals(other.Position) && Size.Equals(other.Size);
108 }
109
113 public override int GetHashCode()
114 {
115 return (Position, Size).GetHashCode();
116 }
117
122 public override string ToString()
123 {
124 return Formatting.Invariant(
125 $"{GetType().Name}{{ X = {X}, Y = {Y}, Width = {Width}, Height = {Height} }}");
126 }
127 }
128 }
129
133
137 public class Rectangle : RectangleT<int, uint>
138 {
142 public Rectangle() : base(0, 0, 0, 0)
143 {
144 }
145
153 public Rectangle(int x, int y, uint width, uint height) : base(x, y, width, height)
154 {
155 }
156
162 public Rectangle(Point point, Size size) : base(point, size)
163 {
164 }
165 }
166
170
174 public class RectangleF : RectangleT<float, float>
175 {
179 public RectangleF() : base(0.0f, 0.0f, 0.0f, 0.0f)
180 {
181 }
182
191 public RectangleF(float x, float y, float width, float height) : base(x, y, width, height)
192 {
193 }
194
200 public RectangleF(PointF point, SizeF size) : base(point, size)
201 {
202 }
203 }
204
208
212 public class RectangleU : RectangleT<uint, uint>
213 {
217 public RectangleU() : base(0, 0, 0, 0)
218 {
219 }
220
229 public RectangleU(uint x, uint y, uint width, uint height) : base(x, y, width, height)
230 {
231 }
232
238 public RectangleU(PointU point, Size size) : base(point, size)
239 {
240 }
241 }
242}
Represents a 2D point with generic coordinates.
Definition Point.cs:14
Represents a rectangle with generic coordinates and dimensions.
Definition Rectangle.cs:18
SizeT< TSize > Size
Gets the size of the rectangle.
Definition Rectangle.cs:73
TSize Width
Gets the width of the rectangle.
Definition Rectangle.cs:58
TSize Height
Gets the height of the rectangle.
Definition Rectangle.cs:63
override int GetHashCode()
Returns a hash code for the current point.
Definition Rectangle.cs:113
TPosition Y
Gets the Y coordinate of the top-left corner of the rectangle.
Definition Rectangle.cs:53
override bool Equals(object? obj)
Determines whether the specified object is equal to the current RectangleT<TPosition,...
Definition Rectangle.cs:80
override string ToString()
Returns a string representation of the rectangle.
Definition Rectangle.cs:122
RectangleT(TPosition x, TPosition y, TSize width, TSize height)
Initializes a new instance of the RectangleT<TPosition,TSize> class with specified coordinates and di...
Definition Rectangle.cs:39
PointT< TPosition > Position
Gets the position of the rectangle.
Definition Rectangle.cs:68
TPosition X
Gets or sets the X coordinate of the top-left corner of the rectangle.
Definition Rectangle.cs:48
RectangleT(PointT< TPosition > position, SizeT< TSize > size)
Initializes a new instance of the RectangleT<TPosition,TSize> class with specified coordinates and di...
Definition Rectangle.cs:25
Represents a size with generic width and height values.
Definition Size.cs:17
T Width
Gets the width of the size.
Definition Size.cs:37
T Height
Gets the height of the size.
Definition Size.cs:42
override bool Equals(object? obj)
Determines whether the specified object is equal to the current SizeT<T>.
Definition Size.cs:49
Represents a 2D point with floating-point coordinates.
Definition Point.cs:126
Represents a 2D point with integer coordinates.
Definition Point.cs:98
Represents a 2D point with unsigned integer coordinates.
Definition Point.cs:154
Represents a rectangle with floating-point coordinates and dimensions.
Definition Rectangle.cs:175
RectangleF(float x, float y, float width, float height)
Initializes a new instance of the RectangleF class with specified floating-point coordinates and dime...
Definition Rectangle.cs:191
RectangleF()
Initializes a new instance of the RectangleF class with default values (0.0f, 0.0f,...
Definition Rectangle.cs:179
RectangleF(PointF point, SizeF size)
Initializes a new instance of the RectangleF class with location and size.
Definition Rectangle.cs:200
Represents a rectangle with integer coordinates and dimensions.
Definition Rectangle.cs:138
Rectangle()
Initializes a new instance of the Rectangle class with default values (0, 0, 0, 0).
Definition Rectangle.cs:142
Rectangle(int x, int y, uint width, uint height)
Initializes a new instance of the Rectangle class with specified integer coordinates and dimensions.
Definition Rectangle.cs:153
Rectangle(Point point, Size size)
Initializes a new instance of the Rectangle class with location and size.
Definition Rectangle.cs:162
Represents a rectangle with unsigned integer coordinates and dimensions.
Definition Rectangle.cs:213
RectangleU(PointU point, Size size)
Initializes a new instance of the Rectangle class with location and size.
Definition Rectangle.cs:238
RectangleU(uint x, uint y, uint width, uint height)
Initializes a new instance of the RectangleU class with specified integer coordinates and dimensions.
Definition Rectangle.cs:229
RectangleU()
Initializes a new instance of the RectangleU class with default values (0, 0, 0, 0).
Definition Rectangle.cs:217
Represents a size with floating-point width and height values.
Definition Size.cs:143
Represents a size with integer width and height values.
Definition Size.cs:107