Ejemplo n.º 1
0
        public void AddChatMessage(ChatMessage chatMessage)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                if (Filtered(chatMessage))
                {
                    return;
                }

                if (chatMessage is LfgMessage lm && !SettingsHolder.DisableLfgChatMessages)
                {
                    lm.LinkLfg();
                }

                chatMessage.SplitSimplePieces();

                if (ChatWindows.All(x => !x.IsPaused))
                {
                    ChatMessages.Insert(0, chatMessage);
                }
                else
                {
                    _pauseQueue.Enqueue(chatMessage);
                }

                NewMessage?.Invoke(chatMessage);
                if (ChatMessages.Count > SettingsHolder.MaxMessages)
                {
                    var toRemove = ChatMessages[ChatMessages.Count - 1];
                    toRemove.Dispose();
                    ChatMessages.RemoveAt(ChatMessages.Count - 1);
                }
                N(nameof(MessageCount));
            }), DispatcherPriority.DataBind);
        }
Ejemplo n.º 2
0
        public void AddChatMessage(ChatMessage chatMessage)
        {
            if (!App.Settings.ChatEnabled)
            {
                return;
            }

            Dispatcher.InvokeAsync(() =>
            {
                if (Filtered(chatMessage))
                {
                    return;
                }

                if (chatMessage is LfgMessage lm && !App.Settings.DisableLfgChatMessages)
                {
                    lm.LinkListing();
                }

                chatMessage.SplitSimplePieces();

                if (ChatWindows.All(x => !x.IsPaused))
                {
#if BATCH
                    _mainQueue.Enqueue(chatMessage);
#else
                    ChatMessages.Insert(0, chatMessage);
#endif
                }
                else
                {
                    _pauseQueue.Enqueue(chatMessage);
                    N(nameof(QueuedMessagesCount));
                }

                NewMessage?.Invoke(chatMessage);
#if BATCH
#else
                if (ChatMessages.Count > App.Settings.MaxMessages)
                {
                    var toRemove = ChatMessages[ChatMessages.Count - 1];
                    toRemove.Dispose();
                    ChatMessages.RemoveAt(ChatMessages.Count - 1);
                }

                N(nameof(MessageCount));
#endif
            }, DispatcherPriority.DataBind);
        }