IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
Size.cs
Go to the documentation of this file.
3
5{
6 namespace Detail
7 {
12
16 public class SizeT<T>
17 {
23 public SizeT(T width, T height)
24 {
25 Width = width;
26 Height = height;
27 }
28
33
37 public T Width { get; }
38
42 public T Height { get; }
43
49 public override bool Equals(object? obj)
50 {
51 if (obj is null)
52 {
53 return false;
54 }
55
56 if (ReferenceEquals(this, obj))
57 {
58 return true;
59 }
60
61 if (obj is not SizeT<T> other)
62 {
63 return false;
64 }
65
66 return Equals(other);
67 }
68
74 protected bool Equals(SizeT<T> other)
75 {
76 return Width != null && Width.Equals(other.Width) && Height != null && Height.Equals(other.Height);
77 }
78
82 public override int GetHashCode()
83 {
84 return (Width, Height).GetHashCode();
85 }
86
91 public override string ToString()
92 {
93 return Formatting.Invariant(
94 $"{GetType().Name}{{ {nameof(Width)} = {Width}, {nameof(Height)} = {Height} }}");
95 }
96 }
97 }
98
102
106 public class Size : SizeT<uint>
107 {
111 public Size()
112 : base(0, 0)
113 {
114 }
115
121 public Size(uint width, uint height)
122 : base(width, height)
123 {
124 }
125
126 private Size(SizeT<uint> size)
127 : base(size.Width, size.Height)
128 {
129 }
130
132 public new Size Transposed() => new (base.Transposed());
133 }
134
138
142 public class SizeF : SizeT<float>
143 {
147 public SizeF()
148 : base(0.0f, 0.0f)
149 {
150 }
151
157 public SizeF(float width, float height)
158 : base(width, height)
159 {
160 }
161
162 private SizeF(SizeT<float> size)
163 : base(size.Width, size.Height)
164 {
165 }
166
168 public new SizeF Transposed() => new (base.Transposed());
169 }
170}
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
SizeT< T > Transposed()
Returns a transposed size with width and height swapped.
override int GetHashCode()
Returns a hash code for the current size.
Definition Size.cs:82
override bool Equals(object? obj)
Determines whether the specified object is equal to the current SizeT<T>.
Definition Size.cs:49
SizeT(T width, T height)
Initializes a new instance of the SizeT<T> class with specified width and height.
Definition Size.cs:23
override string ToString()
Returns a string representation of the size.
Definition Size.cs:91
Represents a size with floating-point width and height values.
Definition Size.cs:143
SizeF()
Initializes a new instance of the SizeF class with default values (0.0f, 0.0f).
Definition Size.cs:147
SizeF(float width, float height)
Initializes a new instance of the SizeF class with specified floating-point width and height.
Definition Size.cs:157
Represents a size with integer width and height values.
Definition Size.cs:107
Size(uint width, uint height)
Initializes a new instance of the Size class with specified integer width and height.
Definition Size.cs:121
Size()
Initializes a new instance of the Size class with default values (0, 0).
Definition Size.cs:111