public ContactViewModel(User user, ContactViewModel parent) { User = user; IsOnline = user.Online; Status = user.Online ? "Online" : "Offline"; _parent = parent; }
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; }
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); }
public ContactViewModel(User user) { User = user; IsOnline = user.Online; Status = user.Online ? "Online" : "Offline"; }
public ChatSessionEventArgs(User user, string message) { Contact = user; Message = message; }
public OpenChatEventArgs(User contact) { Contact = contact; }
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)); } }
public ChatSessionViewModel(User user) { Contact = user; Conversation = new ObservableCollection<Message>(); }