예제 #1
0
        private async void LoadCbRepresentations()
        {
            switch (ChampionshipType)
            {
            case ChampionshipType.Male:
                RepresentationRepo = new MaleRepresentation();
                break;

            case ChampionshipType.Female:
                RepresentationRepo = new FemaleRepresentation();
                break;
            }

            Cursor          = Cursors.Wait;
            Representations = (List <Representation>) await RepresentationRepo.GetAllTeams();

            Cursor = Cursors.Arrow;

            if (Representations != null)
            {
                Representations.Sort();

                foreach (var representation in Representations)
                {
                    cbRepresentations.Items.Add(representation);
                }

                if (File.Exists(Properties.Settings.Default.Representation_Filepath))
                {
                    var jsonRepresentation = File.ReadAllText(Properties.Settings.Default.Representation_Filepath);

                    if (!string.IsNullOrEmpty(jsonRepresentation))
                    {
                        RepresentationSaveFile saveFile = JsonConvert.DeserializeObject <RepresentationSaveFile>(jsonRepresentation);
                        if (saveFile.ChampionshipType == this.ChampionshipType)
                        {
                            FavoriteRepresentation         = saveFile.Representation;
                            cbRepresentations.SelectedItem = FavoriteRepresentation;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Unable to fetch representation data!");
            }
        }
예제 #2
0
        private void StatisticsForm_Load(object sender, EventArgs e)
        {
            if (File.Exists(Properties.Settings.Default.Representation_Filepath))
            {
                try
                {
                    string favoriteRepresentationJson = File.ReadAllText(Properties.Settings.Default.Representation_Filepath);

                    RepresentationSaveFile saveFile = JsonConvert.DeserializeObject <RepresentationSaveFile>(favoriteRepresentationJson);

                    if (saveFile.ChampionshipType == this.ChampionshipType)
                    {
                        favoriteRepresentation = saveFile.Representation;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            GetTeamDataAsync(ChampionshipType);
        }