public void XmppConnectOnOnPresence(object sender, agsXMPP.protocol.client.Presence pres) { try { if (pres.GetAttribute("name") == "Facebook User") return; switch (pres.Type) { case PresenceType.available: if (Core.Presences.Contains(pres)) Core.Presences.Remove(pres); Core.Presences.Add(pres); var itemOnline = Core.AllPlayers[pres.GetAttribute("name")]; Core.AllPlayers.Remove(pres.GetAttribute("name")); itemOnline.IsOnline = true; Core.AllPlayers.Add(pres.GetAttribute("name"), itemOnline); break; case PresenceType.unsubscribe: case PresenceType.unsubscribed: case PresenceType.invisible: if (Core.Presences.Contains(pres)) Core.Presences.Remove(pres); var itemOffline = Core.AllPlayers[pres.GetAttribute("name")]; Core.AllPlayers.Remove(pres.GetAttribute("name")); itemOffline.IsOnline = false; Core.AllPlayers.Add(pres.GetAttribute("name"), itemOffline); break; } Load(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }