Option Strict On
Option Explicit On
Public Class Form1
Dim WeeklyBasis As New Specialized.StringCollection
Dim DailyBasis As New Specialized.StringCollection
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.NotifyIcon1.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReadSettings()
Timer1.Start()
With Me.NotifyIcon1
.Icon = Me.Icon
.Visible = True
End With
End Sub
Private Sub ReadSettings()
Dim MyXml As New Xml.XmlDocument
Dim XmlNode As Xml.XmlNode
Dim Weekly As Xml.XmlNode
Dim Daily As Xml.XmlNode
MyXml.Load(Application.StartupPath & "\settings.xml")
For Each Node As Xml.XmlNode In MyXml.ChildNodes
If Node.Name = "xml" Then
XmlNode = Node
Exit For
End If
Next
For Each tnode As Xml.XmlNode In XmlNode.ChildNodes
Select Case tnode.Attributes("name").Value
Case "DailyBasis"
Daily = tnode
Case "WeeklyBasis"
Weekly = tnode
End Select
Next
For Each Node As Xml.XmlNode In Daily.ChildNodes
DailyBasis.Add(Node.Attributes("name").Value & "|" & (Node.Attributes("time").Value) & "|" & Node.Attributes("date").Value)
Next
For Each node As Xml.XmlNode In Weekly.ChildNodes
WeeklyBasis.Add(node.Attributes("name").Value & "|" & (node.Attributes("time").Value) & "|" & node.Attributes("date").Value)
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i As Int32 = 0 To WeeklyBasis.Count - 1
Dim Values() As String = WeeklyBasis(i).Split("|"c)
If Values(2) = Date.Now.DayOfWeek.ToString AndAlso Values(1).Substring(0, Values(1).IndexOf(":")).ToString = Math.Abs(Convert.ToInt32(Date.Now.TimeOfDay.Hours) - 12).ToString Then
NotifyIcon1.ShowBalloonTip(100, "Reminder!", Values(0), ToolTipIcon.Info)
End If
Next
For i As Int32 = 0 To DailyBasis.Count - 1
Dim Values() As String = DailyBasis(i).Split("|"c)
If Values(2) = Date.Now.ToShortDateString AndAlso Values(1).Substring(0, Values(1).IndexOf(":")).ToString = Math.Abs(Convert.ToInt32(Date.Now.TimeOfDay.Hours) - 12).ToString Then
NotifyIcon1.ShowBalloonTip(100, "Reminder!", Values(0), ToolTipIcon.Info)
End If
Next
End Sub
End Class