Author:水如烟
指示框:
MessageForm.Designer.vb
MessageForm.vb
ProgressForm.Designer.vb
ProgressForm.vb
WaitingForm.vb
指示框:
MessageForm.Designer.vb
Namespace ApplicationBase
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MessageForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.LabelMessage = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'LabelMessage
'
Me.LabelMessage.AutoSize = True
Me.LabelMessage.Location = New System.Drawing.Point(12, 9)
Me.LabelMessage.Name = "LabelMessage"
Me.LabelMessage.Size = New System.Drawing.Size(83, 12)
Me.LabelMessage.TabIndex = 0
Me.LabelMessage.Text = "进行中 "
'
'MessageForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(567, 71)
Me.ControlBox = False
Me.Controls.Add(Me.LabelMessage)
Me.MaximumSize = New System.Drawing.Size(575, 98)
Me.MinimumSize = New System.Drawing.Size(575, 98)
Me.Name = "MessageForm"
Me.ShowInTaskbar = False
Me.Text = "请稍候"
Me.TopMost = True
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private WithEvents LabelMessage As System.Windows.Forms.Label
End Class
End Namespace
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MessageForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.LabelMessage = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'LabelMessage
'
Me.LabelMessage.AutoSize = True
Me.LabelMessage.Location = New System.Drawing.Point(12, 9)
Me.LabelMessage.Name = "LabelMessage"
Me.LabelMessage.Size = New System.Drawing.Size(83, 12)
Me.LabelMessage.TabIndex = 0
Me.LabelMessage.Text = "进行中 "
'
'MessageForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(567, 71)
Me.ControlBox = False
Me.Controls.Add(Me.LabelMessage)
Me.MaximumSize = New System.Drawing.Size(575, 98)
Me.MinimumSize = New System.Drawing.Size(575, 98)
Me.Name = "MessageForm"
Me.ShowInTaskbar = False
Me.Text = "请稍候"
Me.TopMost = True
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private WithEvents LabelMessage As System.Windows.Forms.Label
End Class
End Namespace
MessageForm.vb
Imports System.Windows.Forms
Namespace ApplicationBase
Friend Class MessageForm
Protected Delegate Sub SetControlText(ByVal ctr As Control, ByVal s As String)
Private CanClose As Boolean = False
Protected Sub OnSetControlText(ByVal ctr As Control, ByVal s As String)
If ctr.InvokeRequired Then
Dim d As New SetControlText(AddressOf OnSetControlText)
Me.Invoke(d, New Object() {ctr, s})
Else
ctr.Text = s
End If
Application.DoEvents()
End Sub
Private Sub WaitingForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = Not CanClose
End Sub
Public Sub SetFormText(ByVal s As String)
OnSetControlText(Me, s)
End Sub
Public Sub SetMessage(ByVal s As String)
OnSetControlText(Me.LabelMessage, s)
End Sub
Public Sub SetMessage(ByVal format As String, ByVal args() As Object)
SetMessage(String.Format(format, args))
End Sub
Public Sub SetCanClose(ByVal yes As Boolean)
CanClose = yes
End Sub
End Class
End Namespace
Namespace ApplicationBase
Friend Class MessageForm
Protected Delegate Sub SetControlText(ByVal ctr As Control, ByVal s As String)
Private CanClose As Boolean = False
Protected Sub OnSetControlText(ByVal ctr As Control, ByVal s As String)
If ctr.InvokeRequired Then
Dim d As New SetControlText(AddressOf OnSetControlText)
Me.Invoke(d, New Object() {ctr, s})
Else
ctr.Text = s
End If
Application.DoEvents()
End Sub
Private Sub WaitingForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = Not CanClose
End Sub
Public Sub SetFormText(ByVal s As String)
OnSetControlText(Me, s)
End Sub
Public Sub SetMessage(ByVal s As String)
OnSetControlText(Me.LabelMessage, s)
End Sub
Public Sub SetMessage(ByVal format As String, ByVal args() As Object)
SetMessage(String.Format(format, args))
End Sub
Public Sub SetCanClose(ByVal yes As Boolean)
CanClose = yes
End Sub
End Class
End Namespace
ProgressForm.Designer.vb
Namespace ApplicationBase
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class ProgressForm
Inherits ApplicationBase.MessageForm
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ProgressBar = New System.Windows.Forms.ProgressBar
Me.SuspendLayout()
'
'ProgressBar
'
Me.ProgressBar.Location = New System.Drawing.Point(16, 35)
Me.ProgressBar.Name = "ProgressBar"
Me.ProgressBar.Size = New System.Drawing.Size(541, 23)
Me.ProgressBar.Step = 1
Me.ProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee
Me.ProgressBar.TabIndex = 1
'
'ProgressForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.ClientSize = New System.Drawing.Size(567, 71)
Me.Controls.Add(Me.ProgressBar)
Me.Name = "ProgressForm"
Me.Controls.SetChildIndex(Me.ProgressBar, 0)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private WithEvents ProgressBar As System.Windows.Forms.ProgressBar
End Class
End Namespace
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class ProgressForm
Inherits ApplicationBase.MessageForm
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ProgressBar = New System.Windows.Forms.ProgressBar
Me.SuspendLayout()
'
'ProgressBar
'
Me.ProgressBar.Location = New System.Drawing.Point(16, 35)
Me.ProgressBar.Name = "ProgressBar"
Me.ProgressBar.Size = New System.Drawing.Size(541, 23)
Me.ProgressBar.Step = 1
Me.ProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee
Me.ProgressBar.TabIndex = 1
'
'ProgressForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.ClientSize = New System.Drawing.Size(567, 71)
Me.Controls.Add(Me.ProgressBar)
Me.Name = "ProgressForm"
Me.Controls.SetChildIndex(Me.ProgressBar, 0)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private WithEvents ProgressBar As System.Windows.Forms.ProgressBar
End Class
End Namespace
ProgressForm.vb
Namespace ApplicationBase
Friend Class ProgressForm
End Class
End Namespace
Friend Class ProgressForm
End Class
End Namespace
WaitingForm.vb
Namespace ApplicationBase
Public Class WaitingForm
Private gMessageForm As MessageForm
Private Shared gCurrentForm As WaitingForm
Public Shared ReadOnly Property CurrentForm() As WaitingForm
Get
Return gCurrentForm
End Get
End Property
Sub New(ByVal FormType As MessageFormType)
Select Case FormType
Case MessageFormType.Message
gMessageForm = New MessageForm
Case MessageFormType.Progress
gMessageForm = New ProgressForm
End Select
gCurrentForm = Me
End Sub
Public Sub ReceiveMessage(ByVal s As String)
ReceiveMessage(s, False)
End Sub
Public Sub ReceiveMessage(ByVal s As String, ByVal IsTitle As Boolean)
If IsTitle Then
gMessageForm.SetFormText(s)
Else
gMessageForm.SetMessage(s)
End If
End Sub
Public Sub ReceiveMessage(ByVal format As String, ByVal args() As Object)
ReceiveMessage(format, args, False)
End Sub
Public Sub ReceiveMessage(ByVal format As String, ByVal args() As Object, ByVal IsTitle As Boolean)
ReceiveMessage(String.Format(format, args), IsTitle)
End Sub
Public Sub Show()
gMessageForm.Show()
End Sub
Public Sub Hide()
gMessageForm.Hide()
End Sub
Public Sub Close()
gMessageForm.SetCanClose(True)
gMessageForm.Close()
gMessageForm = Nothing
End Sub
Public ReadOnly Property IsDisposed() As Boolean
Get
If gMessageForm Is Nothing Then Return True
Return gMessageForm.IsDisposed
End Get
End Property
'//
Private Shared gDefaultForm As WaitingForm
Private Shared gDefaultType As MessageFormType = MessageFormType.Message
Public Shared ReadOnly Property DefaultForm() As WaitingForm
Get
GetDefaultForm()
Return gDefaultForm
End Get
End Property
Private Shared Sub GetDefaultForm()
If gDefaultForm Is Nothing OrElse gDefaultForm.IsDisposed Then
gDefaultForm = New WaitingForm(gDefaultType)
End If
End Sub
Public Shared Sub SetDefaultFormType(ByVal formtype As MessageFormType)
If formtype <> gDefaultType Then
If gDefaultForm IsNot Nothing Then gDefaultForm.Close()
gDefaultType = formtype
End If
End Sub
End Class
End Namespace
Namespace ApplicationBase
Public Enum MessageFormType
Message
Progress
End Enum
End Namespace
Public Class WaitingForm
Private gMessageForm As MessageForm
Private Shared gCurrentForm As WaitingForm
Public Shared ReadOnly Property CurrentForm() As WaitingForm
Get
Return gCurrentForm
End Get
End Property
Sub New(ByVal FormType As MessageFormType)
Select Case FormType
Case MessageFormType.Message
gMessageForm = New MessageForm
Case MessageFormType.Progress
gMessageForm = New ProgressForm
End Select
gCurrentForm = Me
End Sub
Public Sub ReceiveMessage(ByVal s As String)
ReceiveMessage(s, False)
End Sub
Public Sub ReceiveMessage(ByVal s As String, ByVal IsTitle As Boolean)
If IsTitle Then
gMessageForm.SetFormText(s)
Else
gMessageForm.SetMessage(s)
End If
End Sub
Public Sub ReceiveMessage(ByVal format As String, ByVal args() As Object)
ReceiveMessage(format, args, False)
End Sub
Public Sub ReceiveMessage(ByVal format As String, ByVal args() As Object, ByVal IsTitle As Boolean)
ReceiveMessage(String.Format(format, args), IsTitle)
End Sub
Public Sub Show()
gMessageForm.Show()
End Sub
Public Sub Hide()
gMessageForm.Hide()
End Sub
Public Sub Close()
gMessageForm.SetCanClose(True)
gMessageForm.Close()
gMessageForm = Nothing
End Sub
Public ReadOnly Property IsDisposed() As Boolean
Get
If gMessageForm Is Nothing Then Return True
Return gMessageForm.IsDisposed
End Get
End Property
'//
Private Shared gDefaultForm As WaitingForm
Private Shared gDefaultType As MessageFormType = MessageFormType.Message
Public Shared ReadOnly Property DefaultForm() As WaitingForm
Get
GetDefaultForm()
Return gDefaultForm
End Get
End Property
Private Shared Sub GetDefaultForm()
If gDefaultForm Is Nothing OrElse gDefaultForm.IsDisposed Then
gDefaultForm = New WaitingForm(gDefaultType)
End If
End Sub
Public Shared Sub SetDefaultFormType(ByVal formtype As MessageFormType)
If formtype <> gDefaultType Then
If gDefaultForm IsNot Nothing Then gDefaultForm.Close()
gDefaultType = formtype
End If
End Sub
End Class
End Namespace
Namespace ApplicationBase
Public Enum MessageFormType
Message
Progress
End Enum
End Namespace