|
Public Class Dialog1
Private StartUpTime As TimeSpan
Public Overloads Shared Sub ShowDialog(ByVal StartupTime As TimeSpan)
Using D As New Dialog1
D.StartUpTime = StartupTime
D.Timer1_Tick(Nothing, EventArgs.Empty)
D.ShowDialog()
End Using
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Me.Label1.Text = String.Format("Seit Programmstart vergingen: {0:HH:mm:ss}", Now - StartUpTime)
End Sub
End Class
Imports System.Windows.Forms
Public Module modMain
Private WithEvents _Notifyer As New NotifyIcon()
Private WithEvents mnuHelloWorld As New MenuItem("Hello World!")
Private WithEvents mnuBeenden As New MenuItem("Beenden")
Private StartUpTime As TimeSpan
Public Sub Main()
With _Notifyer
.Icon = My.Resources.FACE02
.Text = "Ein Icon im Systemtray, mit KontextMenü"
.ContextMenu = New ContextMenu(New MenuItem() {mnuHelloWorld, mnuBeenden})
.Visible = True
End With
StartUpTime = Now - Date.MinValue
Application.Run()
End Sub
Private Sub Menu_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles mnuHelloWorld.Click, mnuBeenden.Click
Select Case True
Case sender Is mnuHelloWorld
MessageBox.Show("Hello World!")
Case sender Is mnuBeenden
For Each D As IDisposable In New IDisposable() { _
_Notifyer.ContextMenu, _Notifyer, mnuHelloWorld, mnuBeenden}
D.Dispose()
Next
Application.Exit()
End Select
End Sub
Private Sub _Notifyer_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) _
Handles _Notifyer.DoubleClick
Dialog1.ShowDialog(StartUpTime)
End Sub
End Module |