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; }
private void FriendRequestDeclineAction(IFriendObject friendObject) { this.ViewModel.ChatRequestCollection.Remove(friendObject); friendObject.RequestFlowDocument = null; friendObject.SelectedAction = null; friendObject.AcceptAction = null; friendObject.DeclineAction = null; }
private void FriendDenyCallAction(IFriendObject friendObject) { if (call == null) { toxav.Reject(friendObject.CallIndex, "I'm busy..."); friendObject.IsCalling = false; } else { call.Stop(); call = null; } }
private void FriendHangupAction(IFriendObject friendObject) { EndCall(friendObject); }
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(); }
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; }
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; }
private void GroupInviteAction(IFriendObject friendObject, IGroupObject groupObject) { tox.InviteFriend(friendObject.ChatNumber, groupObject.ChatNumber); }
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; }
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; }
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(); }
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(); } }
private void FriendCopyIdAction(IFriendObject friendObject) { Clipboard.Clear(); Clipboard.SetText(tox.GetFriendPublicKey(friendObject.ChatNumber).GetString()); }
private void FriendRequestSelectedAction(IFriendObject friendObject, bool isSelected) { friendObject.RequestFlowDocument.AddNewMessageRow(tox, friendObject.RequestMessageData, emojis); }
private void FriendAcceptCallAction(IFriendObject friendObject) { if (call != null) return; call = new ToxCall(tox, toxav, friendObject.CallIndex, friendObject.ChatNumber); call.Answer(); }
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(); } }
private void FriendCopyIdAction(IFriendObject friendObject) { Clipboard.Clear(); Clipboard.SetText(tox.GetClientID(friendObject.ChatNumber)); }
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]; } }
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; }); }