Imports Ihabbox.Ihabbox.Tool.Habbos Imports DevComponents.DotNetBar Public Class frmHabboInfo 'images container,direction of the habbo's image C:\Users\Mikleman\Documents\Visual Studio 2010\Projects\Habbo.Net\Habbo.Net\Resources\(8 is a not possible value,it's used to know there are not images) Private Images As New List(Of Image), Direction As Byte = 8 'adding the avatar in a thread safe way Private Delegate Sub ThreadSafePic(ByVal Avatar As Image, ByVal [Exception] As Boolean) 'multithreaded operation Friend AsyncGetAvatar As Threading.Thread Friend Sub ThreadGetAvatar(ByVal HotelDomain As Object) Try Images.Clear() 'deleting stored images For i As Byte = 0 To CByte(7) 'download all the 8 images Dim Request As Net.WebRequest = Net.WebRequest.Create("http://habbo" & HotelDomain.ToString & "/habbo-imaging/avatarimage?user=" _ & txtUsername.Text & "&direction=" & i _ & "&head_direction=" & i & "&size=l") Images.Add(Image.FromStream(Request.GetResponse.GetResponseStream)) 'save the current image Next pbAvatar.Invoke(New ThreadSafePic(AddressOf ThreadSafePicture), {Images.Item(4), False}) 'set the default image Catch ex As Exception Try pbAvatar.Invoke(New ThreadSafePic(AddressOf ThreadSafePicture), {pbAvatar.ErrorImage, True}) 'set the error image Catch 'if an exception occurs here just ignore it End Try End Try End Sub Private Sub ThreadSafePicture(ByVal Avatar As Image, ByVal [Exception] As Boolean) Try pbAvatar.Visible = False 'the user must not see the image movement 'check if an exception has occurred or not and set the graphical stuff pbAvatar.Size = New Size(67, 110) If [Exception] Then pbAvatar.Location = New Point(225, 63) Else Direction = 4 pbAvatar.Location = New Point(225, 33) pbLeft.Visible = True pbRight.Visible = True End If btnRefresh.Text = "Refresh" frmbrowser.btnGetInfo.Enabled = True pbAvatar.Image = Avatar pbAvatar.Visible = True Catch ex As Exception MessageBoxEx.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub Arrows_Click(ByVal sender As Object, ByVal e As EventArgs) Handles pbLeft.Click, pbRight.Click, pbLeft.DoubleClick, pbRight.DoubleClick Try 'check which picturebox has been clicked,then set the Direction value If Direction <> 8 Then Direction = CByte(IIf(sender Is pbLeft, IIf(Direction = 7, 0, Direction + 1), IIf(Direction = 0, 7, Direction - 1))) pbAvatar.Image = Images.Item(Direction) 'set the requested image Catch ex As Exception MessageboxEx.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Try If btnRefresh.Text = "Refresh" Then Dim Habbo As Habbo = frmbrowser.HabboList.Find(txtUsername.Text) 'refresh this form If Habbo Is Nothing Then Throw New Exception("User's data not found." & Environment.NewLine & "Make sure the user is still there or try reloading the room.") Else frmbrowser.SetHabboInfo(Habbo.Username, Habbo.Sex, Habbo.Motto, Habbo.ID.ToString, Habbo.Figure, Habbo.RoomID) btnRefresh.Text = "Abort" Direction = 8 'resetting Direction to default value End If Else frmbrowser.btnGetInfo.Enabled = True 'the button must be clickable If AsyncGetAvatar IsNot Nothing Then AsyncGetAvatar.Abort() 'end the thread Close() 'close this form End If Catch ex As Exception MessageBoxEx.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub frmHabboInfo_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If Not frmbrowser.btnGetInfo.Enabled Then frmbrowser.btnGetInfo.Enabled = True End Sub Private Sub frmHabboInfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MessageBoxEx.MessageBoxTextColor = Color.White MessageBoxEx.EnableGlass = False If CBool(My.Settings.LogFormat64) = False Then Me.TitleText = "Ihabbox - Habbo Info (Trial Version)" End If frmbrowser.wbClient.Focus() End Sub Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click Try If btnRefresh.Text = "Refresh" Then Dim Habbo As Habbo = frmbrowser.HabboList.Find(txtUsername.Text) 'refresh this form If Habbo Is Nothing Then Throw New Exception("User's data not found." & Environment.NewLine & "Make sure the user is still there or try reloading the room.") Else frmbrowser.SetHabboInfo(Habbo.Username, Habbo.Sex, Habbo.Motto, Habbo.ID.ToString, Habbo.Figure, Habbo.RoomID) btnRefresh.Text = "Abort" Direction = 8 'resetting Direction to default value End If Else frmbrowser.btnGetInfo.Enabled = True 'the button must be clickable If AsyncGetAvatar IsNot Nothing Then AsyncGetAvatar.Abort() 'end the thread Close() 'close this form End If Catch ex As Exception MessageBoxEx.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class