Example #1
0
 private void AddChat(IUser user, string message)
 {
     VGen0 method = null;
     VGen0 gen2 = null;
     bool scroll = true;
     if ((base.InvokeRequired && !base.Disposing) && !base.IsDisposed)
     {
         if (method == null)
         {
             method = delegate {
                 scroll = !this.gvPrivateChat.IsFocusedView && GPGGridView.IsMaxScrolled(this.gvPrivateChat);
             };
         }
         base.Invoke(method);
     }
     else if (!(base.Disposing || base.IsDisposed))
     {
         scroll = !this.gvPrivateChat.IsFocusedView && GPGGridView.IsMaxScrolled(this.gvPrivateChat);
     }
     message = Profanity.MaskProfanity(message);
     ChatLine line = new ChatLine(this.gpgChatGrid);
     line.Tag = user;
     line.PlayerInfo = user.Name;
     line.Text = message;
     line.TextFont = this.gpgChatGrid.Font;
     line.TextColor = Program.Settings.Chat.Appearance.DefaultColor;
     line.Filters[this.ChatTarget.Name] = true;
     if (user.IsSystem)
     {
         if (user.Equals(User.System))
         {
             line.Effect = new FontColorEffect(Program.Settings.Chat.Appearance.SystemColor, Program.Settings.Chat.Appearance.SystemFont);
         }
         else if (user.Equals(User.Event))
         {
             line.Effect = new FontColorEffect(Program.Settings.Chat.Appearance.EventColor, Program.Settings.Chat.Appearance.EventFont);
         }
         else if (user.Equals(User.Error))
         {
             line.Effect = new FontColorEffect(Program.Settings.Chat.Appearance.ErrorColor, Program.Settings.Chat.Appearance.ErrorFont);
         }
     }
     else if (user.IsCurrent)
     {
         line.Effect = new FontColorEffect(Program.Settings.Chat.Appearance.PrivateMessaging.SelfColor, Program.Settings.Chat.Appearance.PrivateMessaging.SelfFont);
     }
     else
     {
         line.Effect = new FontColorEffect(Program.Settings.Chat.Appearance.PrivateMessaging.OtherColor, Program.Settings.Chat.Appearance.PrivateMessaging.OtherFont);
     }
     if (base.InvokeRequired)
     {
         if (!base.Disposing && !base.IsDisposed)
         {
             if (gen2 == null)
             {
                 gen2 = delegate {
                     this.mChatLines.Add(line);
                     if (scroll)
                     {
                         this.gvPrivateChat.MoveLastVisible();
                     }
                 };
             }
             base.BeginInvoke(gen2);
         }
     }
     else
     {
         this.mChatLines.Add(line);
         if (scroll)
         {
             this.gvPrivateChat.MoveLastVisible();
         }
         if (Form.ActiveForm != this)
         {
             base.FlashWindow();
         }
     }
 }
Example #2
0
 internal void AddChat(User user, string message)
 {
     try
     {
         VGen0 method = null;
         VGen1 gen2 = null;
         bool scroll;
         if (!user.IsIgnored)
         {
             if (message.IndexOf("I am the effect: ") >= 0)
             {
                 this.RecieveChatEffect(user.Name, message.Replace("I am the effect: ", ""));
             }
             else
             {
                 message = Profanity.MaskProfanity(message);
                 message = message.Replace("\t", "  ");
                 if (Program.Settings.Sound.Speech.EnableSpeech)
                 {
                     Speech.Speak(string.Format("{0} says,, {1}", user.Name, message), false);
                 }
                 scroll = true;
                 if ((base.InvokeRequired && !base.Disposing) && !base.IsDisposed)
                 {
                     if (method == null)
                     {
                         method = delegate {
                             scroll = !this.gvChat.IsFocusedView && GPGGridView.IsMaxScrolled(this.gvChat);
                         };
                     }
                     base.Invoke(method);
                 }
                 else if (!(base.Disposing || base.IsDisposed))
                 {
                     scroll = !this.gvChat.IsFocusedView && GPGGridView.IsMaxScrolled(this.gvChat);
                 }
                 ChatLine line = new ChatLine(this.gpgChatGrid);
                 line.Tag = user;
                 line.PlayerInfo = user.Name;
                 line.Text = message;
                 line.Icon = null;
                 line.TextColor = Program.Settings.Chat.Appearance.DefaultColor;
                 line.TextFont = Program.Settings.Chat.Appearance.DefaultFont;
                 line.Filters["Self"] = user.IsCurrent;
                 line.Filters["System"] = user.Equals(User.System);
                 line.Filters["Game"] = user.Equals(User.Game);
                 line.Filters["Event"] = user.Equals(User.Event);
                 line.Filters["Error"] = user.Equals(User.Error);
                 line.Filters["Admin"] = !user.IsCurrent && user.IsAdmin;
                 line.Filters["Clan"] = !user.IsCurrent && user.IsClanMate;
                 line.Filters["Friend"] = user.IsFriend;
                 line.Filters["Other"] = ((!user.IsSystem && !user.IsAdmin) && (!user.IsClanMate && !user.IsFriend)) && !user.IsCurrent;
                 line.Filters["Speaking"] = true;
                 line.Filters[user.Name] = true;
                 this.OnStyleChatLine(line);
                 if (this.PlayerChatEffects.ContainsKey(user.Name))
                 {
                     foreach (TextSegment segment in line.TextSegments)
                     {
                         segment.Effect = this.PlayerChatEffects[user.Name];
                     }
                 }
                 if ((user != User.System) && (this.AddSpeaker != null))
                 {
                     this.AddSpeaker(this, user);
                 }
                 if ((base.InvokeRequired && !base.Disposing) && !base.IsDisposed)
                 {
                     if (gen2 == null)
                     {
                         gen2 = delegate (object objline) {
                             this.mChatLines.Add((ChatLine) objline);
                             if (scroll)
                             {
                                 this.gvChat.MoveLastVisible();
                             }
                         };
                     }
                     base.BeginInvoke(gen2, new object[] { line });
                 }
                 else if (!base.Disposing && !base.IsDisposed)
                 {
                     this.mChatLines.Add(line);
                     if ((!base.IsDisposed && !base.Disposing) && scroll)
                     {
                         this.gvChat.MoveLastVisible();
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }