Example #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());
        }
Example #2
0
        /// <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());
        }
Example #3
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);
     }
 }