예제 #1
0
        private void AddFriend(int id)
        {
            if (!Tox.FriendExists(id))
            {
                return;
            }

            ContactViewModel contact = new ContactViewModel();

            contact.ID        = id;
            contact.Name      = Tox.GetFriendName(id);
            contact.Subtext   = Tox.GetFriendStatusMessage(id); // TODO: Replace this with last message when we have a conversation with the contact
            contact.Status    = Utilities.GetDetoxStatusByFriendNumber(id, Tox);
            contact.Timestamp = "5m";                           // TODO: Replace this with last messaged

            if (!File.Exists(Utilities.GetAvatarPath(id, Tox)))
            {
                contact.Image = Path.GetFullPath("./defaultpic.png");
            }
            else
            {
                contact.Image = Utilities.GetAvatarPath(id, Tox);
            }

            List.Add(contact);
        }
예제 #2
0
        public FriendListEntryViewModel(Tox tox, uint friendNumber)
        {
            //var publicKey = tox.GetFriendPublicKey(friendNumber);
            var status = tox.Events().Friends.StatusChanged
                         .Where(x => x.FriendNumber == friendNumber)
                         .Select(x => x.Status);

            status.Select(x => x == ToxUserStatus.Away)
            .ToPropertyEx(this, x => x.IsAway);

            status.Select(x => x == ToxUserStatus.Busy)
            .ToPropertyEx(this, x => x.IsBusy);

            tox.Events().Friends.NameChanged
            .Where(x => x.FriendNumber == friendNumber)
            .Select(x => x.Name)
            .StartWith(tox.GetFriendName(friendNumber, out _))
            .ToPropertyEx(this, x => x.Name);

            tox.Events().Friends.StatusMessageChanged
            .Where(x => x.FriendNumber == friendNumber)
            .Select(x => x.StatusMessage)
            .StartWith(tox.GetFriendStatusMessage(friendNumber, out _))
            .ToPropertyEx(this, x => x.StatusMessage);

            this.Remove       = ReactiveCommand.Create(() => friendNumber);
            this.Conversation = new FriendConversationViewModel(tox, friendNumber);
        }