private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { string nameSummoner = NavigationContext.QueryString["name"]; SummonerDto summoner = new SummonerDto(); try { summoner = await summoner.SearchSummoner(nameSummoner); textBlockNomeInv.Text = summoner.Nome; } catch { MessageBox.Show("Não existe um invocador com esse nome."); NavigationService.GoBack(); return; } textBlockLevel.Text += summoner.SummonerLevel.ToString(); try { LeagueDto leagueSummoner = new LeagueDto(); leagueSummoner = await leagueSummoner.SearchLeague(summoner.Id); textBlockElo.Text = leagueSummoner.Tier + " " + leagueSummoner.Entries[0].Division; textBlockVit.Text = leagueSummoner.Entries[0].Wins > 1 ? leagueSummoner.Entries[0].Wins.ToString() + " vitórias" : leagueSummoner.Entries[0].Wins.ToString() + " vitória"; textBlockDer.Text = leagueSummoner.Entries[0].Losses > 1 ? leagueSummoner.Entries[0].Losses.ToString() + " derrotas" : leagueSummoner.Entries[0].Losses.ToString() + " derrota"; } catch { MessageBox.Show("Informações de derrotas e vitórias são apenas para jogadores ranqueados.", "Informação", MessageBoxButton.OK); textBlockElo.Text = "Unranked"; textBlockVit.Text = "0 vitória"; textBlockDer.Text = "0 derrota"; } imageInvocador.Source = await summoner.GetProfileIcon(); RecentGamesDto gamesRecent = await new RecentGamesDto().GetLatestGamesById(summoner.Id); List <int> lastChampionsPlayed = new List <int>(); foreach (GameDto game in gamesRecent.Games) { lastChampionsPlayed.Add(game.ChampionId); LastMatches controlMatch = new LastMatches(game); controlMatch.Margin = new Thickness(0, 0, 0, 10); controlMatch.Load(); listboxPartidas.Items.Add(controlMatch); } int idChampPref = lastChampionsPlayed[new Random().Next(lastChampionsPlayed.Count - 1)]; ImageBrush imgBrush = new ImageBrush(); BitmapImage source = (await ChampionDto.SearchChampionAllData(idChampPref)).GetChampionSplash(0); imgBrush.ImageSource = source; imgBrush.Stretch = Stretch.UniformToFill; LayoutRoot.Background = imgBrush; }
private async void buttonCadastro_Click(object sender, RoutedEventArgs e) { if (nomeInvocador.Text == string.Empty) { MessageBox.Show("Digite o nome do invocador antes de se cadastrar."); } else { summoner = new SummonerDto(); try { summoner = await summoner.SearchSummoner(nomeInvocador.Text); ls = new LeagueWS.LeagueServiceClient(); ls.encontrarUsuarioCompleted += Ls_encontrarUsuarioCompleted; ls.encontrarUsuarioAsync(nomeInvocador.Text); } catch (Exception) { MessageBox.Show("Erro ao procurar invocador."); } } }