[1] | 1 | ' Classes/System/Drawing/Size.ab
|
---|
| 2 |
|
---|
[473] | 3 | Namespace System
|
---|
| 4 | Namespace Drawing
|
---|
[1] | 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 |
|
---|
[212] | 18 | Sub Size(sz As Size)
|
---|
[1] | 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 |
|
---|
[166] | 39 | Function Operator +(sz As Size) As Size
|
---|
[473] | 40 | Return New Size(width + sz.width, height + sz.height)
|
---|
[1] | 41 | End Function
|
---|
| 42 |
|
---|
[166] | 43 | Function Operator -(sz As Size) As Size
|
---|
[473] | 44 | Return New Size(width - sz.width, height - sz.height)
|
---|
[1] | 45 | End Function
|
---|
| 46 |
|
---|
| 47 | Function Operator () As SizeF
|
---|
[473] | 48 | Return New SizeF(width, height)
|
---|
[1] | 49 | End Function
|
---|
| 50 |
|
---|
[166] | 51 | Function Operator ==(sz As Size) As Boolean
|
---|
[1] | 52 | Return Equals(sz)
|
---|
| 53 | End Function
|
---|
| 54 |
|
---|
[166] | 55 | Function Operator <>(sz As Size) As Boolean
|
---|
[1] | 56 | Return Not Equals(sz)
|
---|
| 57 | End Function
|
---|
[473] | 58 |
|
---|
[104] | 59 | Function Equals(sz As Size) As Boolean
|
---|
[1] | 60 | If width = sz.width And height = sz.height Then
|
---|
[303] | 61 | Equals = True
|
---|
[1] | 62 | Else
|
---|
[303] | 63 | Equals = False
|
---|
[1] | 64 | End If
|
---|
| 65 | End Function
|
---|
| 66 |
|
---|
[166] | 67 | Override Function GetHashCode() As Long
|
---|
[223] | 68 | Return width As DWord Xor _System_BSwap(height As DWord)
|
---|
[166] | 69 | End Function
|
---|
| 70 |
|
---|
[104] | 71 | Function IsEmpty() As Boolean
|
---|
[212] | 72 | Return width = 0 And height = 0
|
---|
[1] | 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
|
---|
[473] | 84 | Return New Size(System.Math.Ceiling(szf.Width) As Long, System.Math.Ceiling(szf.Height) As Long)
|
---|
[1] | 85 | End Function
|
---|
| 86 |
|
---|
| 87 | Static Function Round(szf As SizeF) As Size
|
---|
[473] | 88 | Return New Size(System.Math.Round(szf.Width) As Long, System.Math.Round(szf.Height) As Long)
|
---|
[1] | 89 | End Function
|
---|
| 90 |
|
---|
| 91 | Static Function Truncate(szf As SizeF) As Size
|
---|
[473] | 92 | Return New Size(System.Math.Truncate(szf.Width) As Long, System.Math.Truncate(szf.Height) As Long)
|
---|
[1] | 93 | End Function
|
---|
| 94 |
|
---|
| 95 | Private
|
---|
| 96 | width As Long
|
---|
| 97 | height As Long
|
---|
| 98 | End Class
|
---|
| 99 |
|
---|
[473] | 100 | End Namespace
|
---|
| 101 | End Namespace
|
---|