|
Imports System.Drawing.Design
Imports System.Windows.Forms.Design
Public Class LEDEditor
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New(ByVal current As String)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
Me.Value = current
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
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.
Friend WithEvents txtH1 As System.Windows.Forms.TextBox
Friend WithEvents txtH2 As System.Windows.Forms.TextBox
Friend WithEvents txtM1 As System.Windows.Forms.TextBox
Friend WithEvents txtM2 As System.Windows.Forms.TextBox
Friend WithEvents txtS1 As System.Windows.Forms.TextBox
Friend WithEvents txtS2 As System.Windows.Forms.TextBox
Friend WithEvents btnOK As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents LedClock1 As WinControls.LEDClock
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.txtH1 = New System.Windows.Forms.TextBox()
Me.txtH2 = New System.Windows.Forms.TextBox()
Me.txtM1 = New System.Windows.Forms.TextBox()
Me.txtM2 = New System.Windows.Forms.TextBox()
Me.txtS1 = New System.Windows.Forms.TextBox()
Me.txtS2 = New System.Windows.Forms.TextBox()
Me.btnOK = New System.Windows.Forms.Button()
Me.btnCancel = New System.Windows.Forms.Button()
Me.LedClock1 = New WinControls.LEDClock()
Me.SuspendLayout()
'
'txtH1
'
Me.txtH1.Location = New System.Drawing.Point(16, 40)
Me.txtH1.MaxLength = 1
Me.txtH1.Name = "txtH1"
Me.txtH1.Size = New System.Drawing.Size(32, 20)
Me.txtH1.TabIndex = 1
Me.txtH1.Text = ""
Me.txtH1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtH2
'
Me.txtH2.Location = New System.Drawing.Point(48, 40)
Me.txtH2.MaxLength = 1
Me.txtH2.Name = "txtH2"
Me.txtH2.Size = New System.Drawing.Size(32, 20)
Me.txtH2.TabIndex = 1
Me.txtH2.Text = ""
Me.txtH2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtM1
'
Me.txtM1.Location = New System.Drawing.Point(112, 40)
Me.txtM1.MaxLength = 1
Me.txtM1.Name = "txtM1"
Me.txtM1.Size = New System.Drawing.Size(32, 20)
Me.txtM1.TabIndex = 1
Me.txtM1.Text = ""
Me.txtM1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtM2
'
Me.txtM2.Location = New System.Drawing.Point(144, 40)
Me.txtM2.MaxLength = 1
Me.txtM2.Name = "txtM2"
Me.txtM2.Size = New System.Drawing.Size(32, 20)
Me.txtM2.TabIndex = 1
Me.txtM2.Text = ""
Me.txtM2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtS1
'
Me.txtS1.Location = New System.Drawing.Point(208, 40)
Me.txtS1.MaxLength = 1
Me.txtS1.Name = "txtS1"
Me.txtS1.Size = New System.Drawing.Size(32, 20)
Me.txtS1.TabIndex = 1
Me.txtS1.Text = ""
Me.txtS1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtS2
'
Me.txtS2.Location = New System.Drawing.Point(240, 40)
Me.txtS2.MaxLength = 1
Me.txtS2.Name = "txtS2"
Me.txtS2.Size = New System.Drawing.Size(32, 20)
Me.txtS2.TabIndex = 1
Me.txtS2.Text = ""
Me.txtS2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'btnOK
'
Me.btnOK.Location = New System.Drawing.Point(56, 72)
Me.btnOK.Name = "btnOK"
Me.btnOK.TabIndex = 2
Me.btnOK.Text = "OK"
'
'btnCancel
'
Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnCancel.Location = New System.Drawing.Point(160, 72)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.TabIndex = 2
Me.btnCancel.Text = "Cancel"
'
'LedClock1
'
Me.LedClock1.Location = New System.Drawing.Point(16, 0)
Me.LedClock1.Name = "LedClock1"
Me.LedClock1.Size = New System.Drawing.Size(256, 32)
Me.LedClock1.TabIndex = 3
Me.LedClock1.Time = "00:00:00"
'
'LEDEditor
'
Me.AcceptButton = Me.btnOK
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.btnCancel
Me.ClientSize = New System.Drawing.Size(290, 103)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.LedClock1, Me.btnOK, Me.txtH1, Me.txtH2, Me.txtM1, Me.txtM2, Me.txtS1, Me.txtS2, Me.btnCancel})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "LEDEditor"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "LEDEditor"
Me.ResumeLayout(False)
End Sub
#End Region
Private mValue As String
Public Property Value() As String
Get
Return mValue
End Get
Set(ByVal Value As String)
mValue = Value
End Set
End Property
Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click
mValue = Me.txtH1.Text & Me.txtH2.Text & ":" & Me.txtM1.Text & Me.txtM2.Text & ":" & Me.txtS1.Text & Me.txtS2.Text
Me.Close()
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Me.LedClock1.Time = mValue
Me.txtH1.Text = mValue.Substring(0, 1)
Me.txtH2.Text = mValue.Substring(1, 1)
Me.txtM1.Text = mValue.Substring(3, 1)
Me.txtM2.Text = mValue.Substring(4, 1)
Me.txtS1.Text = mValue.Substring(6, 1)
Me.txtS2.Text = mValue.Substring(7, 1)
Me.LedClock1.Stop()
End Sub
Private Sub txt_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtH1.Validating, txtH2.Validating, txtM1.Validating, txtM2.Validating, txtS1.Validating, txtS2.Validating
If IsNumeric(Me.txtH1.Text) = False Or IsNumeric(Me.txtH2.Text) = False Or _
IsNumeric(Me.txtM1.Text) = False Or IsNumeric(Me.txtM2.Text) = False Or _
IsNumeric(Me.txtS1.Text) = False Or IsNumeric(Me.txtS2.Text) = False Then
MsgBox("Value must be numeric.", MsgBoxStyle.Exclamation)
e.Cancel = True
Exit Sub
End If
If CInt(Me.txtH1.Text & Me.txtH2.Text) > 23 Then
MsgBox("HOURS: Value must be less then 24.", MsgBoxStyle.Exclamation)
e.Cancel = True
End If
If CInt(Me.txtM1.Text & Me.txtM2.Text) > 59 Then
MsgBox("MINUTES: Value must be less then 59.", MsgBoxStyle.Exclamation)
e.Cancel = True
End If
If CInt(Me.txtS1.Text & Me.txtS2.Text) > 59 Then
MsgBox("SECONDS: Value must be less then 59.", MsgBoxStyle.Exclamation)
e.Cancel = True
End If
End Sub
End Class
Public Class LEDTypeEditor
Inherits UITypeEditor
Public Overloads Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
Dim edSvc As IWindowsFormsEditorService
Try
edSvc = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
Dim edForm As LEDEditor
edForm = New LEDEditor(CStr(value))
edSvc.ShowDialog(edForm)
If edForm.DialogResult = DialogResult.OK Then
edForm.Value = edForm.txtH1.Text & edForm.txtH2.Text & ":" & edForm.txtM1.Text & edForm.txtM2.Text & ":" & edForm.txtS1.Text & edForm.txtS2.Text
End If
Return edForm.Value
Catch e As Exception
MsgBox(e.ToString)
End Try
End Function
Public Overloads Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
Return UITypeEditorEditStyle.Modal
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.