Example #1
0
        private async void CbOpponents_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            spOpponentRepresentation.Children.Clear();


            if (cbOpponents.SelectedItem is Team selectedRep)
            {
                List <Player> players = await RepresentationRepo.GetPlayers(selectedRep.Code);

                foreach (var player in players)
                {
                    spOpponentRepresentation.Children.Add(new PlayerUC(player));
                }
            }
        }
Example #2
0
        private async void InitializeOpponentComponents()
        {
            MatchesPlayed = await RepresentationRepo.GetMatchesForCountry(FavoriteRepresentation);

            foreach (var match in MatchesPlayed)
            {
                if (match.HomeTeam.Code == FavoriteRepresentation.FifaCode)
                {
                    cbOpponents.Items.Add(match.AwayTeam);
                }
                else
                {
                    cbOpponents.Items.Add(match.HomeTeam);
                }
            }
        }
        private async void OnRepresentationSelected(object sender, EventArgs e)
        {
            flpPlayers.Controls.Clear();

            var cbox = sender as ComboBox;

            //favoriteRep instead of chosen
            favoriteRepresentation = cbox.SelectedItem as Representation;

            Utilities.SaveDataToFile(new RepresentationSaveFile(favoriteRepresentation, ChampionshipType), Properties.Settings.Default.Representation_Filepath);

            PlayersData = await RepresentationRepo.GetPlayers(favoriteRepresentation.FifaCode);

            PlayersData.Sort();

            FillFLPPlayers();
        }
Example #4
0
        private async void BtnRepresentationInfo_Click(object sender, RoutedEventArgs e)
        {
            var chosenRep = (sender as Button).Tag.ToString();

            if (chosenRep != null && chosenRep == "favoriteRepresentation")
            {
                new RepresentationInfoWindow(MatchesPlayed, FavoriteRepresentation).ShowDialog();
            }
            else
            {
                if (cbOpponents.SelectedItem is Team opponent)
                {
                    List <Match> opponentMatches = await RepresentationRepo.GetMatchesForCountry(new Representation { Country = opponent.Country, FifaCode = opponent.Code });

                    new RepresentationInfoWindow(opponentMatches, opponent).ShowDialog();
                }
            }
        }
Example #5
0
        private async void CbRepresentations_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            spFavoriteRepresentation.Children.Clear();
            spOpponentRepresentation.Children.Clear();
            cbOpponents.Items.Clear();

            Players.Clear();

            FavoriteRepresentation = cbRepresentations.SelectedItem as Representation;

            if (File.Exists(Properties.Settings.Default.Players_Filepath))
            {
                var jsonSaveFile = File.ReadAllText(Properties.Settings.Default.Players_Filepath);
                if (!string.IsNullOrEmpty(jsonSaveFile))
                {
                    PlayersSaveFile playersSaveFile = JsonConvert.DeserializeObject <PlayersSaveFile>(jsonSaveFile);
                    if (playersSaveFile.ChampionshipType == this.ChampionshipType && playersSaveFile.Representation.FifaCode == FavoriteRepresentation.FifaCode)
                    {
                        Players = playersSaveFile.Players;
                        FillStackPanelWithPlayers(spFavoriteRepresentation, Players);
                        InitializeOpponentComponents();
                        return;
                    }
                }
            }

            List <Player> players = await RepresentationRepo.GetPlayers(FavoriteRepresentation.FifaCode);

            players.Sort();

            foreach (var player in players)
            {
                Players.Add(new PlayerVM {
                    Player = player
                });
            }

            Utilities.SaveDataToFile(new RepresentationSaveFile(FavoriteRepresentation, ChampionshipType), Properties.Settings.Default.Representation_Filepath);;
            Utilities.SavePlayersToFile(Players, ChampionshipType, FavoriteRepresentation, Properties.Settings.Default.Players_Filepath);

            FillStackPanelWithPlayers(spFavoriteRepresentation, Players);

            InitializeOpponentComponents();
        }
        private async void BtnStatistics_Click(object sender, EventArgs e)
        {
            List <Match> matches = await RepresentationRepo.GetMatchesForCountry(favoriteRepresentation);

            new StatisticsForm(matches, Players, favoriteRepresentation).Show();
        }