public EditPlayerDialog() { InitializeComponent(); this.player = new Player(); this.playerBindingSource.DataSource = player; }
public void AddPlayer(Player p) { int c = table.ColumnCount; int n = table.RowCount; int r = table.Rows.Add(); DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn() { HeaderText = (n + 1).ToString(), Width = 50, SortMode = DataGridViewColumnSortMode.Programmatic, MaxInputLength = 3, ReadOnly = true, Name = "colPlayer" + n.ToString() }; table.Columns.Insert(n + playersStartIndex, col); table.Rows[r].Cells[0].Value = (n + 1).ToString(); table.Rows[r].Cells[1].Value = p.GetNameWithRate(Type); table.Rows[r].Tag = p; table[n + playersStartIndex, n].Style.BackColor = System.Drawing.SystemColors.WindowFrame; CountTable(); }
public EditPlayerDialog(Player p) : this() { this.Text = p.ToString(); this.player = p.Clone(); this.playerBindingSource.DataSource = player; }
public void AddPlayer(Player p) { int n = table.RowCount; int r = table.Rows.Add(); table.Rows[r].Cells[0].Value = (n + 1).ToString(); table.Rows[r].Cells[1].Value = p.GetNameWithRate(Type); table.Rows[r].Tag = p; CountTable(); }
public int GetAverageRate(Player p) { int sum = 0; for (int i = 0; i < table.RowCount; ++i) { sum += GetPlayer(i).GetRate(Type); } return EloTable.DivideRound(sum, table.RowCount); }
private int GetIndexByPlayer(Player p) { for (int i = 0; i < table.RowCount; ++i) { if (GetPlayer(i).Id == p.Id) { return i; } } return -1; }
public int GetMaxPoints(Player p) { return 2 * (table.RowCount - 1) * Rounds; }
public TournamentResult GetResult(Player p) { int index = GetIndexByPlayer(p); return new TournamentResult() { Participant = p, //Event = GetTournament(), Points = (int)table.Rows[index].Cells["colPoints"].Tag, SeqNumber = index + 1, }; }
private void InsertPlayerIntoViewList(Player p, int index, int count) { ListViewItem item = new ListViewItem(new[] {(index + 1).ToString(), p.Name, p.GetRate(currentRateType).ToString(), p.GetUpdateDate(currentRateType).ToString("dd.MM.yyyy HH:mm") }); item.Tag = p; item.UseItemStyleForSubItems = false; if (index < (count + 1) / 2) { playersListLeft.InsertItem(item); } else { playersListRight.InsertItem(item); } HighlightOldPlayer(item); }
public void UpdatePlayer(Player p) { editPlayerCmd.Parameters.AddWithValue("@name", p.Name); editPlayerCmd.Parameters.AddWithValue("@rblitz", p.BlitzRate); editPlayerCmd.Parameters.AddWithValue("@rrapid", p.RapidRate); editPlayerCmd.Parameters.AddWithValue("@rclassic", p.ClassicRate); editPlayerCmd.Parameters.AddWithValue("@blitzup", p.BlitzLastUpdate.ToUniversalTime()); editPlayerCmd.Parameters.AddWithValue("@rapidup", p.RapidLastUpdate.ToUniversalTime()); editPlayerCmd.Parameters.AddWithValue("@classicup", p.ClassicLastUpdate.ToUniversalTime()); editPlayerCmd.Parameters.AddWithValue("@id", p.Id); editPlayerCmd.ExecuteNonQuery(); }
private bool IsPlayerInactive(Player p) { return !p.IsActive(currentRateType); }
private static int ComparePlayersByBlitzRate(Player x, Player y) { return y.BlitzRate - x.BlitzRate; }
private void PlayerDeleteCallback(Player p) { return; }
public int GetMaxPoints(Player p) { return 2 * (table.RowCount - 1); //TODO many rounds }
private static int ComparePlayersByRapidRate(Player x, Player y) { return y.RapidRate - x.RapidRate; }
private static int ComparePlayersByName(Player x, Player y) { return x.Name.CompareTo(y.Name); }
private static int ComparePlayersByClassicRate(Player x, Player y) { return y.ClassicRate - x.ClassicRate; }
private void OnTablePlayerDeleted(Player p) { if (!showInactivePlayers && IsPlayerInactive(p)) { inactivePlayers.Add(p); return; } availablePlayers.Insert(0, p); if (currentDataSource == searchResult) { if (p.Name.StartsWith(searchPlayer.Text, ignoreCase)) { searchResult.Insert(0, p); } } else if (currentDataSource == noResult) { if (p.Name.StartsWith(searchPlayer.Text, ignoreCase)) { searchResult.Insert(0, p); currentDataSource = searchResult; } } SetDataSource(currentDataSource); }
public List<Player> LoadAllPlayers(PlayerSortType st, GameType gt) { SQLiteCommand selectCmd = GetSelectCmd(st, gt); List<Player> players = new List<Player>(); SQLiteDataReader dataReader = selectCmd.ExecuteReader(); while (dataReader.Read()) { Player p = new Player(dataReader.GetInt64(7)) { Name = dataReader.GetString(0), BlitzRate = dataReader.GetInt32(1), RapidRate = dataReader.GetInt32(2), ClassicRate = dataReader.GetInt32(3), BlitzLastUpdate = dataReader.GetDateTime(4), RapidLastUpdate = dataReader.GetDateTime(5), ClassicLastUpdate = dataReader.GetDateTime(6), }; players.Add(p); } dataReader.Close(); return players; }
public void RemovePlayer(Player p) { removePlayerCmd.Parameters.AddWithValue("@id", p.Id); removePlayerCmd.ExecuteNonQuery(); }
private void EditPlayer(Player player) { EditPlayerDialog editDialog = new EditPlayerDialog(player); if(editDialog.ShowDialog() == DialogResult.OK) { dbMgr.UpdatePlayer(editDialog.GetPlayer()); ReloadPlayersAndView(); //TODO just update the item } }