public void UpdateUser(Dictionary <int, string> list) { OnlineUsersBox.Items.Clear(); foreach (int uid in list.Keys) { Client client = hall.GetClient(uid); if (client == null) { continue; } string nick_name = list[uid]; string message = string.Format("uid {0}:账号{2} 昵称 {1}", uid, nick_name, client.UserName); OnlineUsersBox.Items.Add(message); } }
public void UpdateUser(DataTable list) { OnlineUsersBox.Items.Clear(); foreach (DataRow row in list.Rows) { int uid = int.Parse(row["UserID"].ToString()); Client client = hall.GetClient(uid); if (client == null) { continue; } string nick_name = row["NickName"].ToString(); int room_id = int.Parse(row["RoomNumber"].ToString()); string message = string.Format("uid {0}:账号{3} 昵称 {1} {2}", uid, nick_name, room_id > 0 ? string.Format("房间{0}游戏中", room_id) : "空闲", client.UserName); OnlineUsersBox.Items.Add(message); } }