Beispiel #1
0
        public void ClearChat(bool removeMessages)
        {
            if (removeMessages)
            {
                var _messages = Messages;

                lock (MessageLock)
                {
                    Messages = new Message[0];
                }

                MessagesRemovedAtStart?.Invoke(this, new ValueEventArgs <Message[]>(_messages));
            }
            else
            {
                lock (MessageLock)
                {
                    foreach (var message in Messages)
                    {
                        message.Disabled = true;
                    }
                }

                AddMessage(new Message("Chat has been cleared by a moderator.", HSLColor.Gray, true));
            }
        }
Beispiel #2
0
        private void AppSettings_MessageLimitChanged(object sender, EventArgs e)
        {
            Message[] _messages = null;

            lock (MessageLock)
            {
                if (Messages.Length > AppSettings.ChatMessageLimit)
                {
                    _messages = new Message[Messages.Length - AppSettings.ChatMessageLimit];
                    Array.Copy(Messages, _messages, _messages.Length);

                    var M = new Message[AppSettings.ChatMessageLimit];
                    Array.Copy(Messages, Messages.Length - AppSettings.ChatMessageLimit, M, 0,
                               AppSettings.ChatMessageLimit);

                    Messages = M;
                }
            }

            if (_messages != null)
            {
                MessagesRemovedAtStart?.Invoke(this, new ValueEventArgs <Message[]>(_messages));
            }
        }