I create the picture box into an object and a container holds all the objects. So, I call the returnIcon method which uses generateIcon if necessary. I have a method in the container to search for the correct object and then returns the icon for that object. A form creates the container. It is there I call for icons and then send them to a user control where it is to be displayed. My problem is that the picture box only displays the last time it is called. I know each object is being found correctly. In the user control, I used picturebox.name and each one was correct. The value is being sent, but the image is not displaying. Why will only the last picture box call display?
base object is the basic LeagueObject where it contains the picturebox that is created when needed (depends on the boolean iamset).
the container is basically only a list of the LeagueObjects (it is set up this way for JSON deserialization).
The picture box travels: League(base)object >> container >> form >> userControl that is loaded into the form (there are ten user controls added to the form) The only picture boxes that show are the last user controls that need the pictureBox.
- base object
Protected Sub generateIcon()
If Not iamset Then
img.Width = 45
img.Height = 45
img.SizeMode = PictureBoxSizeMode.Zoom
img.BorderStyle = BorderStyle.None
Try
img.Image = System.Drawing.Image.FromFile(Path.Combine(Path.GetTempPath(), "lolIcons", type, image.full))
Catch ex As Exception
End Try
img.BackColor = Color.White
setIcon()
AddHandler img.Click, AddressOf onIconClick
iamset = True
End If
End Sub
Public Function returnIcon() As PictureBox
generateIcon()
Return img
End Function
- base object collection
Public Function returnImageById(ByVal strID As String) As PictureBox
For Each champ In league_container.data
If champ.Value.id.ToString = strID Then
Console.WriteLine("found " + champ.Value.name)
Return champ.Value.returnIcon()
End If
Next
Console.WriteLine("Failed to find " + strID)
Return New PictureBox
End Function
- form
Public Sub loadUC(ByVal player As LeagueCurrentGameParticipant, ByVal kills As Double, ByVal deaths As Double, ByVal assists As Double, ByVal largestKillingSpree As Double, ByVal largestMultiKill As Double, ByVal killingSprees As Double, ByVal doubleKills As Double, ByVal tripleKills As Double, ByVal quadraKills As Double, ByVal pentaKills As Double, ByVal unRealKills As Double)
Dim uc As New ucMatchSummoner
uc.loadUC(player, rgocm.returnImageById(player.championId.ToString), rgossm.returnImageById(player.spell1Id.ToString()), rgossm.returnImageById(player.spell2Id.ToString()), kills, deaths, assists, largestKillingSpree, largestMultiKill, killingSprees, doubleKills, tripleKills, quadraKills, pentaKills, unRealKills)
tblpMain.Controls.Add(uc)
End Sub
- user control (This one is actually longer but I truncated it since it served no purpose. I was sending it ByVal but attempted ByRef in case anything changed, which it did not.
Public Sub loadUC(ByRef lcgp As LeagueCurrentGameParticipant, ByVal champImage As PictureBox, ByRef spell1 As PictureBox, ByRef spell2 As PictureBox, ByVal kills As Double, ByVal deaths As Double, ByVal assists As Double, ByVal largestKillingSpree As Double, ByVal largestMultiKill As Double, ByVal killingSprees As Double, ByVal doubleKills As Double, ByVal tripleKills As Double, ByVal quadraKills As Double, ByVal pentaKills As Double, ByVal unRealKills As Double)
lp = lcgp
loadPlayerCurrentGameInformation()
pnlChampIcon.Controls.Add(champImage)
flpSpells.Controls.Add(spell1)
flpSpells.Controls.Add(spell2)
End class