Author:水如烟
Imports
LzmTW.uSystem.uWindows.Win32API
Imports System.ComponentModel
Namespace LzmTW.uSystem.uWindows.uForms.uMainForm
Partial Class KeyStatusWatcherStripStatus
Inherits Windows.Forms.StatusStrip
' <System.Diagnostics.DebuggerNonUserCode()> _
Public Sub New ( ByVal Container As System.ComponentModel.IContainer)
MyClass .New()
' Windows.Forms 类撰写设计器支持所必需的
Me .NotifyStripStatusMenuItem.Visible = False
Container.Add( Me )
KeyStatusWatcher.ServiceBegin() ' 运行时生效
End Sub
< System.Diagnostics.DebuggerNonUserCode() > _
Public Sub New ()
MyBase .New()
' 组件设计器需要此调用。
InitializeComponent()
Initialize()
' KeyStatusWatcher.ServiceBegin() '设计时生效
End Sub
' Component 重写 Dispose,以清理组件列表。
< System.Diagnostics.DebuggerNonUserCode() > _
Protected Overrides Sub Dispose( ByVal disposing As Boolean )
If disposing AndAlso components IsNot Nothing Then
KeyStatusWatcher.ServiceDispose() ' 清理
KeyStatusWatcher = Nothing
components.Dispose()
End If
MyBase .Dispose(disposing)
End Sub
' 组件设计器所必需的
Private components As System.ComponentModel.IContainer
' 注意: 以下过程是组件设计器所必需的
' 可使用组件设计器修改它。
' 不要使用代码编辑器修改它。
< System.Diagnostics.DebuggerStepThrough() > _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me .MessageToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .ToolStripProgressBar = New System.Windows.Forms.ToolStripProgressBar
Me .CapsLockToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .NumLockToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .ScrollLockToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .InsertToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .DateToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .TimeToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .NotifyStripStatusMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me .SuspendLayout()
'
' MessageToolStripStatusLabel
'
Me .MessageToolStripStatusLabel.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me .MessageToolStripStatusLabel.Name = " MessageToolStripStatusLabel "
Me .MessageToolStripStatusLabel.RightToLeft = System.Windows.Forms.RightToLeft.No
Me .MessageToolStripStatusLabel.Size = New System.Drawing.Size( 465 , 17 )
Me .MessageToolStripStatusLabel.Spring = True
Me .MessageToolStripStatusLabel.Text = " 待命 "
Me .MessageToolStripStatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
' ToolStripProgressBar
'
Me .ToolStripProgressBar.Name = " ToolStripProgressBar "
Me .ToolStripProgressBar.Size = New System.Drawing.Size( 100 , 16 )
Me .ToolStripProgressBar.Visible = False
'
' CapsLockToolStripStatusLabel
'
Me .CapsLockToolStripStatusLabel.Name = " CapsLockToolStripStatusLabel "
Me .CapsLockToolStripStatusLabel.Text = " 大写 "
'
' NumLockToolStripStatusLabel
'
Me .NumLockToolStripStatusLabel.Name = " NumLockToolStripStatusLabel "
Me .NumLockToolStripStatusLabel.Text = " 数字 "
'
' ScrollLockToolStripStatusLabel
'
Me .ScrollLockToolStripStatusLabel.Name = " ScrollLockToolStripStatusLabel "
Me .ScrollLockToolStripStatusLabel.Text = " 滚动 "
'
' InsertToolStripStatusLabel
'
Me .InsertToolStripStatusLabel.Name = " InsertToolStripStatusLabel "
Me .InsertToolStripStatusLabel.Text = " 改写 "
'
' DateToolStripStatusLabel
'
Me .DateToolStripStatusLabel.Name = " DateToolStripStatusLabel "
Me .DateToolStripStatusLabel.Text = " 日期 "
'
' TimeToolStripStatusLabel
'
Me .TimeToolStripStatusLabel.Name = " TimeToolStripStatusLabel "
Me .TimeToolStripStatusLabel.Text = " 时间 "
'
' NotifyStripStatusMenuItem
'
Me .NotifyStripStatusMenuItem.Text = " Z "
Me .NotifyStripStatusMenuItem.ShortcutKeys = Keys.Control Or Keys.Shift Or Keys.I
Me .Items.AddRange( New System.Windows.Forms.ToolStripItem() { Me .MessageToolStripStatusLabel, Me .ToolStripProgressBar, Me .CapsLockToolStripStatusLabel, Me .NumLockToolStripStatusLabel, Me .ScrollLockToolStripStatusLabel, Me .InsertToolStripStatusLabel, Me .DateToolStripStatusLabel, Me .TimeToolStripStatusLabel, Me .NotifyStripStatusMenuItem})
Me .ResumeLayout( False )
Me .PerformLayout()
End Sub
#Region "定义"
Private WithEvents MessageToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents ToolStripProgressBar As System.Windows.Forms.ToolStripProgressBar
Private WithEvents NumLockToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents CapsLockToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents ScrollLockToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents InsertToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents DateToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents TimeToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents NotifyStripStatusMenuItem As System.Windows.Forms.ToolStripMenuItem
Private WithEvents KeyStatusWatcher As uSystem.uWindows.Win32API.KeyStatusWather
Private gNotify As uNotifyIcon
Private gDefaultMessage As String = " 待命 "
' 监视键共用属性
Private gDefaultBackColor As System.Drawing.Color = Color.Gainsboro
Private gDefaultBorderBorderSides As ToolStripStatusLabelBorderSides = ToolStripStatusLabelBorderSides.All
Private gDefaultBorderStyle As Border3DStyle = Border3DStyle.Etched
Private gDefaultDisplaryStyle As ToolStripItemDisplayStyle = ToolStripItemDisplayStyle.Text
#End Region
#Region "界面处理"
Private Sub Initialize()
UpdateStyle()
VisualUiFont.Instance.SetFont( Me .NotifyStripStatusMenuItem)
KeyStatusWatcher = New uSystem.uWindows.Win32API.KeyStatusWather
KeyStatusWatcher.ServceInitialze()
End Sub
Private Sub UpdateStyle()
For Each key As StatusKey In [ Enum ].GetValues( GetType (StatusKey))
UpdateStyle(key)
Next
End Sub
Private Sub UpdateStyle( ByVal key As StatusKey)
With GetStatusLabel(key)
.BackColor = Me .gDefaultBackColor
.BorderSides = Me .gDefaultBorderBorderSides
.BorderStyle = Me .gDefaultBorderStyle
.DisplayStyle = Me .gDefaultDisplaryStyle
End With
End Sub
#End Region
#Region "属性"
< Browsable( True ), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), DefaultValue( " 待命 " ) > _
Public Property DefaultMessage() As String
Set ( ByVal value As String )
gDefaultMessage = value
Me .ReceiveMessage(value)
End Set
Get
Return gDefaultMessage
End Get
End Property
Public ReadOnly Property MessageLabel() As ToolStripStatusLabel
Get
Return Me .MessageToolStripStatusLabel
End Get
End Property
Public ReadOnly Property ProgressBar() As ToolStripProgressBar
Get
Return Me .ToolStripProgressBar
End Get
End Property
Public WriteOnly Property NotifyIcon() As uNotifyIcon
Set ( ByVal value As uNotifyIcon)
If gNotify IsNot Nothing Then Exit Property
gNotify = value
Me .NotifyStripStatusMenuItem.Visible = True
End Set
End Property
Public ReadOnly Property WatcherService() As uSystem.uWindows.Win32API.KeyStatusWather
Get
Return Me .KeyStatusWatcher
End Get
End Property
#End Region
#Region "消息处理"
Public Function GetStatusLabel( ByVal key As StatusKey) As ToolStripStatusLabel
Select Case key
Case StatusKey.NumLock
Return Me .NumLockToolStripStatusLabel
Case StatusKey.CapsLock
Return Me .CapsLockToolStripStatusLabel
Case StatusKey.ScrollLock
Return Me .ScrollLockToolStripStatusLabel
Case StatusKey.Insert
Return Me .InsertToolStripStatusLabel
Case StatusKey.Date
Return Me .DateToolStripStatusLabel
Case StatusKey.Time
Return Me .TimeToolStripStatusLabel
Case Else
Return Nothing
End Select
End Function
Public Enum StatusKey
NumLock
CapsLock
ScrollLock
Insert
[ Date ]
Time
End Enum
Private Sub KeyStatusWatcher_KeyStatusChanged( ByVal sender As Object , ByVal args As Win32API.KeyStatusWatcherEventArgs) Handles KeyStatusWatcher.KeyStatusChanged
Select Case args.MsgKey
Case KeyWatcher.Time
Me .SetControlPropertyValue( Me .DateToolStripStatusLabel, " Text " , args.Now.ToLongDateString, Nothing )
Me .SetControlPropertyValue( Me .TimeToolStripStatusLabel, " Text " , args.Now.ToLongTimeString, Nothing )
Case Else
Me .SetControlPropertyValue(GetStatusLabel( CType ([ Enum ].Parse( GetType (StatusKey), args.MsgKey.ToString), StatusKey)), " Enabled " , args.IsEnabled, Nothing )
End Select
End Sub
Private Sub SetControlPropertyValue( ByVal ctr As Object , ByVal propertyName As String , ByVal value As Object , ByVal index As Object ())
uThreading.CrossThread.SetControlPropertyValue(ctr, propertyName, value, index)
End Sub
Private Sub NotifyStripStatusMenuItem_Click( ByVal sender As Object , ByVal e As System.EventArgs) Handles NotifyStripStatusMenuItem.Click
gNotify.HideWindow()
End Sub
#End Region
End Class
End Namespace
Imports System.ComponentModel
Namespace LzmTW.uSystem.uWindows.uForms.uMainForm
Partial Class KeyStatusWatcherStripStatus
Inherits Windows.Forms.StatusStrip
' <System.Diagnostics.DebuggerNonUserCode()> _
Public Sub New ( ByVal Container As System.ComponentModel.IContainer)
MyClass .New()
' Windows.Forms 类撰写设计器支持所必需的
Me .NotifyStripStatusMenuItem.Visible = False
Container.Add( Me )
KeyStatusWatcher.ServiceBegin() ' 运行时生效
End Sub
< System.Diagnostics.DebuggerNonUserCode() > _
Public Sub New ()
MyBase .New()
' 组件设计器需要此调用。
InitializeComponent()
Initialize()
' KeyStatusWatcher.ServiceBegin() '设计时生效
End Sub
' Component 重写 Dispose,以清理组件列表。
< System.Diagnostics.DebuggerNonUserCode() > _
Protected Overrides Sub Dispose( ByVal disposing As Boolean )
If disposing AndAlso components IsNot Nothing Then
KeyStatusWatcher.ServiceDispose() ' 清理
KeyStatusWatcher = Nothing
components.Dispose()
End If
MyBase .Dispose(disposing)
End Sub
' 组件设计器所必需的
Private components As System.ComponentModel.IContainer
' 注意: 以下过程是组件设计器所必需的
' 可使用组件设计器修改它。
' 不要使用代码编辑器修改它。
< System.Diagnostics.DebuggerStepThrough() > _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me .MessageToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .ToolStripProgressBar = New System.Windows.Forms.ToolStripProgressBar
Me .CapsLockToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .NumLockToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .ScrollLockToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .InsertToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .DateToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .TimeToolStripStatusLabel = New System.Windows.Forms.ToolStripStatusLabel
Me .NotifyStripStatusMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me .SuspendLayout()
'
' MessageToolStripStatusLabel
'
Me .MessageToolStripStatusLabel.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me .MessageToolStripStatusLabel.Name = " MessageToolStripStatusLabel "
Me .MessageToolStripStatusLabel.RightToLeft = System.Windows.Forms.RightToLeft.No
Me .MessageToolStripStatusLabel.Size = New System.Drawing.Size( 465 , 17 )
Me .MessageToolStripStatusLabel.Spring = True
Me .MessageToolStripStatusLabel.Text = " 待命 "
Me .MessageToolStripStatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
' ToolStripProgressBar
'
Me .ToolStripProgressBar.Name = " ToolStripProgressBar "
Me .ToolStripProgressBar.Size = New System.Drawing.Size( 100 , 16 )
Me .ToolStripProgressBar.Visible = False
'
' CapsLockToolStripStatusLabel
'
Me .CapsLockToolStripStatusLabel.Name = " CapsLockToolStripStatusLabel "
Me .CapsLockToolStripStatusLabel.Text = " 大写 "
'
' NumLockToolStripStatusLabel
'
Me .NumLockToolStripStatusLabel.Name = " NumLockToolStripStatusLabel "
Me .NumLockToolStripStatusLabel.Text = " 数字 "
'
' ScrollLockToolStripStatusLabel
'
Me .ScrollLockToolStripStatusLabel.Name = " ScrollLockToolStripStatusLabel "
Me .ScrollLockToolStripStatusLabel.Text = " 滚动 "
'
' InsertToolStripStatusLabel
'
Me .InsertToolStripStatusLabel.Name = " InsertToolStripStatusLabel "
Me .InsertToolStripStatusLabel.Text = " 改写 "
'
' DateToolStripStatusLabel
'
Me .DateToolStripStatusLabel.Name = " DateToolStripStatusLabel "
Me .DateToolStripStatusLabel.Text = " 日期 "
'
' TimeToolStripStatusLabel
'
Me .TimeToolStripStatusLabel.Name = " TimeToolStripStatusLabel "
Me .TimeToolStripStatusLabel.Text = " 时间 "
'
' NotifyStripStatusMenuItem
'
Me .NotifyStripStatusMenuItem.Text = " Z "
Me .NotifyStripStatusMenuItem.ShortcutKeys = Keys.Control Or Keys.Shift Or Keys.I
Me .Items.AddRange( New System.Windows.Forms.ToolStripItem() { Me .MessageToolStripStatusLabel, Me .ToolStripProgressBar, Me .CapsLockToolStripStatusLabel, Me .NumLockToolStripStatusLabel, Me .ScrollLockToolStripStatusLabel, Me .InsertToolStripStatusLabel, Me .DateToolStripStatusLabel, Me .TimeToolStripStatusLabel, Me .NotifyStripStatusMenuItem})
Me .ResumeLayout( False )
Me .PerformLayout()
End Sub
#Region "定义"
Private WithEvents MessageToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents ToolStripProgressBar As System.Windows.Forms.ToolStripProgressBar
Private WithEvents NumLockToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents CapsLockToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents ScrollLockToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents InsertToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents DateToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents TimeToolStripStatusLabel As System.Windows.Forms.ToolStripStatusLabel
Private WithEvents NotifyStripStatusMenuItem As System.Windows.Forms.ToolStripMenuItem
Private WithEvents KeyStatusWatcher As uSystem.uWindows.Win32API.KeyStatusWather
Private gNotify As uNotifyIcon
Private gDefaultMessage As String = " 待命 "
' 监视键共用属性
Private gDefaultBackColor As System.Drawing.Color = Color.Gainsboro
Private gDefaultBorderBorderSides As ToolStripStatusLabelBorderSides = ToolStripStatusLabelBorderSides.All
Private gDefaultBorderStyle As Border3DStyle = Border3DStyle.Etched
Private gDefaultDisplaryStyle As ToolStripItemDisplayStyle = ToolStripItemDisplayStyle.Text
#End Region
#Region "界面处理"
Private Sub Initialize()
UpdateStyle()
VisualUiFont.Instance.SetFont( Me .NotifyStripStatusMenuItem)
KeyStatusWatcher = New uSystem.uWindows.Win32API.KeyStatusWather
KeyStatusWatcher.ServceInitialze()
End Sub
Private Sub UpdateStyle()
For Each key As StatusKey In [ Enum ].GetValues( GetType (StatusKey))
UpdateStyle(key)
Next
End Sub
Private Sub UpdateStyle( ByVal key As StatusKey)
With GetStatusLabel(key)
.BackColor = Me .gDefaultBackColor
.BorderSides = Me .gDefaultBorderBorderSides
.BorderStyle = Me .gDefaultBorderStyle
.DisplayStyle = Me .gDefaultDisplaryStyle
End With
End Sub
#End Region
#Region "属性"
< Browsable( True ), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), DefaultValue( " 待命 " ) > _
Public Property DefaultMessage() As String
Set ( ByVal value As String )
gDefaultMessage = value
Me .ReceiveMessage(value)
End Set
Get
Return gDefaultMessage
End Get
End Property
Public ReadOnly Property MessageLabel() As ToolStripStatusLabel
Get
Return Me .MessageToolStripStatusLabel
End Get
End Property
Public ReadOnly Property ProgressBar() As ToolStripProgressBar
Get
Return Me .ToolStripProgressBar
End Get
End Property
Public WriteOnly Property NotifyIcon() As uNotifyIcon
Set ( ByVal value As uNotifyIcon)
If gNotify IsNot Nothing Then Exit Property
gNotify = value
Me .NotifyStripStatusMenuItem.Visible = True
End Set
End Property
Public ReadOnly Property WatcherService() As uSystem.uWindows.Win32API.KeyStatusWather
Get
Return Me .KeyStatusWatcher
End Get
End Property
#End Region
#Region "消息处理"
Public Function GetStatusLabel( ByVal key As StatusKey) As ToolStripStatusLabel
Select Case key
Case StatusKey.NumLock
Return Me .NumLockToolStripStatusLabel
Case StatusKey.CapsLock
Return Me .CapsLockToolStripStatusLabel
Case StatusKey.ScrollLock
Return Me .ScrollLockToolStripStatusLabel
Case StatusKey.Insert
Return Me .InsertToolStripStatusLabel
Case StatusKey.Date
Return Me .DateToolStripStatusLabel
Case StatusKey.Time
Return Me .TimeToolStripStatusLabel
Case Else
Return Nothing
End Select
End Function
Public Enum StatusKey
NumLock
CapsLock
ScrollLock
Insert
[ Date ]
Time
End Enum
Private Sub KeyStatusWatcher_KeyStatusChanged( ByVal sender As Object , ByVal args As Win32API.KeyStatusWatcherEventArgs) Handles KeyStatusWatcher.KeyStatusChanged
Select Case args.MsgKey
Case KeyWatcher.Time
Me .SetControlPropertyValue( Me .DateToolStripStatusLabel, " Text " , args.Now.ToLongDateString, Nothing )
Me .SetControlPropertyValue( Me .TimeToolStripStatusLabel, " Text " , args.Now.ToLongTimeString, Nothing )
Case Else
Me .SetControlPropertyValue(GetStatusLabel( CType ([ Enum ].Parse( GetType (StatusKey), args.MsgKey.ToString), StatusKey)), " Enabled " , args.IsEnabled, Nothing )
End Select
End Sub
Private Sub SetControlPropertyValue( ByVal ctr As Object , ByVal propertyName As String , ByVal value As Object , ByVal index As Object ())
uThreading.CrossThread.SetControlPropertyValue(ctr, propertyName, value, index)
End Sub
Private Sub NotifyStripStatusMenuItem_Click( ByVal sender As Object , ByVal e As System.EventArgs) Handles NotifyStripStatusMenuItem.Click
gNotify.HideWindow()
End Sub
#End Region
End Class
End Namespace
Imports
LzmTW.uSystem.uWindows.Win32API
Namespace LzmTW.uSystem.uWindows.uForms.uMainForm
< System.Drawing.ToolboxBitmap( " ../../Resources/KeyStatus.ico " ) > _
Public Class KeyStatusWatcherStripStatus
Private gOrignalProgreeBarStyle As Windows.Forms.ProgressBarStyle
Public Sub ReceiveMessage( ByVal message As String )
Me .SetControlPropertyValue( Me .MessageLabel, " Text " , message, Nothing )
Application.DoEvents()
End Sub
Public Sub ReceiveMessage()
ReceiveMessage(gDefaultMessage)
End Sub
' 待更新
Public Sub ProgressMarqueeStart()
With Me .ToolStripProgressBar
If .Visible = True Then Exit Sub
gOrignalProgreeBarStyle = .Style
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Visible " , True , Nothing )
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Style " , ProgressBarStyle.Marquee, Nothing )
End With
End Sub
' 待更新
Public Sub ProgressMarqueeStop()
With Me .ToolStripProgressBar
If .Style <> ProgressBarStyle.Marquee Then Exit Sub
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Visible " , False , Nothing )
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Style " , gOrignalProgreeBarStyle, Nothing )
End With
End Sub
Public Function InsertStatusLabel( ByVal shortName As String ) As Windows.Forms.ToolStripStatusLabel
Dim mIndex As Integer = Me .Items.IndexOf( Me .ProgressBar)
Return InsertStatusLabel(mIndex, shortName)
End Function
Public Function InsertStatusLabel( ByVal index As Integer , ByVal shortName As String ) As Windows.Forms.ToolStripStatusLabel
Dim mToolStripStatusLabel As New ToolStripStatusLabel
mToolStripStatusLabel = FindStatusLabel(shortName)
If mToolStripStatusLabel IsNot Nothing Then Return mToolStripStatusLabel
mToolStripStatusLabel = New ToolStripStatusLabel
With mToolStripStatusLabel
.BorderSides = ToolStripStatusLabelBorderSides.All
.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenOuter
.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
.Name = shortName & " ToolStripStatusLabel "
.Text = shortName
End With
Me .Items.Insert(index, mToolStripStatusLabel)
Return mToolStripStatusLabel
End Function
Public Function FindStatusLabel( ByVal shortName As String ) As Windows.Forms.ToolStripStatusLabel
Dim mResult As Windows.Forms.ToolStripStatusLabel = Nothing
shortName = shortName & " ToolStripStatusLabel "
Dim tmp As Windows.Forms.ToolStripItem() = Me .Items.Find(shortName, True )
If tmp.Length = 1 Then
mResult = CType (tmp( 0 ), ToolStripStatusLabel)
End If
Return mResult
End Function
Public Function RemoveStatusLabel( ByVal shortName As String ) As Boolean
Dim mToolStripStatusLabel As New ToolStripStatusLabel
mToolStripStatusLabel = FindStatusLabel(shortName)
If mToolStripStatusLabel Is Nothing Then Return False
Me .Items.Remove(mToolStripStatusLabel)
mToolStripStatusLabel.Dispose()
Return True
End Function
End Class
End Namespace
Namespace LzmTW.uSystem.uWindows.uForms.uMainForm
< System.Drawing.ToolboxBitmap( " ../../Resources/KeyStatus.ico " ) > _
Public Class KeyStatusWatcherStripStatus
Private gOrignalProgreeBarStyle As Windows.Forms.ProgressBarStyle
Public Sub ReceiveMessage( ByVal message As String )
Me .SetControlPropertyValue( Me .MessageLabel, " Text " , message, Nothing )
Application.DoEvents()
End Sub
Public Sub ReceiveMessage()
ReceiveMessage(gDefaultMessage)
End Sub
' 待更新
Public Sub ProgressMarqueeStart()
With Me .ToolStripProgressBar
If .Visible = True Then Exit Sub
gOrignalProgreeBarStyle = .Style
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Visible " , True , Nothing )
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Style " , ProgressBarStyle.Marquee, Nothing )
End With
End Sub
' 待更新
Public Sub ProgressMarqueeStop()
With Me .ToolStripProgressBar
If .Style <> ProgressBarStyle.Marquee Then Exit Sub
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Visible " , False , Nothing )
Me .SetControlPropertyValue( Me .ToolStripProgressBar, " Style " , gOrignalProgreeBarStyle, Nothing )
End With
End Sub
Public Function InsertStatusLabel( ByVal shortName As String ) As Windows.Forms.ToolStripStatusLabel
Dim mIndex As Integer = Me .Items.IndexOf( Me .ProgressBar)
Return InsertStatusLabel(mIndex, shortName)
End Function
Public Function InsertStatusLabel( ByVal index As Integer , ByVal shortName As String ) As Windows.Forms.ToolStripStatusLabel
Dim mToolStripStatusLabel As New ToolStripStatusLabel
mToolStripStatusLabel = FindStatusLabel(shortName)
If mToolStripStatusLabel IsNot Nothing Then Return mToolStripStatusLabel
mToolStripStatusLabel = New ToolStripStatusLabel
With mToolStripStatusLabel
.BorderSides = ToolStripStatusLabelBorderSides.All
.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenOuter
.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
.Name = shortName & " ToolStripStatusLabel "
.Text = shortName
End With
Me .Items.Insert(index, mToolStripStatusLabel)
Return mToolStripStatusLabel
End Function
Public Function FindStatusLabel( ByVal shortName As String ) As Windows.Forms.ToolStripStatusLabel
Dim mResult As Windows.Forms.ToolStripStatusLabel = Nothing
shortName = shortName & " ToolStripStatusLabel "
Dim tmp As Windows.Forms.ToolStripItem() = Me .Items.Find(shortName, True )
If tmp.Length = 1 Then
mResult = CType (tmp( 0 ), ToolStripStatusLabel)
End If
Return mResult
End Function
Public Function RemoveStatusLabel( ByVal shortName As String ) As Boolean
Dim mToolStripStatusLabel As New ToolStripStatusLabel
mToolStripStatusLabel = FindStatusLabel(shortName)
If mToolStripStatusLabel Is Nothing Then Return False
Me .Items.Remove(mToolStripStatusLabel)
mToolStripStatusLabel.Dispose()
Return True
End Function
End Class
End Namespace