Exemplo n.º 1
0
        private void GroupSelectedAction(IGroupObject groupObject, bool isSelected)
        {
            groupObject.HasNewMessage = false;
            groupObject.NewMessageCount = 0;

            TypingStatusLabel.Content = "";

            if (isSelected)
            {
                SelectGroupControl(groupObject);
                ScrollChatBox();
                TextToSend.Focus();
            }
        }
Exemplo n.º 2
0
        private void SelectGroupControl(IGroupObject group)
        {
            if (group == null)
            {
                return;
            }

            CallButton.Visibility = Visibility.Collapsed;
            FileButton.Visibility = Visibility.Collapsed;

            group.AdditionalInfo = string.Join(", ", tox.GetGroupNames(group.ChatNumber));

            if (groupdic.ContainsKey(group.ChatNumber))
            {
                ChatBox.Document = groupdic[group.ChatNumber];
            }
            else
            {
                FlowDocument document = GetNewFlowDocument();
                groupdic.Add(group.ChatNumber, document);
                ChatBox.Document = groupdic[group.ChatNumber];
            }
        }
Exemplo n.º 3
0
        private void GroupDeleteAction(IGroupObject groupObject)
        {
            this.ViewModel.ChatCollection.Remove(groupObject);
            int groupNumber = groupObject.ChatNumber;
            if (groupdic.ContainsKey(groupNumber))
            {
                groupdic.Remove(groupNumber);

                if (groupObject.Selected)
                    ChatBox.Document = null;
            }
            tox.DeleteGroupChat(groupNumber);
            groupObject.SelectedAction = null;
            groupObject.DeleteAction = null;
        }
Exemplo n.º 4
0
 private void GroupInviteAction(IFriendObject friendObject, IGroupObject groupObject)
 {
     tox.InviteFriend(friendObject.ChatNumber, groupObject.ChatNumber);
 }
Exemplo n.º 5
0
        private void RearrangeGroupPeerList(IGroupObject group)
        {
            var peers = new ObservableCollection<GroupPeer>();

            for (int i = 0; i < tox.GetGroupMemberCount(group.ChatNumber); i++)
            {
                var publicKey = tox.GetGroupPeerPublicKey(group.ChatNumber, i);
                var oldPeer = group.PeerList.GetPeerByPublicKey(publicKey);
                GroupPeer newPeer;

                if (oldPeer != null)
                    newPeer = oldPeer;
                else
                    newPeer = new GroupPeer(group.ChatNumber, publicKey) { Name = tox.GetGroupMemberName(group.ChatNumber, i) };

                peers.Add(newPeer);
            }

            group.PeerList = new GroupPeerCollection(peers.OrderBy(p => p.Name).ToList());
        }
Exemplo n.º 6
0
        private void SelectGroupControl(IGroupObject group)
        {
            if (group == null)
            {
                return;
            }

            CallButton.Visibility = Visibility.Collapsed;
            FileButton.Visibility = Visibility.Collapsed;
            HangupButton.Visibility = Visibility.Collapsed;
            VideoButton.Visibility = Visibility.Collapsed;

            if (tox.GetGroupType(group.ChatNumber) == ToxGroupType.Av)
                MicButton.Visibility = Visibility.Visible;
            else
                MicButton.Visibility = Visibility.Collapsed;

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

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

            GroupListGrid.Visibility = Visibility.Visible;
            PeerColumn.Width = new GridLength(150);
        }
Exemplo n.º 7
0
        private void GroupSelectedAction(IGroupObject groupObject, bool isSelected)
        {
            MessageAlertClear(groupObject);

            TypingStatusLabel.Content = "";

            if (isSelected)
            {
                SelectGroupControl(groupObject);
                ScrollChatBox();
                TextToSend.Focus();
            }
        }
Exemplo n.º 8
0
        private void GroupDeleteAction(IGroupObject groupObject)
        {
            ViewModel.ChatCollection.Remove(groupObject);
            int groupNumber = groupObject.ChatNumber;
            if (groupdic.ContainsKey(groupNumber))
            {
                groupdic.Remove(groupNumber);

                if (groupObject.Selected)
                    ChatBox.Document = null;
            }

            if (tox.GetGroupType(groupNumber) == ToxGroupType.Av && call != null)
            {
                call.Stop();
                call = null;
            }

            tox.DeleteGroupChat(groupNumber);

            groupObject.SelectedAction = null;
            groupObject.DeleteAction = null;

            MicButton.IsChecked = false;
        }
Exemplo n.º 9
0
        private async void ChangeTitleAction(IGroupObject groupObject)
        {
            string title = await this.ShowInputAsync("Change group title", "Enter a new title for this group.", new MetroDialogSettings() { DefaultText = tox.GetGroupTitle(groupObject.ChatNumber) });
            if (string.IsNullOrEmpty(title))
                return;

            if (tox.SetGroupTitle(groupObject.ChatNumber, title))
            {
                groupObject.Name = title;
                groupObject.AdditionalInfo = string.Format("Topic set by: {0}", tox.Name);
            }
        }