Esempio n. 1
0
        private void InitProgram()
        {
            InitializeComponent();
            DataContext = this;

            UserList = IMService.LoadUsers();

            var contactList = IMService.GetContacts(LoggedInUser);

            InitContactsCollection(contactList);

            InitContactsDetails();
            if (ContactsDetails != null && ContactsDetails.Count > 0)
            {
                SelectedContact = ContactsDetails.First();
            }
            InitMessagesCollection();
            Show();
        }
Esempio n. 2
0
 private void CheckForNewMessagesAndContacts()
 {
     if (LoggedInUser != null && SelectedContact != null)
     {
         var messagesList = IMService.GetAllMessagesBetweenContacts(LoggedInUser, GetSelectedUser());
         foreach (var message in messagesList)
         {
             if (MessagesCollection.Count(c => c.Id == message.Id) == 0)
             {
                 MessagesCollection.Add(message);
             }
         }
         var contactsList = IMService.GetContacts(LoggedInUser);
         foreach (var contact in contactsList)
         {
             if (ContactsCollection.Count(c => c.Username == contact.Username) == 0)
             {
                 ContactsCollection.Add(contact);
                 AddToContactsDetails(contact);
             }
         }
     }
 }