Inheritance: System.EventArgs
Beispiel #1
0
        private void OnGetChatMessage(Packet packet)
        {
            var message = packet.DataAsString();

            if (packet.Opcode == Opcode.ChatMessage)
            {
                GotChatResponse = true;
                if (message.Trim() == "Server received, But no response!!")
                {
                    return;
                }
                string[] messages = message.Split('\n');
                foreach (string newMessage in messages)
                {
                    if (string.IsNullOrWhiteSpace(newMessage))
                    {
                        continue;
                    }
                    string[] splitMessage = newMessage.Split(new char[] { ':' }, 2);

                    if (newMessage.StartsWith("SERVER:") && newMessage == "SERVER: " + LastSentAdminMessage)
                    {
                        if (SentMessageUpdated != null)
                        {
                            var chatLog = new ChatLogEventArgs()
                            {
                                Timestamp = packet.Timestamp,
                                IsAdmin   = true
                            };
                            chatLog.Message = newMessage.Replace("SERVER: ", "");
                            SentMessageUpdated(this, chatLog);
                        }
                    }
                    else
                    {
                        if (ChatLogUpdated != null)
                        {
                            var chatLog = new ChatLogEventArgs()
                            {
                                Message   = splitMessage[1],
                                Sender    = splitMessage[0],
                                Timestamp = packet.Timestamp,
                                IsAdmin   = false
                            };
                            ChatLogUpdated(this, chatLog);
                        }
                    }
                }
            }
        }
        private void AddTextRecieved(ChatLogEventArgs args)
        {
            var message = new ChatMessage
            {
                PrevSide = _curside,
                SenderName = args.Sender,
                Text = args.Message,
                Side = MessageSide.You
            };

            if (ChatSettings.IsTimestampingEnabled)
                message.Timestamp = args.Timestamp;

            ChatMessages.Add(message);
            _curside = MessageSide.You;
            if (ChatSettings.IsAutoScrollEnabled)
            {
                View.ScrollConversationToEnd();
            }

            try
            {
                if (!ChatSettings.IsNotificationsEnabled || ChatSettings.NotificationString == null) return;

                if (ChatSettings.NotificationWords.Any(s => message.Text.Contains(s)))
                {
                    ShowCustomBalloon($"{message.SenderName}: {message.Text}");
                }

                if (ChatSettings.IsFlashWindowNotificationEnabled)
                    Application.Current.MainWindow.FlashWindow();

                if (!ChatSettings.IsNotificationSoundFileEnabled || ChatSettings.NotificationSoundFile == null) return;
                    SoundManager.PlayFile(ChatSettings.NotificationSoundFile);
            }
            catch (Exception ex)
            {
                App.LogErrorMessage(ex);
            }
        }
 private void AddTextSend(ChatLogEventArgs args)
 {
     var message = new ChatMessage { PrevSide = _curside };
     if (ChatSettings.IsCustomServerConsoleNameEnabled)
         message.SenderName = string.IsNullOrWhiteSpace(ChatSettings.CustomServerConsoleName) ? "Server Admin" : ChatSettings.CustomServerConsoleName;
     else
         message.SenderName = "Server Admin";
     message.Text = args.Message;
     message.Side = MessageSide.Me;
     if (ChatSettings.IsTimestampingEnabled)
         message.Timestamp = args.Timestamp;
     ChatMessages.Add(message);
     _curside = MessageSide.Me;
     if (ChatSettings.IsAutoScrollEnabled)
     {
         View.ScrollConversationToEnd();
     }
 }
        private void addTextRecieved(ChatLogEventArgs args)
        {
            var message = new ChatMessage();
            message.PrevSide = curside;
            message.SenderName = args.Sender;
            message.Text = args.Message;
            message.Side = MessageSide.You;

            if (ChatSettings.IsTimestampingEnabled)
                message.Timestamp = args.Timestamp;

            ChatMessages.Add(message);
            curside = MessageSide.You;
            if (ChatSettings.IsAutoScrollEnabled)
            {
                View.ScrollConversationToEnd();
            }
        }
        private void OnGetChatMessage(Packet packet)
        {
            var message = packet.DataAsString();
            if (packet.Opcode == Opcode.ChatMessage)
            {
                GotChatResponse = true;
                if (message.Trim() == "Server received, But no response!!") return;
                string[] messages = message.Split('\n');
                foreach (string newMessage in messages)
                {
                    if (string.IsNullOrWhiteSpace(newMessage)) continue;
                    string[] splitMessage = newMessage.Split(new char[] { ':' }, 2);

                    if (newMessage.StartsWith("SERVER:") && newMessage == "SERVER: " + LastSentAdminMessage)
                    {
                        if (SentMessageUpdated != null)
                        {
                            var chatLog = new ChatLogEventArgs()
                            {
                                Timestamp = packet.Timestamp,
                                IsAdmin = true
                            };
                            chatLog.Message = newMessage.Replace("SERVER: ", "");
                            SentMessageUpdated(this, chatLog);
                        }
                    }
                    else
                    {
                        if (ChatLogUpdated != null)
                        {
                            var chatLog = new ChatLogEventArgs()
                            {
                                Message = splitMessage[1],
                                Sender = splitMessage[0],
                                Timestamp = packet.Timestamp,
                                IsAdmin = false
                            };
                            ChatLogUpdated(this, chatLog);
                        }
                    }
                }
                    
            }
        }