示例#1
0
        private void FriendRequestAcceptAction(IFriendObject friendObject)
        {
            int friendnumber = tox.AddFriendNoRequest(friendObject.Name);
            tox.SetSendsReceipts(friendnumber, true);
            AddFriendToView(friendnumber);

            this.ViewModel.ChatRequestCollection.Remove(friendObject);
            friendObject.RequestFlowDocument = null;
            friendObject.SelectedAction = null;
            friendObject.AcceptAction = null;
            friendObject.DeclineAction = null;
            friendObject.MainViewModel = null;
        }
示例#2
0
 private void FriendRequestDeclineAction(IFriendObject friendObject)
 {
     this.ViewModel.ChatRequestCollection.Remove(friendObject);
     friendObject.RequestFlowDocument = null;
     friendObject.SelectedAction = null;
     friendObject.AcceptAction = null;
     friendObject.DeclineAction = null;
 }
示例#3
0
 private void FriendDenyCallAction(IFriendObject friendObject)
 {
     if (call == null)
     {
         toxav.Reject(friendObject.CallIndex, "I'm busy...");
         friendObject.IsCalling = false;
     }
     else
     {
         call.Stop();
         call = null;
     }
 }
示例#4
0
 private void FriendHangupAction(IFriendObject friendObject)
 {
     EndCall(friendObject);
 }
示例#5
0
        private async void FriendDeleteAction(IFriendObject friendObject)
        {
            var result = await this.ShowMessageAsync("Remove friend", string.Format("Are you sure you want to remove {0} from your friend list?", friendObject.Name), MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings() { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });
            if (result != MessageDialogResult.Affirmative)
                return;

            ViewModel.ChatCollection.Remove(friendObject);
            var friendNumber = friendObject.ChatNumber;
            if (convdic.ContainsKey(friendNumber))
            {
                convdic.Remove(friendNumber);
                if (friendObject.Selected)
                {
                    ChatBox.Document = null;
                }
            }
            tox.DeleteFriend(friendNumber);
            friendObject.SelectedAction = null;
            friendObject.DenyCallAction = null;
            friendObject.AcceptCallAction = null;
            friendObject.CopyIDAction = null;
            friendObject.DeleteAction = null;
            friendObject.GroupInviteAction = null;
            friendObject.MainViewModel = null;

            saveTox();
        }
示例#6
0
 private void FriendDeleteAction(IFriendObject friendObject)
 {
     this.ViewModel.ChatCollection.Remove(friendObject);
     var friendNumber = friendObject.ChatNumber;
     if (convdic.ContainsKey(friendNumber))
     {
         convdic.Remove(friendNumber);
         if (friendObject.Selected)
         {
             ChatBox.Document = null;
         }
     }
     tox.DeleteFriend(friendNumber);
     friendObject.SelectedAction = null;
     friendObject.DenyCallAction = null;
     friendObject.AcceptCallAction = null;
     friendObject.CopyIDAction = null;
     friendObject.DeleteAction = null;
     friendObject.GroupInviteAction = null;
     friendObject.MainViewModel = null;
 }
示例#7
0
        private void EndCall(IFriendObject friend)
        {
            if (friend != null)
            {
                toxav.Cancel(friend.CallIndex, friend.ChatNumber, "I'm busy...");

                friend.IsCalling = false;
                friend.IsCallingToFriend = false;
            }

            if (call != null)
            {
                call.Stop();
                call = null;
            }

            this.ViewModel.CallingFriend = null;

            HangupButton.Visibility = Visibility.Collapsed;
            CallButton.Visibility = Visibility.Visible;
        }
示例#8
0
 private void GroupInviteAction(IFriendObject friendObject, IGroupObject groupObject)
 {
     tox.InviteFriend(friendObject.ChatNumber, groupObject.ChatNumber);
 }
示例#9
0
        private void EndCall(IFriendObject friend)
        {
            if (friend != null)
            {
                toxav.Cancel(friend.CallIndex, friend.ChatNumber, "I'm busy...");

                friend.IsCalling = false;
                friend.IsCallingToFriend = false;
            }

            if (call != null)
            {
                call.Stop();
                call = null;

                CurrentCallControl.TimerLabel.Content = "00:00:00";
            }

            ViewModel.CallingFriend = null;
            VideoImageRow.Height = new GridLength(0);
            VideoGridSplitter.IsEnabled = false;
            VideoChatImage.Source = null;

            HangupButton.Visibility = Visibility.Collapsed;
            VideoButton.Visibility = Visibility.Collapsed;
            CallButton.Visibility = Visibility.Visible;
        }
示例#10
0
        private void SelectFriendControl(IFriendObject friend)
        {
            if (friend == null)
            {
                return;
            }
            int friendNumber = friend.ChatNumber;

            if (call != null && call.GetType() != typeof(ToxGroupCall))
            {
                if (call.FriendNumber != friendNumber)
                {
                    HangupButton.Visibility = Visibility.Collapsed;
                    VideoButton.Visibility = Visibility.Collapsed;

                    if (tox.IsFriendOnline(friendNumber))
                    {
                        CallButton.Visibility = Visibility.Visible;
                        FileButton.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        CallButton.Visibility = Visibility.Collapsed;
                        FileButton.Visibility = Visibility.Collapsed;
                    }

                    VideoImageRow.Height = new GridLength(0);
                    VideoGridSplitter.IsEnabled = false;
                    VideoChatImage.Source = null;
                }
                else
                {
                    HangupButton.Visibility = Visibility.Visible;
                    VideoButton.Visibility = Visibility.Visible;
                    CallButton.Visibility = Visibility.Collapsed;

                    if (toxav.GetPeerCodecSettings(call.CallIndex, 0).CallType == ToxAvCallType.Video)
                    {
                        VideoImageRow.Height = new GridLength(300);
                        VideoGridSplitter.IsEnabled = true;
                    }
                }
            }
            else
            {
                if (!tox.IsFriendOnline(friendNumber))
                {
                    CallButton.Visibility = Visibility.Collapsed;
                    FileButton.Visibility = Visibility.Collapsed;
                }
                else
                {
                    CallButton.Visibility = Visibility.Visible;
                    FileButton.Visibility = Visibility.Visible;
                }

                VideoImageRow.Height = GridLength.Auto;
            }

            MicButton.Visibility = Visibility.Collapsed;

            if (convdic.ContainsKey(friend.ChatNumber))
            {
                ChatBox.Document = convdic[friend.ChatNumber];
            }
            else
            {
                FlowDocument document = FlowDocumentExtensions.CreateNewDocument();
                convdic.Add(friend.ChatNumber, document);
                ChatBox.Document = convdic[friend.ChatNumber];
            }

            GroupListGrid.Visibility = Visibility.Collapsed;
            PeerColumn.Width = GridLength.Auto;
        }
示例#11
0
        private void FriendRequestAcceptAction(IFriendObject friendObject)
        {
            int friendnumber = tox.AddFriendNoRequest(new ToxKey(ToxKeyType.Public, friendObject.Name));

            if (friendnumber != -1)
                AddFriendToView(friendnumber, false);
            else
                this.ShowMessageAsync("Unknown Error", "Could not accept friend request.");

            ViewModel.ChatRequestCollection.Remove(friendObject);
            friendObject.RequestFlowDocument = null;
            friendObject.SelectedAction = null;
            friendObject.AcceptAction = null;
            friendObject.DeclineAction = null;
            friendObject.MainViewModel = null;

            saveTox();
        }
示例#12
0
        private void FriendSelectedAction(IFriendObject friendObject, bool isSelected)
        {
            MessageAlertClear(friendObject);

            if (isSelected)
            {
                if (!tox.GetFriendTypingStatus(friendObject.ChatNumber) || tox.GetFriendStatus(friendObject.ChatNumber) == ToxUserStatus.None)
                    TypingStatusLabel.Content = "";
                else
                    TypingStatusLabel.Content = getFriendName(friendObject.ChatNumber) + " is typing...";

                SelectFriendControl(friendObject);
                ScrollChatBox();
                TextToSend.Focus();
            }
        }
示例#13
0
 private void FriendCopyIdAction(IFriendObject friendObject)
 {
     Clipboard.Clear();
     Clipboard.SetText(tox.GetFriendPublicKey(friendObject.ChatNumber).GetString());
 }
示例#14
0
 private void FriendRequestSelectedAction(IFriendObject friendObject, bool isSelected)
 {
     friendObject.RequestFlowDocument.AddNewMessageRow(tox, friendObject.RequestMessageData, emojis);
 }
示例#15
0
        private void FriendAcceptCallAction(IFriendObject friendObject)
        {
            if (call != null)
                return;

            call = new ToxCall(tox, toxav, friendObject.CallIndex, friendObject.ChatNumber);
            call.Answer();
        }
示例#16
0
        private void FriendSelectedAction(IFriendObject friendObject, bool isSelected)
        {
            friendObject.HasNewMessage = false;
            friendObject.NewMessageCount = 0;

            if (!tox.GetIsTyping(friendObject.ChatNumber))
                TypingStatusLabel.Content = "";
            else
                TypingStatusLabel.Content = tox.GetName(friendObject.ChatNumber) + " is typing...";

            if (isSelected)
            {
                SelectFriendControl(friendObject);
                ScrollChatBox();
                TextToSend.Focus();
            }
        }
示例#17
0
 private void FriendCopyIdAction(IFriendObject friendObject)
 {
     Clipboard.Clear();
     Clipboard.SetText(tox.GetClientID(friendObject.ChatNumber));
 }
示例#18
0
        private void SelectFriendControl(IFriendObject friend)
        {
            if (friend == null)
            {
                return;
            }
            int friendNumber = friend.ChatNumber;

            if (call != null)
            {
                if (call.FriendNumber != friendNumber)
                    HangupButton.Visibility = Visibility.Collapsed;
                else
                    HangupButton.Visibility = Visibility.Visible;
            }
            else
            {
                if (tox.GetFriendConnectionStatus(friendNumber) != 1)
                {
                    CallButton.Visibility = Visibility.Collapsed;
                    FileButton.Visibility = Visibility.Collapsed;
                }
                else
                {
                    CallButton.Visibility = Visibility.Visible;
                    FileButton.Visibility = Visibility.Visible;
                }
            }

            if (convdic.ContainsKey(friend.ChatNumber))
            {
                ChatBox.Document = convdic[friend.ChatNumber];
            }
            else
            {
                FlowDocument document = GetNewFlowDocument();
                convdic.Add(friend.ChatNumber, document);
                ChatBox.Document = convdic[friend.ChatNumber];
            }
        }
示例#19
0
        private Task<bool> applyAvatar(IFriendObject friend)
        {
            return Task.Run(() =>
            {
                byte[] data;
                var img = avatarStore.Load(tox.GetFriendPublicKey(friend.ChatNumber), out data);
                Dispatcher.BeginInvoke(((Action)(() => friend.Avatar = img)));

                if (!avatarStore.Save(data, tox.GetFriendPublicKey(friend.ChatNumber)))
                    return false;

                return true;
            });
        }