1 | ' Classes/System/Drawing/Size.ab
|
---|
2 |
|
---|
3 | Namespace System
|
---|
4 | Namespace Drawing
|
---|
5 |
|
---|
6 | Class Size
|
---|
7 | Public
|
---|
8 | Sub Size()
|
---|
9 | width = 0
|
---|
10 | height = 0
|
---|
11 | End Sub
|
---|
12 |
|
---|
13 | Sub Size(initWidth As Long, initHeight As Long)
|
---|
14 | width = initWidth
|
---|
15 | height = initHeight
|
---|
16 | End Sub
|
---|
17 |
|
---|
18 | Sub Size(sz As Size)
|
---|
19 | width = sz.width
|
---|
20 | height = sz.height
|
---|
21 | End Sub
|
---|
22 |
|
---|
23 | Function Width() As Long
|
---|
24 | Return width
|
---|
25 | End Function
|
---|
26 |
|
---|
27 | Sub Width(w As Long)
|
---|
28 | width = w
|
---|
29 | End Sub
|
---|
30 |
|
---|
31 | Function Height() As Long
|
---|
32 | Return height
|
---|
33 | End Function
|
---|
34 |
|
---|
35 | Sub Height(h As Long)
|
---|
36 | height = h
|
---|
37 | End Sub
|
---|
38 |
|
---|
39 | Function Operator +(sz As Size) As Size
|
---|
40 | Return New Size(width + sz.width, height + sz.height)
|
---|
41 | End Function
|
---|
42 |
|
---|
43 | Function Operator -(sz As Size) As Size
|
---|
44 | Return New Size(width - sz.width, height - sz.height)
|
---|
45 | End Function
|
---|
46 |
|
---|
47 | Function Operator () As SizeF
|
---|
48 | Return New SizeF(width, height)
|
---|
49 | End Function
|
---|
50 |
|
---|
51 | Function Operator ==(sz As Size) As Boolean
|
---|
52 | Return Equals(sz)
|
---|
53 | End Function
|
---|
54 |
|
---|
55 | Function Operator <>(sz As Size) As Boolean
|
---|
56 | Return Not Equals(sz)
|
---|
57 | End Function
|
---|
58 |
|
---|
59 | Function Equals(sz As Size) As Boolean
|
---|
60 | If width = sz.width And height = sz.height Then
|
---|
61 | Equals = True
|
---|
62 | Else
|
---|
63 | Equals = False
|
---|
64 | End If
|
---|
65 | End Function
|
---|
66 |
|
---|
67 | Override Function GetHashCode() As Long
|
---|
68 | Return width As DWord Xor _System_BSwap(height As DWord)
|
---|
69 | End Function
|
---|
70 |
|
---|
71 | Function IsEmpty() As Boolean
|
---|
72 | Return width = 0 And height = 0
|
---|
73 | End Function
|
---|
74 |
|
---|
75 | Function Add(sz As Size) As Size
|
---|
76 | Return This + sz
|
---|
77 | End Function
|
---|
78 |
|
---|
79 | Function Subtract(sz As Size) As Size
|
---|
80 | Return This - sz
|
---|
81 | End Function
|
---|
82 |
|
---|
83 | Static Function Ceiling(szf As SizeF) As Size
|
---|
84 | Return New Size(System.Math.Ceiling(szf.Width) As Long, System.Math.Ceiling(szf.Height) As Long)
|
---|
85 | End Function
|
---|
86 |
|
---|
87 | Static Function Round(szf As SizeF) As Size
|
---|
88 | Return New Size(System.Math.Round(szf.Width) As Long, System.Math.Round(szf.Height) As Long)
|
---|
89 | End Function
|
---|
90 |
|
---|
91 | Static Function Truncate(szf As SizeF) As Size
|
---|
92 | Return New Size(System.Math.Truncate(szf.Width) As Long, System.Math.Truncate(szf.Height) As Long)
|
---|
93 | End Function
|
---|
94 |
|
---|
95 | Private
|
---|
96 | width As Long
|
---|
97 | height As Long
|
---|
98 | End Class
|
---|
99 |
|
---|
100 | End Namespace
|
---|
101 | End Namespace
|
---|