Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub FindGamerPictures(ByVal sender As System.Object, ByVal e As DoWorkEventArgs)
- Dim BackgroundWorker As BackgroundWorker = sender
- Dim GameID As UInt32 = &H41560855
- Dim MaxFails As Integer = 50
- For i As Integer = 0 To 3
- Dim Fails As Integer = 0
- Dim ImageID As Integer = 0
- Select Case i
- Case 0
- ImageID = &H20000
- Case 1
- ImageID = &H20400
- Case 2
- ImageID = &H21000
- Case 3
- ImageID = &H28000
- End Select
- Do
- Try
- Dim URL As String = "http://image.xboxlive.com/global/t." & GameID.ToString("x") & "/tile/0/" & ImageID.ToString("x")
- Dim WEBClient As New WebClient
- WEBClient.DownloadData(URL)'this errors = not a valid gamerpic
- BackgroundWorker.ReportProgress(0, New GamerPicture(GameID, ImageID))
- Catch ex As Exception
- Fails += 1
- End Try
- ImageID += 1
- Loop While Fails < MaxFails
- Next
- End Sub
- Public Sub UpdateGamerPictures(ByVal sender As System.Object, ByVal e As ProgressChangedEventArgs)
- Dim GamerPicture As GamerPicture = e.UserState
- GamerPictures.Add(GamerPicture)
- Dim LVI As New ListViewItem
- LVI.Text = GamerPicture.PNGURL64
- LVI.SubItems.Add(GamerPicture.PNGURL32)
- ListView2.Items.Add(LVI)
- End Sub
- Public Sub FoundGamerPictures(ByVal sender As System.Object, ByVal e As RunWorkerCompletedEventArgs)
- MsgBox("Found " & GamerPictures.Count & " Gamerpics")
- End Sub
- Private Sub FindPicsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindPicsToolStripMenuItem.Click
- Dim BackgroundWorker As New BackgroundWorker
- BackgroundWorker.WorkerReportsProgress = True
- BackgroundWorker.WorkerSupportsCancellation = False
- AddHandler BackgroundWorker.DoWork, New DoWorkEventHandler(AddressOf FindGamerPictures)
- AddHandler BackgroundWorker.ProgressChanged, New ProgressChangedEventHandler(AddressOf UpdateGamerPictures)
- AddHandler BackgroundWorker.RunWorkerCompleted, New RunWorkerCompletedEventHandler(AddressOf FoundGamerPictures)
- BackgroundWorker.RunWorkerAsync()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment