internal void RemoveChatTab(ChatTab tab)
 {
     if (tab != null)
     {
         tabControl_Page.Items.Remove(tab);
         tabControl_Page.SelectedItem = tabItem_Main;
     }
 }
        private void sock_OnAddClient(object sender, AddClientEventArgs e)
        {
            if (e.ErrCode == AddClientEventArgs.ErrorCode.Ok)
            {
                PengChat3ClientSock sock = (PengChat3ClientSock)sender;
                ChatTab tab;

                if (e.AddedMember.Nickname == sock.Nickname)
                {
                    var room = GetViewModelBySocket(sock).Rooms.Find(r => { return r.ID == e.RoomID.Value; });

                    Dispatcher.Invoke(new Action(delegate()
                    {
                        tab = new ChatTab(sock, room);
                        tabControl_Page.Items.Add(tab);
                        tabControl_Page.SelectedItem = tab;
                        // Of course GetMembersInfo function is also get my info.
                    }));

                    sock.GetMembersInfo(e.RoomID.Value);
                }
                else
                {
                    GetChatTabBySocketAndRoomID(sock, e.RoomID.Value).AddMember(e.AddedMember);
                }
            }
            else
            {
                string err = ResourceManager.GetStringByKey("Str_CannotEntryToRoom") + '\n';

                switch (e.ErrCode)
                {
                    case AddClientEventArgs.ErrorCode.AlreadyEntered:
                        err += ResourceManager.GetStringByKey("Str_AlreadyLogged");
                        break;
                    case AddClientEventArgs.ErrorCode.PasswordIsWrong:
                        err += ResourceManager.GetStringByKey("Str_PasswordIsWrong");
                        break;
                    case AddClientEventArgs.ErrorCode.RoomIsFull:
                        err += ResourceManager.GetStringByKey("Str_RoomIsFull");
                        break;
                }

                Log(LogType.LogKind.Failed, err);

                Dispatcher.Invoke(new Action(delegate()
                {
                    Utility.Error(err);
                }));
            }
        }