예제 #1
0
        /// <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());
        }
예제 #2
0
 /// <summary>
 /// Removes a chatroom based on the <see cref="Chatroom.ID"/>.
 /// </summary>
 public void RemoveChatroom(int chatroomId)
 {
     if (Chatrooms.ContainsKey(chatroomId))
     {
         Chatroom room = Chatrooms[chatroomId];
         DisconnectChatroom(room);
         ChatroomsList.Remove(room);
         Chatrooms.Remove(chatroomId);
     }
 }