Imports System.Xml
''' <summary>
''' Digg Notify
''' This program sends a quick pop up when someone has dugg one of your stories. When it hits FP it will stop monitoring.
''' </summary>
'''
Public Class frmMain
Private rand As New Random
Public objXMLDoc As New XmlDocument
Dim objNode As System.Xml.XmlNode
Dim strPath = Application.StartupPath & "\Config.ini"
Dim arrDiggCount(100) As String
Dim strSliceMsg As String = ""
Dim i As Integer = 0
Dim j As Integer = 0
Dim strCheckHmpg(100) As String
Dim bolCheck As Boolean = False
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtUser.Text = INIRead(strPath, "Config", "User", "Username")
numStories.Text = INIRead(strPath, "Config", "NumStories", "15")
numMinDiggs.Text = INIRead(strPath, "Config", "MinDiggs", "0")
End Sub
Private Sub tmrUpdate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrUpdate.Tick
'Dim Thread As New System.Threading.Thread(AddressOf DiggUpdate)
'Thread.IsBackground = True
'Thread.Priority = Threading.ThreadPriority.Normal
'Thread.Start()
DiggUpdate()
End Sub
Private Delegate Sub DiggUpdateDelegate()
Public Sub DiggUpdate()
Try
i = 0
objXMLDoc.Load("http://digg.com/rss/" & txtUser.Text & "/index1.xml")
For Each elemOut As Xml.XmlElement In objXMLDoc.GetElementsByTagName("item")
For Each elemIn As Xml.XmlElement In elemOut.GetElementsByTagName("digg:diggCount")
arrDiggCount(i) = elemIn.ChildNodes(0).InnerText
i = i + 1
Next elemIn
Next elemOut
i = 0
lstStories.Items.Clear()
For Each objNode In objXMLDoc.SelectNodes("rss/channel/item")
If i < numStories.Text Then
If INIRead(strPath, txtUser.Text, objNode.SelectSingleNode("title").InnerText, "") = "" Then
INIWrite(strPath, txtUser.Text, objNode.SelectSingleNode("title").InnerText, arrDiggCount(i))
End If
If arrDiggCount(i) > 30 And INIRead(strPath, "Ignored", objNode.SelectSingleNode("title").InnerText, "0") <> 1 Then
strCheckHmpg(i) = objNode.SelectSingleNode("title").InnerText
bolCheck = True
End If
If INIRead(strPath, txtUser.Text, objNode.SelectSingleNode("title").InnerText, "") <> arrDiggCount(i) And INIRead(strPath, "Ignored", objNode.SelectSingleNode("title").InnerText, "0") <> 1 And INIRead(strPath, "Config", "MinDiggs", "0") <= arrDiggCount(i) Then
Dim strTitle As String = objNode.SelectSingleNode("title").InnerText
If strTitle.Length > 40 Then
strTitle = strTitle.Substring(0, 40) & "..."
End If
INIWrite(strPath, txtUser.Text, objNode.SelectSingleNode("title").InnerText, arrDiggCount(i))
strSliceMsg = strSliceMsg & strTitle & "(" & arrDiggCount(i) & ")" & vbCrLf
End If
If INIRead(strPath, "Ignored", objNode.SelectSingleNode("title").InnerText, "0") = 1 Then
lstStories.Items.Add("(" & arrDiggCount(i) & ") " & objNode.SelectSingleNode("title").InnerText & " [Ignored]")
Else
lstStories.Items.Add("(" & arrDiggCount(i) & ") " & objNode.SelectSingleNode("title").InnerText)
End If
Else
Exit For
End If
i = i + 1
Next
If strSliceMsg <> "" Then
Dim slice As New frmToast(Me.rand.Next(5000, 10000), strSliceMsg)
slice.Height = Me.rand.Next(150, 150)
slice.Show()
strSliceMsg = ""
End If
i = 0
If bolCheck = True Then
objXMLDoc.Load("http://digg.com/rss/containertechnology.xml")
For Each objNode In objXMLDoc.SelectNodes("rss/channel/item")
Do Until i > numStories.Text
If objNode.SelectSingleNode("title").InnerText = strCheckHmpg(i) Then
INIWrite(strPath, "Ignored", strCheckHmpg(i), "1")
Dim slice As New frmToast(Me.rand.Next(5000, 10000), objNode.SelectSingleNode("title").InnerText & " Hit FP!")
slice.Height = Me.rand.Next(150, 150)
slice.Show()
strCheckHmpg(i) = ""
End If
i = i + 1
Loop
i = 0
Next
bolCheck = False
End If
i = 0
Catch ex As Exception
End Try
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
If tmrUpdate.Enabled = True Then
tmrUpdate.Enabled = False
btnStart.Text = "Start"
Else
tmrUpdate.Enabled = True
btnStart.Text = "Pause"
End If
If INIRead(strPath, "Config", "User", "") <> txtUser.Text Then
INIWrite(strPath, "Config", "User", txtUser.Text)
End If
End Sub
Private Sub btnIgnore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIgnore.Click
INIWrite(strPath, "Ignored", lstStories.SelectedItem, "1")
End Sub
Private Sub btnUnignore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUnignore.Click
INIWrite(strPath, "Ignored", lstStories.SelectedItem, "0")
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
INIRead(strPath, "Config", "NumStories", numStories.Text)
INIWrite(strPath, "Config", "MinDiggs", numMinDiggs.Text)
End Sub
End Class