Esempio n. 1
0
 public void WriteMessage(ChatMessage message, bool autoscroll)
 {
     if (InvokeRequired)
     {
         this.Invoke(new Action<ChatMessage,bool>(WriteMessage), message,autoscroll);
     }
     else
     {
         ChatHelper.WriteMessage(message, ChatLog, autoscroll);
     }
 }
Esempio n. 2
0
        public void WriteMessage(ChatMessage message)
        {
            if (InvokeRequired)
            {
                this.Invoke(new Action<ChatMessage>(WriteMessage), message);
            }
            else
            {
                ChatHelper.WriteMessage(message, ChatLog, true);

                if(message.From != null)
                    if(message.From.Username != Program.UserInfo.Username && !ChatInput.Focused)
                        FlashWindow.Start(this);
            }
        }
Esempio n. 3
0
        private void NewMessage(ChatMessage message)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<ChatMessage>(NewMessage), message);
            }
            else
            {
                if (message.Type == MessageType.PrivateMessage ||
                    message.Type == MessageType.Message ||
                    message.Type == MessageType.Me)
                {
                    if (IgnoreContainsUser(message.From.Username))
                        return;
                }

                if (Program.Config.PmWindows && message.Type == MessageType.PrivateMessage)
                {
                    if (PmWindows.ContainsKey(message.Channel))
                    {
                        PmWindows[message.Channel].WriteMessage(message);
                    }
                    else
                    {
                        PmWindows.Add(message.Channel, new PmWindow_frm(message.Channel, true,server));
                        PmWindows[message.Channel].WriteMessage(message);
                        PmWindows[message.Channel].Show();
                        PmWindows[message.Channel].FormClosed += Chat_frm_FormClosed;
                    }

                }
                else
                {

                    ChatWindow window = GetChatWindow(message.Channel);
                    if (window == null)
                    {
                        ChatTabs.TabPages.Add(new ChatWindow(message.Channel, true));
                        window = GetChatWindow(message.Channel);
                        window.WriteMessage(message);
                    }
                    else
                    {
                        window.WriteMessage(message);
                    }

                    if (ChatTabs.SelectedTab.Name != window.Name && window.isprivate)
                        SystemSounds.Beep.Play();
                }
            }
        }
Esempio n. 4
0
        public void WriteMessage(ChatMessage message)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<ChatMessage>(WriteMessage), message);
                return;
            }

            if(message.From != null && IgnoreList.Items.Contains(message.From.Username))
            {
                return;
            }

            ChatWindow window = null;
            if (message.Type == MessageType.Server || message.Type == MessageType.System)
            {
                window = (ChatWindow)ChannelTabs.SelectedTab;
                if (window == null)
                {
                    window = new ChatWindow(message.Type.ToString(), true) { issystemtab = true};
                    ChannelTabs.TabPages.Add(window);
                }
            }
            else if (message.Type == MessageType.Join || message.Type == MessageType.Leave || message.Channel == null)
            {
                window = GetChatWindow(message.Channel) ?? (ChatWindow)ChannelTabs.SelectedTab;
                if (window == null)
                {
                    window = new ChatWindow(message.Type.ToString(), true) { issystemtab = true };
                    ChannelTabs.TabPages.Add(window);
                }
            }
            else if (message.Type == MessageType.PrivateMessage && Program.Config.PmWindows)
            {
                if (_pmWindows.ContainsKey(message.Channel))
                {
                    _pmWindows[message.Channel].WriteMessage(message);
                }
                else
                {
                    _pmWindows.Add(message.Channel, new PmWindow_frm(message.Channel, true, Program.ChatServer));
                    _pmWindows[message.Channel].WriteMessage(message);
                    _pmWindows[message.Channel].Show();
                    _pmWindows[message.Channel].FormClosed += Chat_frm_FormClosed;
                }
            }
            else if (message.Type == MessageType.Team)
            {
                window = GetChatWindow(message.Type.ToString());
                if (window == null)
                {
                    window = new ChatWindow(message.Type.ToString(), message.Type == MessageType.PrivateMessage);
                    ChannelTabs.TabPages.Add(window);
                }
            }

            window = window ?? GetChatWindow(message.Channel);
            if(window == null)
            {
                window = new ChatWindow(message.Channel, message.Type == MessageType.PrivateMessage);
                ChannelTabs.TabPages.Add(window);
            }

            window.WriteMessage(message, autoscroll);
        }
Esempio n. 5
0
        public void WriteMessage(ChatMessage message)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<ChatMessage>(WriteMessage), message);
            }
            else
            {
                if(message.From != null)
                    if (IgnoreList.Items.Contains(message.From.Username))
                        return;

                if (message.Type == MessageType.Server || message.Type == MessageType.System)
                {
                    ChatWindow window = (ChatWindow)ChannelTabs.SelectedTab;
                    if (window == null)
                    {
                        ChannelTabs.TabPages.Add(new ChatWindow(message.Type.ToString(), true) { issystemtab = true});
                        GetChatWindow(message.Type.ToString()).WriteMessage(message, autoscroll);
                    }
                    else
                        window.WriteMessage(message, autoscroll);
                }
                else if (message.Type == MessageType.Join || message.Type == MessageType.Leave || message.Channel == null)
                {
                    if (GetChatWindow(message.Channel) != null)
                    {
                        GetChatWindow(message.Channel).WriteMessage(message, autoscroll);
                    }
                    else
                    {
                        ChatWindow window = (ChatWindow)ChannelTabs.SelectedTab;
                        if (window == null)
                        {
                            ChannelTabs.TabPages.Add(new ChatWindow(message.Type.ToString(), true) { issystemtab = true });
                            GetChatWindow(message.Type.ToString()).WriteMessage(message, autoscroll);
                        }
                        else
                            window.WriteMessage(message, autoscroll);
                    }
                }
                else if (message.Type == MessageType.PrivateMessage && Program.Config.PmWindows)
                {
                    if (PMWindows.ContainsKey(message.Channel))
                    {
                        PMWindows[message.Channel].WriteMessage(message);
                    }
                    else
                    {
                        PMWindows.Add(message.Channel, new PmWindow_frm(message.Channel, true, Program.ChatServer));
                        PMWindows[message.Channel].WriteMessage(message);
                        PMWindows[message.Channel].Show();
                        PMWindows[message.Channel].FormClosed += Chat_frm_FormClosed;
                    }
                }
                else if (message.Type == MessageType.Team)
                {
                    if (GetChatWindow(message.Type.ToString()) != null)
                    {
                        GetChatWindow(message.Type.ToString()).WriteMessage(message, autoscroll);
                    }
                    else
                    {
                        ChannelTabs.TabPages.Add(new ChatWindow(message.Type.ToString(), (message.Type == MessageType.PrivateMessage ? true : false)));
                        GetChatWindow(message.Type.ToString()).WriteMessage(message, autoscroll);
                    }
                }
                else if (GetChatWindow(message.Channel) != null)
                    GetChatWindow(message.Channel).WriteMessage(message, autoscroll);
                else
                {
                    ChannelTabs.TabPages.Add(new ChatWindow(message.Channel, (message.Type == MessageType.PrivateMessage ? true : false)));
                    GetChatWindow(message.Channel).WriteMessage(message, autoscroll);
                }
            }
        }
Esempio n. 6
0
        public static void WriteMessage(ChatMessage message, CustomRTB window,bool autoscroll)
        {
            if (window.Text != "")//start a new line unless theres no text
                window.AppendText(Environment.NewLine);
            window.Select(window.TextLength, 0);

            if (message.Command == CommandType.Me)
            {
                WriteText(window, message.FormattedMessage, Program.Config.MeMsgColor.ToColor());
            }
            else if (message.Type == MessageType.Team && message.Command == CommandType.TeamServerMessage)
            {
                WriteText(window, "[TeamMessage] " + message.FormattedMessage,(Program.Config.ColorBlindMode ? Color.Black : Program.Config.ServerMsgColor.ToColor()));
            }
            else if (message.Type == MessageType.Message || message.Type == MessageType.PrivateMessage || message.Type == MessageType.Team)
            {
                if (Program.Config.ShowTimeStamp)
                    WriteText(window, message.Time.ToString("[HH:mm] "), (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                if (message.From.Rank > 0)
                {
                    WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                    WriteText(window, "Dev", (Program.Config.ColorBlindMode ? Color.Black : message.RankColor));
                    WriteText(window, "]", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                }
                WriteText(window, "[", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));
                if (Program.Config.UsernameColors)
                {
                    if (message.From.UserColor.ToArgb() == Color.Black.ToArgb())
                    {
                        WriteText(window, message.From.Username,
                            (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                    }
                    else
                    {
                        WriteText(window, message.From.Username,
                            (Program.Config.ColorBlindMode ? Color.Black : message.From.UserColor));
                    }
                }
                else
                {
                    WriteText(window, message.From.Username,
                        (Program.Config.ColorBlindMode ? Color.Black : Program.Config.Level0Color.ToColor()));
                }
                WriteText(window, "]: ", (Program.Config.ColorBlindMode ? Color.Black : Program.Config.NormalTextColor.ToColor()));

                if (message.From.Rank == 0)
                    WriteText(window, message.FormattedMessage.Trim(), (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor));
                else
                    FormatText(message.FormattedMessage.Trim(), window);

            }
            else if (message.Type == MessageType.System || message.Type == MessageType.Server)
            {
                WriteText(window, "[" + message.Type + "] " + message.FormattedMessage,
                        (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor));
            }
            else
            {
                WriteText(window, (Program.Config.ColorBlindMode ? "[" + message.Type + "] " + message.FormattedMessage : message.FormattedMessage),
                    (Program.Config.ColorBlindMode ? Color.Black : message.MessageColor));
            }

            window.SelectionStart = window.TextLength;
            window.SelectionLength = 0;

            if (autoscroll)
                window.ScrollToCaret();
        }