Exemplo n.º 1
0
        public void PrintStartupMessage()
        {
            ChatBufferItem title = new ChatBufferItem(
                DateTime.Now, "",
                UUID.Zero,
                Properties.Resources.RadegastTitle + " " + Assembly.GetExecutingAssembly().GetName().Version,
                ChatBufferTextStyle.StartupTitle);

            ChatBufferItem ready = new ChatBufferItem(
                DateTime.Now, "", UUID.Zero, "Ready.", ChatBufferTextStyle.StatusBlue);

            ProcessBufferItem(title, true);
            ProcessBufferItem(ready, true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Displays notification in the main chat tab
        /// </summary>
        /// <param name="msg">Message to be printed in the chat tab</param>
        /// <param name="style">Style of the message to be printed, normal, object, etc.</param>
        /// <param name="highlightChatTab">Highligt (and flash in taskbar) chat tab if not selected</param>
        public void DisplayNotificationInChat(string msg, ChatBufferTextStyle style, bool highlightChatTab)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                {
                    BeginInvoke(new MethodInvoker(() => DisplayNotificationInChat(msg, style, highlightChatTab)));
                }
                return;
            }

            if (style != ChatBufferTextStyle.Invisible)
            {
                ChatBufferItem line = new ChatBufferItem(
                    DateTime.Now,
                    string.Empty,
                    UUID.Zero,
                    msg,
                    style
                    );

                try
                {
                    mainChatManger.ProcessBufferItem(line, true);
                    if (highlightChatTab)
                    {
                        tabs["chat"].Highlight();
                    }
                }
                catch (Exception) { }
            }

            if (OnChatNotification != null)
            {
                try { OnChatNotification(this, new ChatNotificationEventArgs(msg, style)); }
                catch { }
            }
        }
Exemplo n.º 3
0
 public ChatLineAddedArgs(ChatBufferItem item)
 {
     mItem = item;
 }
Exemplo n.º 4
0
        //Used only for non-public chat
        private void ProcessOutgoingChat(ChatSentEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            switch (e.Type)
            {
                case ChatType.Normal:
                    sb.Append(": ");
                    break;

                case ChatType.Whisper:
                    sb.Append(" whisper: ");
                    break;

                case ChatType.Shout:
                    sb.Append(" shout: ");
                    break;
            }

            sb.Append(e.Message);

            ChatBufferItem item = new ChatBufferItem(
                DateTime.Now, string.Format("(channel {0}) {1}", e.Channel, client.Self.Name), client.Self.AgentID, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue);

            ProcessBufferItem(item, true);

            sb = null;
        }
Exemplo n.º 5
0
        private void ProcessIncomingChat(ChatEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message)) return;

            // Check if the sender agent is muted
            if (e.SourceType == ChatSourceType.Agent &&
                null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID)
                ) return;

            // Check if sender object is muted
            if (e.SourceType == ChatSourceType.Object &&
                null != client.Self.MuteList.Find(me =>
                    (me.Type == MuteType.Resident && me.ID == e.OwnerID) // Owner muted
                    || (me.Type == MuteType.Object && me.ID == e.SourceID) // Object muted by ID
                    || (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name
                )) return;

            if (instance.RLV.Enabled && e.Message.StartsWith("@"))
            {
                instance.RLV.TryProcessCMD(e);
            #if !DEBUG
                return;
            #endif
            }

            ChatBufferItem item = new ChatBufferItem();
            item.ID = e.SourceID;
            item.RawMessage = e;
            StringBuilder sb = new StringBuilder();

            if (e.SourceType == ChatSourceType.Agent)
            {
                item.From = instance.Names.Get(e.SourceID, e.FromName);
            }
            else
            {
                item.From = e.FromName;
            }

            bool isEmote = e.Message.ToLower().StartsWith("/me ");

            if (!isEmote)
            {
                switch (e.Type)
                {

                    case ChatType.Whisper:
                        sb.Append(" whispers");
                        break;

                    case ChatType.Shout:
                        sb.Append(" shouts");
                        break;
                }
            }

            if (isEmote)
            {
                if (e.SourceType == ChatSourceType.Agent && instance.RLV.RestictionActive("recvemote", e.SourceID.ToString()))
                    sb.Append(" ...");
                else
                    sb.Append(e.Message.Substring(3));
            }
            else
            {
                sb.Append(": ");
                if (e.SourceType == ChatSourceType.Agent && !e.Message.StartsWith("/") && instance.RLV.RestictionActive("recvchat", e.SourceID.ToString()))
                    sb.Append("...");
                else
                    sb.Append(e.Message);
            }

            item.Timestamp = DateTime.Now;
            item.Text = sb.ToString();

            switch (e.SourceType)
            {
                case ChatSourceType.Agent:
                    item.Style =
                        (e.FromName.EndsWith("Linden") ?
                        ChatBufferTextStyle.LindenChat : ChatBufferTextStyle.Normal);
                    break;

                case ChatSourceType.Object:
                    if (e.Type == ChatType.OwnerSay)
                    {
                        item.Style = ChatBufferTextStyle.OwnerSay;
                    }
                    else
                    {
                        item.Style = ChatBufferTextStyle.ObjectChat;
                    }
                    break;
            }

            ProcessBufferItem(item, true);
            instance.TabConsole.Tabs["chat"].Highlight();

            sb = null;
        }
Exemplo n.º 6
0
        private void netcom_AlertMessageReceived(object sender, AlertMessageEventArgs e)
        {
            if (e.Message.ToLower().Contains("autopilot canceled")) return; //workaround the stupid autopilot alerts

            ChatBufferItem item = new ChatBufferItem(
                DateTime.Now, "Alert message", UUID.Zero, ": " + e.Message, ChatBufferTextStyle.Alert);

            ProcessBufferItem(item, true);
        }
Exemplo n.º 7
0
        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["disable_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);
                }
            }
        }
Exemplo n.º 8
0
        public void PrintStartupMessage()
        {
            ChatBufferItem title = new ChatBufferItem(
                DateTime.Now, "", UUID.Zero, Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev, ChatBufferTextStyle.StartupTitle);

            ChatBufferItem ready = new ChatBufferItem(
                DateTime.Now, "", UUID.Zero, "Ready.", ChatBufferTextStyle.StatusBlue);

            ProcessBufferItem(title, true);
            ProcessBufferItem(ready, true);
        }
Exemplo n.º 9
0
 public ChatLineAddedArgs(ChatBufferItem item)
 {
     mItem = item;
 }
Exemplo n.º 10
0
        private void ProcessIncomingChat(ChatEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message))
            {
                return;
            }

            // Check if the sender agent is muted
            if (e.SourceType == ChatSourceType.Agent &&
                null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID)
                )
            {
                return;
            }

            // Check if it's script debug
            if (e.Type == ChatType.Debug && !instance.GlobalSettings["show_script_errors"])
            {
                return;
            }

            // Check if sender object is muted
            if (e.SourceType == ChatSourceType.Object &&
                null != client.Self.MuteList.Find(me =>
                                                  (me.Type == MuteType.Resident && me.ID == e.OwnerID) || // Owner muted
                                                  (me.Type == MuteType.Object && me.ID == e.SourceID) || // Object muted by ID
                                                  (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name
                                                  ))
            {
                return;
            }

            if (instance.RLV.Enabled && e.Message.StartsWith("@"))
            {
                instance.RLV.TryProcessCMD(e);
#if !DEBUG
                if (!instance.RLV.EnabledDebugCommands)
                {
                    return;
                }
#endif
            }

            ChatBufferItem item = new ChatBufferItem();
            item.ID         = e.SourceID;
            item.RawMessage = e;
            StringBuilder sb = new StringBuilder();

            if (e.SourceType == ChatSourceType.Agent)
            {
                item.From = instance.Names.Get(e.SourceID, e.FromName);
            }
            else
            {
                item.From = e.FromName;
            }

            bool isEmote = e.Message.ToLower().StartsWith("/me ");

            if (!isEmote)
            {
                switch (e.Type)
                {
                case ChatType.Whisper:
                    sb.Append(" whispers");
                    break;

                case ChatType.Shout:
                    sb.Append(" shouts");
                    break;
                }
            }

            if (isEmote)
            {
                if (e.SourceType == ChatSourceType.Agent && instance.RLV.RestictionActive("recvemote", e.SourceID.ToString()))
                {
                    sb.Append(" ...");
                }
                else
                {
                    sb.Append(e.Message.Substring(3));
                }
            }
            else
            {
                sb.Append(": ");
                if (e.SourceType == ChatSourceType.Agent && !e.Message.StartsWith("/") && instance.RLV.RestictionActive("recvchat", e.SourceID.ToString()))
                {
                    sb.Append("...");
                }
                else
                {
                    sb.Append(e.Message);
                }
            }

            item.Timestamp = DateTime.Now;
            item.Text      = sb.ToString();

            switch (e.SourceType)
            {
            case ChatSourceType.Agent:
                if (e.FromName.EndsWith("Linden"))
                {
                    item.Style = ChatBufferTextStyle.LindenChat;
                }
                else if (isEmote)
                {
                    item.Style = ChatBufferTextStyle.Emote;
                }
                else if (e.SourceID == client.Self.AgentID)
                {
                    item.Style = ChatBufferTextStyle.Self;
                }
                else
                {
                    item.Style = ChatBufferTextStyle.Normal;
                }
                break;

            case ChatSourceType.Object:
                if (e.Type == ChatType.OwnerSay)
                {
                    if (isEmote)
                    {
                        item.Style = ChatBufferTextStyle.Emote;
                    }
                    else
                    {
                        item.Style = ChatBufferTextStyle.OwnerSay;
                    }
                }
                else if (e.Type == ChatType.Debug)
                {
                    item.Style = ChatBufferTextStyle.Error;
                }
                else
                {
                    item.Style = ChatBufferTextStyle.ObjectChat;
                }
                break;
            }

            ProcessBufferItem(item, true);
            instance.TabConsole.Tabs["chat"].Highlight();

            sb = null;
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Displays notification in the main chat tab
        /// </summary>
        /// <param name="msg">Message to be printed in the chat tab</param>
        /// <param name="style">Style of the message to be printed, normal, object, etc.</param>
        /// <param name="highlightChatTab">Highligt (and flash in taskbar) chat tab if not selected</param>
        public void DisplayNotificationInChat(string msg, ChatBufferTextStyle style, bool highlightChatTab)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                    BeginInvoke(new MethodInvoker(() => DisplayNotificationInChat(msg, style, highlightChatTab)));
                return;
            }

            if (style != ChatBufferTextStyle.Invisible)
            {
                ChatBufferItem line = new ChatBufferItem(
                    DateTime.Now,
                    string.Empty,
                    UUID.Zero,
                    msg,
                    style
                );

                try
                {
                    mainChatManger.ProcessBufferItem(line, true);
                    if (highlightChatTab)
                    {
                        tabs["chat"].Highlight();
                    }
                }
                catch (Exception) { }
            }

            if (OnChatNotification != null)
            {
                try { OnChatNotification(this, new ChatNotificationEventArgs(msg, style)); }
                catch { }
            }
        }
Exemplo n.º 13
0
        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);
                }
            }
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
        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;
                }

                textPrinter.PrintTextLine(item.From + item.Text);
            }
        }