I am making a league of legends simulator. The app simulates a 5V5 or a 3V3 match where randomly Champions will load into 2 teams. To fill the image of a champion (comparable with a loadingscreen) I have a method called 'Genereer5v5Button_Click'. This method is called when a user clicks on a button, this will fill 2 List of 5 random Champions.
Now when I click the button nothing happens , the images are not showing and no error is thrown. Can somebody look at my code, there is probably something wrong with the path I am passing because when I am debugging the path is filled in (Maybe something with Relative/Absolute).
private void Genereer5v5Button_Click(object sender, RoutedEventArgs e)
{
if (!String.IsNullOrEmpty(PasswordBoxMatchCode.Password))
{
if (MatchData.IsUniqueCode(PasswordBoxMatchCode.Password).Equals(true))
{
currentMatch = new SummonersRift(PasswordBoxMatchCode.Password);
currentMatch.GenereerTeams();
ImageIconChampion1Team1.Source = ReturnSourceTeam1()[0];
ImageIconChampion2Team1.Source = ReturnSourceTeam1()[1];
ImageIconChampion3Team1.Source = ReturnSourceTeam1()[2];
ImageIconChampion4Team1.Source = ReturnSourceTeam1()[3];
ImageIconChampion5Team1.Source = ReturnSourceTeam1()[4];
ImageIconChampion1Team2.Source = ReturnSourceTeam2()[0];
ImageIconChampion2Team2.Source = ReturnSourceTeam2()[1];
ImageIconChampion3Team2.Source = ReturnSourceTeam2()[2];
ImageIconChampion4Team2.Source = ReturnSourceTeam2()[3];
ImageIconChampion5Team2.Source = ReturnSourceTeam2()[4];
}
else
{
MessageBox.Show("Deze code is reeds gebruikt. Kies een andere.");
}
}
else
{
MessageBox.Show("Geef een code mee", "Geen code");
}
}
private List<ImageSource> ReturnSourceTeam1()
{
List<ImageSource> sources = new List<ImageSource>();
foreach (var champ in currentMatch.Team1Champions)
{
Uri uri = new Uri($"images/{champ.IconSource}", UriKind.Relative);
ImageSource imgSource = new BitmapImage(uri);
sources.Add(imgSource);
}
return sources;
}