private void RefreshFriends()
{
if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { RefreshFriends(); });
else
{
Client.Friends.FriendList.ForEach(delegate(FriendInfo friend)
{
string key = friend.UUID.ToString();
string onlineText;
string name = friend.Name == null ? "(loading...)" : friend.Name;
int image;
Color color;
if (friend.IsOnline)
{
image = 1;
onlineText = "*";
color = Color.FromKnownColor(KnownColor.ControlText);
}
else
{
image = 0;
onlineText = " ";
color = Color.FromKnownColor(KnownColor.GrayText);
}
if (!this.Items.ContainsKey(key))
{
this.Items.Add(key, name, image);
this.Items[key].SubItems.Add(onlineText);
}
else
{
if (this.Items[key].Text == string.Empty || friend.Name != null)
this.Items[key].Text = name;
this.Items[key].SubItems[1].Text = onlineText;
}
this.Items[key].ForeColor = color;
this.Items[key].ImageIndex = image;
this.Items[key].Tag = friend;
});
}
}