Esempio n. 1
0
 public ContactViewModel(User user, ContactViewModel parent)
 {
     User = user;
     IsOnline = user.Online;
     Status = user.Online ? "Online" : "Offline";
     _parent = parent;
 }
Esempio n. 2
0
 public ChatSessionViewModel StartNewSession(User contact, User initiator)
 {
     var viewModel = new ChatSessionViewModel(contact);
     viewModel.Initiator = initiator;
     viewModel.SendMessage += OnSendMessage;
     viewModel.ChatSessionClosed += OnChatSessionClosed;
     _chatSessions.Add(contact.Name, viewModel);
     return viewModel;
 }
Esempio n. 3
0
 public void AddMessage(Message message, User initiator)
 {
     ChatSessionViewModel chatSession;
     if (!_chatSessions.TryGetValue(message.From.Name, out chatSession))
     {
         chatSession = StartNewSession(message.From, initiator);
         chatSession.OpenChat();
     }
     chatSession.MessageReceived(message);
 }
Esempio n. 4
0
 public ContactViewModel(User user)
 {
     User = user;
     IsOnline = user.Online;
     Status = user.Online ? "Online" : "Offline";
 }
Esempio n. 5
0
 public ChatSessionEventArgs(User user, string message)
 {
     Contact = user;
     Message = message;
 }
Esempio n. 6
0
 public OpenChatEventArgs(User contact)
 {
     Contact = contact;
 }
Esempio n. 7
0
        private void OnUserStatusChange(User user)
        {
            // Mark user as online/offline
            if (Contacts != null)
            {
                var contact = Contacts.FirstOrDefault(u => u.User.Name == user.Name);
                if (contact != null)
                {
                    // For the contact list to register that the contact has changed status,
                    // have to remove and re-add the contact again
                    Contacts.Remove(contact);
                }

                Contacts.Add(new ContactViewModel(user, Me));
            }
        }
Esempio n. 8
0
 public ChatSessionViewModel(User user)
 {
     Contact = user;
     Conversation = new ObservableCollection<Message>();
 }