Ejemplo n.º 1
0
        async void HandleFlag(CountryFlags newValue)
        {
            var countryName = newValue.ToString();
            var path        = ResourcePath + countryName + ".png";

            await TrySetFlagSource(path).ConfigureAwait(false);
        }
        //// =====================================================================================

        /// <summary>
        /// Initialise une nouvelle instance de la classe <see cref="WhoisControl" />.
        /// </summary>
        public WhoisControl()
        {
            this.worker = new BackgroundWorker();

            // Initialisation de l'interface graphique
            this.InitializeComponent();

            // Gestionnaires d'événements
            this.worker.DoWork             += (sender, e) => e.Result = WhoisClient.GetHostInfo(e.Argument.ToString());
            this.worker.RunWorkerCompleted += this.OnWorkCompleted;

            // Laison des données
            var defaultIcon = StockIcons.Internet.SmallBitmapImage;

            this.InputComboBox.Items.Add(CreateComboBoxItem(".com", defaultIcon));
            this.InputComboBox.Items.Add(CreateComboBoxItem(".net", defaultIcon));
            this.InputComboBox.Items.Add(CreateComboBoxItem(".org", defaultIcon));
            this.InputComboBox.Items.Add(new Separator {
                Tag = string.Empty
            });

            foreach (var item in WhoisClient.KnownServers.Keys)
            {
                var icon = CountryFlags.GetCountryFlag(item);
                this.InputComboBox.Items.Add(CreateComboBoxItem('.' + item, icon != null ? icon.SmallBitmapImage : defaultIcon));
            }

            // On force le rafraîchissement du rendu de la liste déroulante
            Action emptyDelegate = delegate {};

            this.InputComboBox.Dispatcher.Invoke(emptyDelegate, DispatcherPriority.Render);
        }
 public void LoadForm()
 {
     _countries    = _db.GetCountries();
     _dgvCountries = new List <DGVCountry>(_countries.Count);
     foreach (DBCountry country in _countries)
     {
         _dgvCountries.Add(new DGVCountry(country,
                                          CountryFlags.GetFlagImage(country.CountryName)));
     }
     _form.FillDGV(_dgvCountries);
 }
Ejemplo n.º 4
0
        private void CalculateAndSortPlayersScores()
        {
            _playersRankings = new List <PlayerRanking>(_players.Count);
            foreach (DBPlayer player in _players)
            {
                string teamName = string.Empty;
                if (_tournament.IsTeams)
                {
                    teamName = _teams.Find(x => x.TeamId == player.PlayerTeamId).TeamName;
                }
                string        countryImageUrl = _db.GetCountryImageUrl(player.PlayerCountryName);
                PlayerRanking playerRanking   = new PlayerRanking(player.PlayerId, player.PlayerName,
                                                                  player.PlayerTeamId, teamName, player.PlayerCountryName, countryImageUrl,
                                                                  CountryFlags.GetFlagImage(player.PlayerCountryName));

                List <DBTable> playerTables = _tables.FindAll(x =>
                                                              player.PlayerId == x.Player1Id || player.PlayerId == x.Player2Id ||
                                                              player.PlayerId == x.Player3Id || player.PlayerId == x.Player4Id);

                foreach (DBTable table in playerTables)
                {
                    if (player.PlayerId.ToString().Equals(table.PlayerEastId))
                    {
                        playerRanking.PlayerPoints += table.PlayerEastPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerEastPoints);
                        playerRanking.PlayerScore  += table.PlayerEastScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerEastScore);
                    }
                    else if (player.PlayerId.ToString().Equals(table.PlayerSouthId))
                    {
                        playerRanking.PlayerPoints += table.PlayerSouthPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerSouthPoints);
                        playerRanking.PlayerScore  += table.PlayerSouthScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerSouthScore);
                    }
                    else if (player.PlayerId.ToString().Equals(table.PlayerWestId))
                    {
                        playerRanking.PlayerPoints += table.PlayerWestPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerWestPoints);
                        playerRanking.PlayerScore  += table.PlayerWestScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerWestScore);
                    }
                    else
                    {
                        playerRanking.PlayerPoints += table.PlayerNorthPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerNorthPoints);
                        playerRanking.PlayerScore  += table.PlayerNorthScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerNorthScore);
                    }
                }
                _playersRankings.Add(playerRanking);
            }
            _playersRankings = _playersRankings.OrderByDescending(x => x.PlayerPoints).ThenByDescending(x => x.PlayerScore).ToList();
            for (int i = 0; i < _playersRankings.Count; i++)
            {
                _playersRankings[i].Order = i + 1;
            }
        }
Ejemplo n.º 5
0
 private void ShowCountriesSelector(int rowIndex)
 {
     using (var countrySelectorForm = new CountrySelectorForm())
     {
         if (countrySelectorForm.ShowDialog() == DialogResult.OK)
         {
             int playerId = (int)dgv.Rows[rowIndex].Cells[DBPlayer.COLUMN_PLAYERS_ID].Value;
             if (countrySelectorForm.ReturnValue != null && !countrySelectorForm.ReturnValue.Equals(string.Empty))
             {
                 _presenter.SaveNewPlayerCountry(playerId, countrySelectorForm.ReturnValue);
                 dgv.Rows[rowIndex].Cells[DBPlayer.COLUMN_PLAYERS_COUNTRY_NAME].Value  = countrySelectorForm.ReturnValue;
                 dgv.Rows[rowIndex].Cells[DGVPlayer.COLUMN_PLAYERS_COUNTRY_FLAG].Value =
                     CountryFlags.GetFlagImage(countrySelectorForm.ReturnValue);
             }
         }
     }
 }
Ejemplo n.º 6
0
        public void LoadForm(int tournamentId)
        {
            _tournament = _db.GetTournament(tournamentId);
            _players    = _db.GetTournamentPlayers(tournamentId);
            if (_tournament.IsTeams)
            {
                _teams = _db.GetTournamentTeams(tournamentId);
            }
            _countries = _db.GetCountries();

            List <DGVPlayer> dgvPlayers = new List <DGVPlayer>(_players.Count);

            foreach (DBPlayer player in _players)
            {
                dgvPlayers.Add(new DGVPlayer(player, getPlayerTeamName(player.PlayerTeamId),
                                             CountryFlags.GetFlagImage(player.PlayerCountryName)));
            }

            _form.FillDGV(dgvPlayers, _tournament.IsTeams);
            CheckWrongPlayersTeams();
        }
Ejemplo n.º 7
0
        async void HandleFlag(CountryFlags newValue) {
            var countryName = newValue.ToString();
            var path = ResourcePath + countryName + ".png";

            await TrySetFlagSource(path).ConfigureAwait(false);
        }