Ejemplo n.º 1
0
 public ChatViewModel()
 {
     dialogService          = new DialogService();
     currentRoom            = new RoomModel();
     listMessageModel       = ListMessageModel.GetInstance();
     sendersTyping          = new ObservableCollection <string>();
     socket                 = SocketAPI.GetInstance().GetSocket();
     SendTextMessageCommand = new DelegateCommand(SendMessage);
     ItemSelectedCommand    = new DelegateCommand <RoomModel>(HandleItemSelected);
     TypingCommand          = new DelegateCommand <TextBox>(HandleTyping);
     ChangeImageCommand     = new DelegateCommand(ChangeImage);
     SignOutCommand         = new DelegateCommand(SignOut);
     DisplayTyping          = "Hidden";
     userInfo               = UserInfo.GetInstance();
     HandleSocket();
 }
        // method
        private void HandleSelectedItem(RoomModel obj)
        {
            currentRoom = obj;

            //emit to server to get message
            socket.Emit("room_change", obj.ID);

            int index = ListRoomModel.GetInstance().GetIndexByValue("ID", obj.ID);

            ListRoomModel.GetInstance().List[index].DisplayNewMessage = "Hidden";
            ListRoomModel.GetInstance().List[index].NotifyChanged("DisplayNewMessage");
            ListRoomModel.GetInstance().NotifyChanged("List");

            //clear data in list message
            ListMessageModel.GetInstance().Clear();
            // clear list task
            ListTaskModel.GetInstance().Clear();
        }