Exemple #1
0
        private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string message)
        {
            if (showTimestamps)
            {
                textPrinter.ForeColor = SystemColors.GrayText;
                textPrinter.PrintText(timestamp.ToString("[HH:mm] "));
            }

            textPrinter.ForeColor = SystemColors.WindowText;

            if (instance.GlobalSettings["av_name_link"])
            {
                textPrinter.InsertLink(fromName, string.Format("secondlife:///app/agent/{0}/about", fromID));
            }
            else
            {
                textPrinter.PrintText(fromName);
            }

            StringBuilder sb = new StringBuilder();

            if (message.StartsWith("/me "))
            {
                sb.Append(message.Substring(3));
            }
            else
            {
                sb.Append(": ");
                sb.Append(message);
            }

            instance.LogClientMessage(sessionName + ".txt", fromName + sb.ToString());
            textPrinter.PrintTextLine(sb.ToString());
        }
        public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
        {
            if (ChatLineAdded != null)
            {
                ChatLineAdded(this, new ChatLineAddedArgs(item));
            }

            lock (SyncChat)
            {
                instance.LogClientMessage("chat.txt", item.From + item.Text);
                if (addToBuffer)
                {
                    textBuffer.Add(item);
                }

                if (showTimestamps)
                {
                    if (fontSettings.ContainsKey("Timestamp"))
                    {
                        var fontSetting = fontSettings["Timestamp"];
                        textPrinter.ForeColor = fontSetting.ForeColor;
                        textPrinter.BackColor = fontSetting.BackColor;
                        textPrinter.Font      = fontSetting.Font;
                        textPrinter.PrintText(item.Timestamp.ToString("[HH:mm] "));
                    }
                    else
                    {
                        textPrinter.ForeColor = SystemColors.GrayText;
                        textPrinter.BackColor = Color.Transparent;
                        textPrinter.Font      = Settings.FontSetting.DefaultFont;
                        textPrinter.PrintText(item.Timestamp.ToString("[HH:mm] "));
                    }
                }

                if (fontSettings.ContainsKey("Name"))
                {
                    var fontSetting = fontSettings["Name"];
                    textPrinter.ForeColor = fontSetting.ForeColor;
                    textPrinter.BackColor = fontSetting.BackColor;
                    textPrinter.Font      = fontSetting.Font;
                }
                else
                {
                    textPrinter.ForeColor = SystemColors.WindowText;
                    textPrinter.BackColor = Color.Transparent;
                    textPrinter.Font      = Settings.FontSetting.DefaultFont;
                }

                if (item.Style == ChatBufferTextStyle.Normal && item.ID != UUID.Zero && instance.GlobalSettings["av_name_link"])
                {
                    textPrinter.InsertLink(item.From, string.Format("secondlife:///app/agent/{0}/about", item.ID));
                }
                else
                {
                    textPrinter.PrintText(item.From);
                }

                if (fontSettings.ContainsKey(item.Style.ToString()))
                {
                    var fontSetting = fontSettings[item.Style.ToString()];
                    textPrinter.ForeColor = fontSetting.ForeColor;
                    textPrinter.BackColor = fontSetting.BackColor;
                    textPrinter.Font      = fontSetting.Font;
                }
                else
                {
                    textPrinter.ForeColor = SystemColors.WindowText;
                    textPrinter.BackColor = Color.Transparent;
                    textPrinter.Font      = Settings.FontSetting.DefaultFont;
                }
                textPrinter.PrintTextLine(item.Text);
            }
        }
        public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
        {
            if (ChatLineAdded != null)
            {
                ChatLineAdded(this, new ChatLineAddedArgs(item));
            }

            lock (SyncChat)
            {
                instance.LogClientMessage("chat.txt", item.From + item.Text);
                if (addToBuffer)
                {
                    textBuffer.Add(item);
                }

                if (showTimestamps)
                {
                    textPrinter.ForeColor = SystemColors.GrayText;
                    textPrinter.PrintText(item.Timestamp.ToString("[HH:mm] "));
                }

                switch (item.Style)
                {
                case ChatBufferTextStyle.Normal:
                    textPrinter.ForeColor = SystemColors.WindowText;
                    break;

                case ChatBufferTextStyle.StatusBlue:
                    textPrinter.ForeColor = Color.Blue;
                    break;

                case ChatBufferTextStyle.StatusDarkBlue:
                    textPrinter.ForeColor = Color.DarkBlue;
                    break;

                case ChatBufferTextStyle.LindenChat:
                    textPrinter.ForeColor = Color.DarkGreen;
                    break;

                case ChatBufferTextStyle.ObjectChat:
                    textPrinter.ForeColor = Color.DarkCyan;
                    break;

                case ChatBufferTextStyle.StartupTitle:
                    textPrinter.ForeColor = SystemColors.WindowText;
                    textPrinter.Font      = new Font(textPrinter.Font, FontStyle.Bold);
                    break;

                case ChatBufferTextStyle.Alert:
                    textPrinter.ForeColor = Color.DarkRed;
                    break;

                case ChatBufferTextStyle.Error:
                    textPrinter.ForeColor = Color.Red;
                    break;

                case ChatBufferTextStyle.OwnerSay:
                    textPrinter.ForeColor = Color.FromArgb(255, 180, 150, 0);
                    break;
                }

                if (item.Style == ChatBufferTextStyle.Normal && item.ID != UUID.Zero && instance.GlobalSettings["av_name_link"])
                {
                    textPrinter.InsertLink(item.From, string.Format("secondlife:///app/agent/{0}/about", item.ID));
                    textPrinter.PrintTextLine(item.Text);
                }
                else
                {
                    textPrinter.PrintTextLine(item.From + item.Text);
                }
            }
        }
Exemple #4
0
        private void PrintIM(DateTime timestamp, string fromName, UUID fromID, string message, bool isNewMessage)
        {
            if (showTimestamps)
            {
                if (fontSettings.ContainsKey("Timestamp"))
                {
                    var fontSetting = fontSettings["Timestamp"];
                    textPrinter.ForeColor = fontSetting.ForeColor;
                    textPrinter.BackColor = fontSetting.BackColor;
                    textPrinter.Font      = fontSetting.Font;
                    textPrinter.PrintText(DateTime.Now.ToString("[HH:mm] "));
                }
                else
                {
                    textPrinter.ForeColor = SystemColors.GrayText;
                    textPrinter.BackColor = Color.Transparent;
                    textPrinter.Font      = Settings.FontSetting.DefaultFont;
                    textPrinter.PrintText(DateTime.Now.ToString("[HH:mm] "));
                }
            }

            if (fontSettings.ContainsKey("Name"))
            {
                var fontSetting = fontSettings["Name"];
                textPrinter.ForeColor = fontSetting.ForeColor;
                textPrinter.BackColor = fontSetting.BackColor;
                textPrinter.Font      = fontSetting.Font;
            }
            else
            {
                textPrinter.ForeColor = SystemColors.WindowText;
                textPrinter.BackColor = Color.Transparent;
                textPrinter.Font      = Settings.FontSetting.DefaultFont;
            }

            if (instance.GlobalSettings["av_name_link"])
            {
                textPrinter.InsertLink(fromName, string.Format("secondlife:///app/agent/{0}/about", fromID));
            }
            else
            {
                textPrinter.PrintText(fromName);
            }

            StringBuilder sb = new StringBuilder();

            if (message.StartsWith("/me "))
            {
                if (fontSettings.ContainsKey("Emote"))
                {
                    var fontSetting = fontSettings["Emote"];
                    textPrinter.ForeColor = fontSetting.ForeColor;
                    textPrinter.BackColor = fontSetting.BackColor;
                    textPrinter.Font      = fontSetting.Font;
                }
                else
                {
                    textPrinter.ForeColor = SystemColors.WindowText;
                    textPrinter.BackColor = Color.Transparent;
                    textPrinter.Font      = Settings.FontSetting.DefaultFont;
                }

                sb.Append(message.Substring(3));
            }
            else
            {
                if (fromID == instance.Client.Self.AgentID)
                {
                    if (fontSettings.ContainsKey("OutgoingIM"))
                    {
                        var fontSetting = fontSettings["OutgoingIM"];
                        textPrinter.ForeColor = fontSetting.ForeColor;
                        textPrinter.BackColor = fontSetting.BackColor;
                        textPrinter.Font      = fontSetting.Font;
                    }
                    else
                    {
                        textPrinter.ForeColor = SystemColors.WindowText;
                        textPrinter.BackColor = Color.Transparent;
                        textPrinter.Font      = Settings.FontSetting.DefaultFont;
                    }
                }
                else
                {
                    if (fontSettings.ContainsKey("IncomingIM"))
                    {
                        var fontSetting = fontSettings["IncomingIM"];
                        textPrinter.ForeColor = fontSetting.ForeColor;
                        textPrinter.BackColor = fontSetting.BackColor;
                        textPrinter.Font      = fontSetting.Font;
                    }
                    else
                    {
                        textPrinter.ForeColor = SystemColors.WindowText;
                        textPrinter.BackColor = Color.Transparent;
                        textPrinter.Font      = Settings.FontSetting.DefaultFont;
                    }
                }

                sb.Append(": ");
                sb.Append(message);
            }

            if (isNewMessage)
            {
                instance.LogClientMessage(sessionName + ".txt", fromName + sb.ToString());
            }

            textPrinter.PrintTextLine(sb.ToString());
        }