Public Class My_事务标签
Inherits System.Windows.Forms.Label
Private toolTip1 As System.Windows.Forms.ToolTip
Private into As Boolean = False
Private pr As Drawing2D.LinearGradientBrush
Private Sub back() '设置背景的颜色,此处使用的渐变色,可以根据需要修改
Dim BJ_p1 As Point = New Point(0, 0)
Dim BJ_p2 As Point = New Point(0, Me.Height)
If into Then '鼠标进入
pr = New Drawing2D.LinearGradientBrush(BJ_p1, BJ_p2, Color.Orange, Color.NavajoWhite)
Else
Select Case TaskType
Case 1 '普通任务
pr = New Drawing2D.LinearGradientBrush(BJ_p1, BJ_p2, Color.Orange, Color.NavajoWhite)
Case 2 '周期性任务
pr = New Drawing2D.LinearGradientBrush(BJ_p1, BJ_p2, Color.DeepSkyBlue, Color.PowderBlue)
Case 3 '过期任务
pr = New Drawing2D.LinearGradientBrush(BJ_p1, BJ_p2, Color.Tomato, Color.DarkSalmon)
Case 4 '终止的任务
pr = New Drawing2D.LinearGradientBrush(BJ_p1, BJ_p2, Color.DarkGray, Color.LightGray)
End Select
End If
End Sub
Private TaskType As Integer = 1
'任务的类型,1-普通任务 2-周期性任务 3-过期任务 4-终止的任务
Private TaskContent As List(Of String)
'用户传递数据
Public Property MyTaskContent() As List(Of String)
Get
Return TaskContent
End Get
Set(ByVal value As List(Of String))
TaskContent = value
End Set
End Property
Private TaskDate As Date
'标签所属的时间
Public Property MyTaskDate() As Date
Get
Return TaskDate
End Get
Set(ByVal value As Date)
TaskDate = value
End Set
End Property
Public Sub New(ByVal 标题 As String, ByVal 任务类型 As Integer, ByVal 内容 As List(Of String))
Me.Text = 标题
TaskType = 任务类型
MyTaskContent = 内容
Me.BorderStyle = Windows.Forms.BorderStyle.FixedSingle
toolTip1 = New System.Windows.Forms.ToolTip
toolTip1.AutoPopDelay = 5000
toolTip1.InitialDelay = 1000
toolTip1.ReshowDelay = 500
toolTip1.ShowAlways = True
End Sub
Private Sub My_日历标签_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick
'在狐表中写自定义函数,控件的双击事件,可以打开相应的窗口 传递 sender ?e TaskContent
Functions.Execute("事务_标签被双击",sender,e,TaskContent)
End Sub
Private MyPoint As Point
Private Sub My_日历标签_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
MyPoint = e.Location
End Sub
Private Sub My_日历标签_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
into = True
Me.Refresh()
End Sub
Private Sub My_日历标签_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseHover
toolTip1.SetToolTip(Me, Me.Text)
End Sub
Private Sub My_日历标签_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
into = False
Me.Refresh()
End Sub
Private Sub My_日历标签_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
'在狐表中写自定义函数,控件的移动事件,要传递 sender ?e MyPoint
End Sub
Private Sub My_日历标签_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'标签重绘
back()
Dim g As Graphics = e.Graphics
Dim fnt As Font = Me.Font
Dim br As SolidBrush = New SolidBrush(System.Drawing.SystemColors.ControlText)
Dim sf1 As New StringFormat
sf1.Alignment = StringAlignment.Near '居中对齐
Dim ref As New RectangleF(2, 2, Me.Width - 4, Me.Height - 4)
g.FillRectangle(pr, New Rectangle(0, 0, Me.Width, Me.Height))
g.DrawString(Me.Text, fnt, br, ref, sf1)
End Sub
End Class