public void AcceptCurrentFriendRequest() { if (CurrentFriendRequest == null) { return; } var error = ToxErrorFriendAdd.Ok; int friendNumber = ProfileManager.Instance.Tox.AddFriendNoRequest(new ToxKey(ToxKeyType.Public, CurrentFriendRequest.PublicKey), out error); if (error != ToxErrorFriendAdd.Ok) { Debugging.Write("Failed to add friend: " + error); } else { var model = new FriendControlViewModel(this); model.ChatNumber = friendNumber; model.Name = ProfileManager.Instance.Tox.GetFriendPublicKey(friendNumber).ToString(); //add the friend to the list, sorted AddObject(model); SortObject(model); //auto switch to converation view of this friend (?) SelectObject(model); } RemoveCurrentFriendRequest(); }
private void Init() { foreach (int friend in ProfileManager.Instance.Tox.Friends) { string name = ProfileManager.Instance.Tox.GetFriendName(friend); string statusMessage = ProfileManager.Instance.Tox.GetFriendStatusMessage(friend); var model = new FriendControlViewModel(this); model.ChatNumber = friend; model.Name = string.IsNullOrEmpty(name) ? ProfileManager.Instance.Tox.GetFriendPublicKey(friend).ToString() : name; model.StatusMessage = statusMessage; AddObject(model); } RearrangeChatCollection(); }
public ConversationViewModel(FriendControlViewModel model) { Friend = model; }