Point类源代码
来源:互联网 发布:mariadb与mysql 兼容 编辑:程序博客网 时间:2024/05/20 11:24
Imports System
Imports System.ComponentModel
Imports System.Globalization
Imports System.Runtime.InteropServices
Namespace System.Drawing
<Serializable, StructLayout(LayoutKind.Sequential), TypeConverter(GetType(PointConverter)), ComVisible(True)> _
Public Structure Point
Public Shared ReadOnly Empty As Point
Private x As Integer
Private y As Integer
Public Sub New(ByVal x As Integer, ByVal y As Integer)
Me.x = x
Me.y = y
End Sub
Public Sub New(ByVal sz As Size)
Me.x = sz.Width
Me.y = sz.Height
End Sub
Public Sub New(ByVal dw As Integer)
Me.x = CShort(Point.LOWORD(dw))
Me.y = CShort(Point.HIWORD(dw))
End Sub
<Browsable(False)> _
Public ReadOnly Property IsEmpty As Boolean
Get
Return ((Me.x = 0) AndAlso (Me.y = 0))
End Get
End Property
Public Property X As Integer
Get
Return Me.x
End Get
Set(ByVal value As Integer)
Me.x = value
End Set
End Property
Public Property Y As Integer
Get
Return Me.y
End Get
Set(ByVal value As Integer)
Me.y = value
End Set
End Property
Public Shared [Widening] [Operator] CType(ByVal p As Point) As PointF
Return New PointF(CSng(p.X), CSng(p.Y))
End Function
Public Shared [Narrowing] [Operator] CType(ByVal p As Point) As Size
Return New Size(p.X, p.Y)
End Function
Public Shared [Operator] +(ByVal pt As Point, ByVal sz As Size) As Point
Return Point.Add(pt, sz)
End Function
Public Shared [Operator] -(ByVal pt As Point, ByVal sz As Size) As Point
Return Point.Subtract(pt, sz)
End Function
Public Shared [Operator] =(ByVal left As Point, ByVal right As Point) As Boolean
Return ((left.X = right.X) AndAlso (left.Y = right.Y))
End Function
Public Shared [Operator] <>(ByVal left As Point, ByVal right As Point) As Boolean
Return Not (left = right)
End Function
Public Shared Function Add(ByVal pt As Point, ByVal sz As Size) As Point
Return New Point((pt.X + sz.Width), (pt.Y + sz.Height))
End Function
Public Shared Function Subtract(ByVal pt As Point, ByVal sz As Size) As Point
Return New Point((pt.X - sz.Width), (pt.Y - sz.Height))
End Function
Public Shared Function Ceiling(ByVal value As PointF) As Point
Return New Point(CInt(Math.Ceiling(CDbl(value.X))), CInt(Math.Ceiling(CDbl(value.Y))))
End Function
Public Shared Function Truncate(ByVal value As PointF) As Point
Return New Point(CInt(value.X), CInt(value.Y))
End Function
Public Shared Function Round(ByVal value As PointF) As Point
Return New Point(CInt(Math.Round(CDbl(value.X))), CInt(Math.Round(CDbl(value.Y))))
End Function
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If Not TypeOf obj Is Point Then
Return False
End If
Dim point As Point = DirectCast(obj, Point)
Return ((point.X = Me.X) AndAlso (point.Y = Me.Y))
End Function
Public Overrides Function GetHashCode() As Integer
Return (Me.x Xor Me.y)
End Function
Public Sub Offset(ByVal dx As Integer, ByVal dy As Integer)
Me.X = (Me.X + dx)
Me.Y = (Me.Y + dy)
End Sub
Public Sub Offset(ByVal p As Point)
Me.Offset(p.X, p.Y)
End Sub
Public Overrides Function ToString() As String
Return String.Concat(New String() { "{X=", Me.X.ToString(CultureInfo.CurrentCulture), ",Y=", Me.Y.ToString(CultureInfo.CurrentCulture), "}" })
End Function
Private Shared Function HIWORD(ByVal n As Integer) As Integer
Return ((n >> &H10) And &HFFFF)
End Function
Private Shared Function LOWORD(ByVal n As Integer) As Integer
Return (n And &HFFFF)
End Function
Shared Sub New()
Point.Empty = New Point
End Sub
End Structure
End Namespace
- Point类源代码
- Point类
- point 类
- Point 类
- Point类android.graphics.Point
- Point类计算矢量
- Point类重载
- android Point类,画线
- C++实现Point类
- C++ Line,Point类
- Opencv的Point类
- Point类的定义
- C++之Point类
- Size数据结构 Point类
- Point
- Point
- point
- Point
- 03年一个项目相关的东西(词)
- GoF设计模式的概括
- C# 检查字符串,防SQL注入攻击
- DTS==Data Transfer System
- 跟踪竞争对手动向和用户反馈
- Point类源代码
- ASP.NET 2.0中实现跨页面提交
- CSS里也写脚本
- OracleConnection类源代码
- 嵌入式系统内存管理方案研究
- 嵌入式系统内存管理方案研究
- 在Windows 2003下安装ZoneAlarm Pro 7
- 最近闲着无聊,做个里网站,http://yzkzoo.freehoxt.com
- 忘了Linux的root密码怎么办?