/// <summary> /// Initiliazes all the chatrooms based on the <see cref="Dictionary{TKey, TValue}"/> parameter. /// </summary> public void InitializeChatrooms(Dictionary <int, Chatroom> rooms) { foreach (var item in rooms) { Chatroom room = item.Value; if (!Chatrooms.ContainsKey(room.ID)) { Chatrooms.Add(room.ID, room); ChatroomsList.Add(room); } } List <Chatroom> toRemove = new List <Chatroom>(); foreach (var item in Chatrooms) { if (!item.Value.IsPrivate && !rooms.ContainsKey(item.Key)) { toRemove.Add(item.Value); } } foreach (var item in toRemove) { Chatrooms.Remove(item.ID); ChatroomsList.Remove(item); } OnChatroomsChanged(new EventArgs()); }
/// <summary> /// Adds a private chatroom to the chatroom mananger. /// </summary> public void AddPrivateRoom(Chatroom room) { room.IsPrivate = true; Chatrooms.Add(room.ID, room); ChatroomsList.Add(room); OnChatroomsChanged(new EventArgs()); }