Exemplo n.º 1
0
 /// <summary>
 /// Updates the list of client names in the window
 /// </summary>
 /// <param name="players">The list of players to add</param>
 public void UpdateClientList(List <Player> players)
 {
     if (this.InvokeRequired)
     {
         PlayerListCallback d = new PlayerListCallback(UpdateClientList);
         this.Invoke(d, new object[] { players });
     }
     else
     {
         liClients.Items.Clear();
         Player.players.ForEach(delegate(Player p) { liClients.Items.Add(p.name); });
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the list of client names in the window
        /// </summary>
        /// <param name="players">The list of players to add</param>
        public void UpdateClientList(List <Player> players)
        {
            if (this.InvokeRequired)
            {
                PlayerListCallback d = UpdateClientList;
                Invoke(d, new List <Player>[] { players });
            }
            else
            {
                if (dgvPlayers.DataSource == null)
                {
                    dgvPlayers.DataSource = pc;
                }

                // Try to keep the same selection on update
                string selected = null;
                if (pc.Count > 0 && dgvPlayers.SelectedRows.Count > 0)
                {
                    selected = (from DataGridViewRow row in dgvPlayers.Rows where row.Selected select pc[row.Index]).First().name;
                }

                // Update the data source and control
                //dgvPlayers.SuspendLayout();

                pc = new PlayerCollection(new PlayerListView());
                Player.players.ForEach(p => pc.Add(p));

                //dgvPlayers.Invalidate();
                dgvPlayers.DataSource = pc;
                // Reselect player
                if (selected != null)
                {
                    for (int i = 0; i < Player.players.Count; i++)
                    {
                        for (int j = 0; j < dgvPlayers.Rows.Count; j++)
                        {
                            if (String.Equals(dgvPlayers.Rows[j].Cells[0].Value, selected))
                            {
                                dgvPlayers.Rows[j].Selected = true;
                            }
                        }
                    }
                }

                dgvPlayers.Refresh();
                //dgvPlayers.ResumeLayout();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the list of client names in the window
 /// </summary>
 /// <param name="players">The list of players to add</param>
 public void UpdateClientList(List<Player> players)
 {
     if (this.InvokeRequired) {
         PlayerListCallback d = new PlayerListCallback(UpdateClientList);
         this.Invoke(d, new object[] { players });
     } else {
         dgvPlayers.Rows.Clear();
         Player.players.ForEach(delegate(Player p) { string[] row = { p.name, p.group.name, p.level.name }; dgvPlayers.Rows.Add(row); });
         //Handles the Players Tab Shit
         liClients.Items.Clear();
         dgvPlayerStats.Rows.Clear();
         Player.players.ForEach(delegate(Player p) { string[] row1 = { p.name, p.title, p.group.name, p.money.ToString(), p.level.name, p.totalLogins.ToString(), p.overallBlocks.ToString() }; dgvPlayerStats.Rows.Add(row1);
         liClients.Items.Add(p.name);
         if (File.Exists("ranks/banned-ip.txt"))
         {
             cmbIpBans.Items.Clear();
             foreach (string line in File.ReadAllLines(("ranks/banned-ip.txt")))
             {
                 cmbIpBans.Items.Add(line);
             }
         }
         if (txtPName.Text != "[Selected Player]")
         {
             liClients.SelectedIndex = 0;
         }
         else if (!liClients.Items.Contains(txtPName.Text))
         {
             liClients.SelectedIndex = 0;
         }
         else
         {
             for (int i = 0; i < liClients.Items.Count; i++)
             {
                 if (liClients.Items[i].ToString().Contains(txtPName.Text))
                 {
                     liClients.SelectedIndex = i;
                 }
             }
         }
         });
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Updates the list of client names in the window
 /// </summary>
 /// <param name="players">The list of players to add</param>
 public void UpdateClientList(List<Player> players)
 {
     if (this.InvokeRequired) {
         PlayerListCallback d = new PlayerListCallback(UpdateClientList);
         this.Invoke(d, new object[] { players });
     } else {
         liClients.Items.Clear();
         Player.players.ForEach(delegate(Player p) { liClients.Items.Add(p.name); });
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the list of client names in the window
        /// </summary>
        /// <param name="players">The list of players to add</param>
        public void UpdateClientList(List<Player> players)
        {
            if (this.InvokeRequired) {
                PlayerListCallback d = new PlayerListCallback(UpdateClientList);
                this.Invoke(d, new object[] { players });
            } else {

                if(dgvPlayers.DataSource == null)
                    dgvPlayers.DataSource = pc;

                // Try to keep the same selection on update
                string selected = null;
                if(pc.Count > 0 && dgvPlayers.SelectedRows.Count > 0)
                {
                    selected = (from DataGridViewRow row in dgvPlayers.Rows where row.Selected select pc[row.Index]).First().name;
                }

                // Update the data source and control
                //dgvPlayers.SuspendLayout();

                pc = new PlayerCollection(new PlayerListView());
                Player.players.ForEach(delegate(Player p) { pc.Add(p); });

                //dgvPlayers.Invalidate();
                dgvPlayers.DataSource = pc;
                // Reselect player
                if (selected != null)
                {
                    foreach (Player p in Player.players)
                        foreach (DataGridViewRow row in dgvPlayers.Rows)
                            if (String.Equals(row.Cells[0].Value, selected))
                                row.Selected = true;
                }

                dgvPlayers.Refresh();
                //dgvPlayers.ResumeLayout();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Updates the list of client names in the window
 /// </summary>
 /// <param name="players">The list of players to add</param>
 public void UpdateClientList(List<Player> players)
 {
     if (this.InvokeRequired) {
         PlayerListCallback d = new PlayerListCallback(UpdateClientList);
         this.Invoke(d, new object[] { players });
     }
     else
     {
         try
         {
             liClients.Items.Clear();
             liPlayers.Items.Clear();
             Player.players.ForEach(delegate(Player p)
             {
                 string groupname = p.group.name;
                 if (Server.devs.Contains(p.name.ToLower())) { groupname = "MCDawn Developer"; }
                 else if (Server.staff.Contains(p.name.ToLower())) { groupname = "MCDawn Staff"; }
                 else if (Server.administration.Contains(p.name.ToLower())) { groupname = "MCDawn Administrator"; }
                 liClients.Items.Add(p.name + " (" + groupname + ")");
                 liPlayers.Items.Add(p.name + " (" + groupname + ")");
             });
             string total = " / " + Server.players.ToString();
             lblTotalPlayers.Text = Player.number.ToString() + total;
             lblTotalGuests.Text = Player.guests.ToString() + total;
             lblTotalOps.Text = Player.ops.ToString() + total;
             if (Server.useMySQL)
             {
                 try
                 {
                     DataTable count = MySQL.fillData("SELECT COUNT(id) FROM players");
                     lblTotalPlayersVisited.Text = count.Rows[0]["COUNT(id)"] + " players have visited this server.";
                 }
                 catch { }
             }
             int bancount = Group.findPerm(LevelPermission.Banned).playerList.All().Count;
             lblTotalPlayersBanned.Text = bancount + " players have been banned.";
         }
         catch { }
     }
 }