void _client_ConversationHistoryLoaded(object sender, List <Conversation> e)
        {
            // associate contact list and last active conversation
            // only 1 to 1 conversation supported
            if (ActiveContacts == null)
            {
                ActiveContacts = new ObservableDictionary <string, ActiveContactModel>();
            }
            string participant_id;

            foreach (Conversation conversation in e)
            {
                participant_id = conversation.Participants.Keys.FirstOrDefault(c => c != CurrentUser.Id);
                if (ActiveContacts.ContainsKey(participant_id))
                {
                    ActiveContacts[participant_id].Conversation = conversation;
                }
                else
                {
                    ActiveContacts.Add(participant_id, new ActiveContactModel()
                    {
                        Conversation = conversation
                    });
                }
            }
            _conversationCache = e.ToDictionary(c => c.Id, c => new ConversationWindowManager(new ConversationViewModel(c, _client)));
        }
Exemple #2
0
        public void Update(Collision collision, long timestamp)
        {
            var parentB = collision.ParentB;
            var parentA = collision.ParentA;

            Id             = Helper.GetPairId(collision.BodyA, collision.BodyB);
            TimeUpdate     = timestamp;
            Collision      = collision;
            _inverseMass   = parentA.InverseMass + parentB.InverseMass;
            Friction       = Math.Min(parentA.Friction, parentB.Friction);
            FrictionStatic = Math.Max(parentA.FrictionStatic, parentB.FrictionStatic);
            Restitution    = Math.Max(parentA.Restitution, parentB.Restitution);
            Slop           = Math.Max(parentA.Slop, parentB.Slop);
            ActiveContacts.Clear();

            Trigger = collision.ParentA.Trigger || collision.ParentB.Trigger;

            if (collision.Collided)
            {
                foreach (var vertex in collision.Supports.Vertexes)
                {
                    var     contactId = vertex.GetId();
                    Contact contact;

                    if (Contacts.TryGetValue(contactId, out contact))
                    {
                        ActiveContacts.Add(contact);
                    }
                    else
                    {
                        var newContact = new Contact()
                        {
                            Id     = contactId,
                            Vertex = vertex
                        };
                        Contacts[contactId] = newContact;
                        ActiveContacts.Add(newContact);
                    }
                }

                _separation = collision.Depth;
                SetActive(true, timestamp);
            }
            else
            {
                if (Active)
                {
                    SetActive(false, timestamp);
                }
            }
        }
 void _client_ContactInformationReceived(object sender, User e)
 {
     if (ActiveContacts.ContainsKey(e.Id))
     {
         ActiveContacts[e.Id].Contact = e;
     }
     else
     {
         ActiveContacts.Add(e.Id, new ActiveContactModel()
         {
             Contact = e
         });
     }
 }
Exemple #4
0
        void _client_ConversationHistoryLoaded(object sender, List <Conversation> e)
        {
            // associate contact list and last active conversation
            // only 1 to 1 conversation supported
            if (ActiveContacts == null)
            {
                ActiveContacts = new List <ConversationViewModel>();
            }

            foreach (Conversation conversation in e)
            {
                ActiveContacts.Add(new ConversationViewModel(conversation, _client));
            }

            reorderContacts();
        }
Exemple #5
0
        void _client_ConversationHistoryLoaded(object sender, List <Conversation> e)
        {
            // associate contact list and last active conversation
            // only 1 to 1 conversation supported
            if (ActiveContacts == null)
            {
                ActiveContacts = new ObservableCollection <ConversationViewModel>();
            }

            foreach (Conversation conversation in e)
            {
                ActiveContacts.Add(new ConversationViewModel(conversation, _client));
            }

            OnPropertyChanged("ActiveContacts");
        }
        private async Task <TimeSpan> LoadFromExternalDatabase()
        {
            ActiveContacts.Clear();

            var table = await _externalDb.FetchAllContacts();

            _logger.LogInfo("Found " + table.Count + " contacts in databse");
            foreach (var contact in table)
            {
                ActiveContacts.Add(contact);
            }

            ActiveContacts.Sort();

            //TimeScheduler.GetTimeScheduler().AddTask(DS_TASK_NAME, TimeSpan.FromSeconds(INITIAL_DELAY), () => OnTimedEvent());
            return(TimeScheduler.STOP_TIMER);                // This stops us being re-scheduled
        }
        public async void SaveContact(Contact contact)
        {
            _logger.LogInfo("Saving contact " + contact.Id + " profile=" + contact.RealName);

            if (contact.Id == 0)
            {
                Contact newContact = await _externalDb.AddNewContact(contact);

                if (newContact != null)
                {
                    contact.Id = newContact.Id;
                    ActiveContacts.Add(contact);
                }
            }
            else
            {
                Contact newContact = await _externalDb.ModifyContact(contact);
            }
        }
Exemple #8
0
 void _client_NewConversationCreated(object sender, Conversation e)
 {
     ActiveContacts.Add(new ConversationViewModel(e, _client));
     reorderContacts();
 }