Exemplo n.º 1
0
        public void DisplayNotification(string message)
        {
            if (instance.MainForm.InvokeRequired)
            {
                instance.MainForm.Invoke(new System.Windows.Forms.MethodInvoker(() => DisplayNotification(message)));
                return;
            }

            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("Notification"))
            {
                var fontSetting = fontSettings["Notification"];
                TextPrinter.ForeColor = fontSetting.ForeColor;
                TextPrinter.BackColor = fontSetting.BackColor;
                TextPrinter.Font      = fontSetting.Font;
            }
            else
            {
                TextPrinter.ForeColor = Color.DarkCyan;
                TextPrinter.BackColor = Color.Transparent;
                TextPrinter.Font      = Settings.FontSetting.DefaultFont;
            }

            instance.LogClientMessage(sessionName + ".txt", message);
            TextPrinter.PrintTextLine(message);
        }
Exemplo n.º 2
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, $"secondlife:///app/agent/{fromID}/about");
            }
            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);
            }

            TextPrinter.PrintTextLine(sb.ToString());
        }
Exemplo n.º 3
0
        public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
        {
            ChatLineAdded?.Invoke(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, $"secondlife:///app/agent/{item.ID}/about");
                }
                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);
            }
        }