Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private Property pageready As Boolean = False
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- If Button1.Text = "Start" Then
- Timer1.Start()
- Button1.Text = "Stop"
- loadChData()
- Button3.Enabled = False
- Else
- Timer1.Stop()
- Button1.Text = "Start"
- Button3.Enabled = True
- End If
- End Sub
- Private Sub WaitForPageLoad()
- AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
- While Not pageready
- Application.DoEvents()
- End While
- pageready = False
- End Sub
- Private Sub PageWaiter(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
- If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
- pageready = True
- RemoveHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
- End If
- End Sub
- Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
- loadChData()
- End Sub
- Private Sub loadChData()
- WebBrowser1.Navigate("http://www.southperry.net/stat.php")
- WaitForPageLoad()
- RichTextBox1.ResetText()
- Dim position As Integer = 0
- Dim channel As Integer = 1
- position = WebBrowser1.DocumentText.IndexOf("Bera", position)
- While channel <> 21
- position = WebBrowser1.DocumentText.IndexOf("Current Latency", position)
- Dim endPosition As Integer = WebBrowser1.DocumentText.IndexOf("</tr>", position)
- If endPosition <> -1 Then
- Dim chan As String = channel.ToString
- If channel < 10 Then
- chan = "0" + channel.ToString
- End If
- RichTextBox1.Text += "Channel " + chan + " " + WebBrowser1.DocumentText.Substring(position + 24, 4) + vbNewLine
- channel += 1
- End If
- position = endPosition
- End While
- End Sub
- Private Sub loadLoginData()
- WebBrowser1.Navigate("http://www.southperry.net/stat.php")
- WaitForPageLoad()
- Dim ok As Integer = 0
- For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("img")
- If element.GetAttribute("alt") = "OK" Then
- ok += 1
- End If
- Next
- If ok > 3 Then
- Timer2.Stop()
- MsgBox("Server is back up!")
- Button3.Text = "Status"
- Button1.Enabled = True
- End If
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- loadChData()
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- If Button3.Text = "Status" Then
- Timer2.Start()
- Button1.Enabled = False
- Button3.Text = "Off"
- loadLoginData()
- Else
- Button3.Text = "Status"
- Button1.Enabled = True
- End If
- End Sub
- Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
- loadLoginData()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement