Exemplo n.º 1
0
        private async Task AddMessage(ChatMessageViewModel message)
        {
            await messageUpdateLock.WaitAsync();

            ChatMessageControl messageControl = new ChatMessageControl(message);

            if (ChannelSession.Settings.LatestChatAtTop)
            {
                this.MessageControls.Insert(0, messageControl);
            }
            else
            {
                this.MessageControls.Add(messageControl);
            }
            this.totalMessages++;

            while (this.MessageControls.Count > ChannelSession.Settings.MaxMessagesInChat)
            {
                if (ChannelSession.Settings.LatestChatAtTop)
                {
                    this.MessageControls.RemoveAt(this.MessageControls.Count - 1);
                }
                else
                {
                    this.MessageControls.RemoveAt(0);
                }
            }

            messageUpdateLock.Release();
        }
Exemplo n.º 2
0
        private async Task AddMessage(ChatMessageViewModel message)
        {
            await this.messageUpdateLock.WaitAndRelease(() =>
            {
                ChatMessageControl messageControl = new ChatMessageControl(message);
                if (ChannelSession.Settings.LatestChatAtTop)
                {
                    this.MessageControls.Insert(0, messageControl);
                }
                else
                {
                    this.MessageControls.Add(messageControl);
                }
                this.totalMessages++;

                while (this.MessageControls.Count > ChannelSession.Settings.MaxMessagesInChat)
                {
                    if (ChannelSession.Settings.LatestChatAtTop)
                    {
                        this.MessageControls.RemoveAt(this.MessageControls.Count - 1);
                    }
                    else
                    {
                        this.MessageControls.RemoveAt(0);
                    }
                }

                Logger.LogChatEvent(message.ToString());

                return(Task.FromResult(0));
            });
        }
Exemplo n.º 3
0
 private void MessageCopyMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (this.ChatList.SelectedItem != null)
     {
         ChatMessageControl control = (ChatMessageControl)this.ChatList.SelectedItem;
         Clipboard.SetText(control.Message.Message);
     }
 }
Exemplo n.º 4
0
 private async void MessageUserInformationMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (this.ChatList.SelectedItem != null)
     {
         ChatMessageControl control = (ChatMessageControl)this.ChatList.SelectedItem;
         await this.ShowUserDialog(control.Message.User);
     }
 }
Exemplo n.º 5
0
        private void ChatClient_OnDeleteMessageOccurred(object sender, Guid messageID)
        {
            ChatMessageControl message = this.MessageControls.FirstOrDefault(msg => msg.Message.ID.Equals(messageID));

            if (message != null)
            {
                message.DeleteMessage();
            }
        }
Exemplo n.º 6
0
 private async void MessageDeleteMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (this.ChatList.SelectedItem != null)
     {
         ChatMessageControl control = (ChatMessageControl)this.ChatList.SelectedItem;
         if (!control.Message.IsWhisper)
         {
             await ChannelSession.Chat.DeleteMessage(control.Message.ID);
         }
     }
 }
Exemplo n.º 7
0
 private void MessageCopyMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (this.ChatList.SelectedItem != null)
     {
         ChatMessageControl control = (ChatMessageControl)this.ChatList.SelectedItem;
         try
         {
             Clipboard.SetText(control.Message.Message);
         }
         catch (Exception ex) { Logger.Log(ex); }
     }
 }
Exemplo n.º 8
0
 private void MessageWhisperUserMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (this.ChatList.SelectedItem != null)
     {
         ChatMessageControl control = (ChatMessageControl)this.ChatList.SelectedItem;
         if (control.Message.User != null)
         {
             this.ChatMessageTextBox.Text = $"/w @{control.Message.User.UserName} ";
             this.ChatMessageTextBox.Focus();
             this.ChatMessageTextBox.CaretIndex = this.ChatMessageTextBox.Text.Length;
         }
     }
 }
Exemplo n.º 9
0
        private async void ChatClient_OnDeleteMessageOccurred(object sender, Guid messageID)
        {
            await this.Dispatcher.InvokeAsync <Task>(async() =>
            {
                await this.messageUpdateLock.WaitAsync();

                ChatMessageControl message = this.MessageControls.FirstOrDefault(msg => msg.Message.ID.Equals(messageID));
                if (message != null)
                {
                    message.DeleteMessage();
                }

                this.messageUpdateLock.Release();
            });
        }
Exemplo n.º 10
0
 private async void ChatClient_OnDeleteMessageOccurred(object sender, ChatDeleteMessageEventModel deleteEvent)
 {
     await this.Dispatcher.InvokeAsync <Task>(async() =>
     {
         await this.messageUpdateLock.WaitAndRelease(() =>
         {
             ChatMessageControl message = this.MessageControls.FirstOrDefault(msg => msg.Message.ID.Equals(deleteEvent.id));
             if (message != null)
             {
                 message.DeleteMessage(deleteEvent.moderator?.user_name);
                 if (ChannelSession.Settings.HideDeletedMessages)
                 {
                     this.MessageControls.Remove(message);
                 }
             }
             return(Task.FromResult(0));
         });
     });
 }
Exemplo n.º 11
0
        private async Task AddMessage(ChatMessageViewModel message)
        {
            await messageUpdateLock.WaitAsync();

            ScrollViewer scrollViewer = VisualTreeHelpers.GetVisualChild <ScrollViewer>(this.ChatList);

            if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight)
            {
                this.updateScrollingToLatest = true;
            }

            ChatMessageControl messageControl = new ChatMessageControl(message);

            this.totalMessages++;
            this.MessageControls.Add(messageControl);
            while (this.MessageControls.Count > ChannelSession.Settings.MaxMessagesInChat)
            {
                this.MessageControls.RemoveAt(0);
            }

            messageUpdateLock.Release();
        }