Ejemplo n.º 1
0
        private void RPC_016(NetMessage arg1, PlayerMessageInfo arg2)
        {
            string   targetName = arg1.ReadString();
            string   text       = arg1.ReadString();
            ChatIcon icon       = (ChatIcon)arg1.ReadByte();

            if (targetName == _user.Name || targetName == m_name)
            {
                return;
            }
            if (icon != ChatIcon.None && _user.Access < AccessLevel.Moderator)
            {
                icon = ChatIcon.None;
            }
            MasterPlayer player;

            if (_server.TryGetByPonyName(targetName, out player))
            {
                var message = default(ChatMsg);
                message.Icon     = icon;
                message.Text     = text;
                message.Time     = DateTime.Now;
                message.CharID   = _user.Char;
                message.PlayerID = _player.Id;
                message.Type     = ChatType.Whisper;
                message.Name     = m_name ?? _user.Name;
                _lastWhisper     = player.Char?.Pony.Name;
                //_player.PlayerRpc(15, ChatType.Whisper, _message.Name ?? _user.Name, message, time, _user.Char, icon, (int)_player.Id);
                player.Player.PlayerRpc(15, message);
            }
            else
            {
                _lastWhisper = null;
            }
        }
Ejemplo n.º 2
0
 public void OnDeserialize(NetMessage message)
 {
     Type = (ChatType)message.ReadByte();
     Text = message.ReadString();
     Icon = (ChatIcon)message.ReadByte();
     Time = DateTime.Now;
 }
Ejemplo n.º 3
0
        public Bitmap GetChatBitmap(ChatIcon icon)
        {
            switch (icon)
            {
            case ChatIcon.Sc2Tv:
                return(Properties.Resources.sc2icon);

            case ChatIcon.TwitchTv:
                return(Properties.Resources.twitchicon);

            case ChatIcon.Steam:
                return(Properties.Resources.steamicon);

            case ChatIcon.Skype:
                return(Properties.Resources.skypeicon);

            case ChatIcon.Admin:
                return(Properties.Resources.adminicon);

            case ChatIcon.Goodgame:
                return(Properties.Resources.goodgameicon);

            case ChatIcon.Battlelog:
                return(Properties.Resources.bf3icon);

            case ChatIcon.Empire:
                return(Properties.Resources.empire);

            case ChatIcon.Goha:
                return(Properties.Resources.goha);

            case ChatIcon.Cybergame:
                return(Properties.Resources.cybergame);

            case ChatIcon.Default:
                return(Properties.Resources.adminicon);

            case ChatIcon.Hashd:
                return(Properties.Resources.hashd);

            case ChatIcon.Music:
                return(Properties.Resources.music);

            case ChatIcon.Youtube:
                return(Properties.Resources.youtube);

            case ChatIcon.GamersTv:
                return(Properties.Resources.gamerstvicon);

            case ChatIcon.JetSet:
                return(Properties.Resources.jetset);

            case ChatIcon.HitBox:
                return(Properties.Resources.hitbox);

            default:
                return(null);
            }
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     equipment       = GetComponent <Equipment>();
     playerMove      = GetComponent <PlayerMove>();
     playerScript    = GetComponent <PlayerScript>();
     chatIcon        = GetComponentInChildren <ChatIcon>();
     objectBehaviour = GetComponent <ObjectBehaviour>();
 }
Ejemplo n.º 5
0
 private void Start()
 {
     equipment       = GetComponent <Equipment>();
     playerMove      = GetComponent <PlayerMove>();
     playerSprites   = GetComponent <UserControlledSprites>();
     playerScript    = GetComponent <PlayerScript>();
     chatIcon        = GetComponentInChildren <ChatIcon>();
     objectBehaviour = GetComponent <ObjectBehaviour>();
 }
Ejemplo n.º 6
0
 void Start()
 {
     equipment           = GetComponent <Equipment.Equipment>();
     playerMove          = GetComponent <PlayerMove>();
     playerSprites       = GetComponent <PlayerSprites>();
     playerScript        = GetComponent <PlayerScript>();
     soundNetworkActions = GetComponent <SoundNetworkActions>();
     chatIcon            = GetComponentInChildren <ChatIcon>();
 }
Ejemplo n.º 7
0
 void Start()
 {
     equipment           = GetComponent <Equipment.Equipment>();
     playerMove          = GetComponent <PlayerMove>();
     playerSprites       = GetComponent <PlayerSprites>();
     playerScript        = GetComponent <PlayerScript>();
     soundNetworkActions = GetComponent <SoundNetworkActions>();
     chatIcon            = GetComponentInChildren <ChatIcon>();
     CmdSyncRoundTime(GameManager.Instance.GetRoundTime);
 }
Ejemplo n.º 8
0
    void InitChat(ChatIcon icon, string name, IMessagesBox msgBox, ChatIcon.OnIconClick iconClickEvent)
    {
        icon.InitUI(m_UIManager);
        icon.onClickEvent += iconClickEvent;

        Chat chat = new Chat(msgBox, icon, m_audio, name);

        chat.onKeyEvent += OnKeyEvent;

        m_chats.Add(chat);
    }
Ejemplo n.º 9
0
        /// <summary>
        /// Writes a line to the textbox. Automaticall adds newline character
        /// </summary>
        /// <param name="text"></param>
        public void WriteLine(string text, ChatIcon icon = ChatIcon.Default)
        {
            if (tb.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(WriteLine);
                try
                {
                    tb.Parent.Invoke(d, new object[] { text, icon });
                }
                catch { }
            }
            else
            {
                Bitmap chatIcon = null;
                switch (icon)
                {
                    case ChatIcon.Sc2Tv:
                        chatIcon = Properties.Resources.sc2icon;
                        break;
                    case ChatIcon.TwitchTv:
                        chatIcon = Properties.Resources.twitchicon;
                        break;
                    case ChatIcon.Steam:
                        chatIcon = Properties.Resources.steamicon;
                        break;
                    case ChatIcon.Skype:
                        chatIcon = Properties.Resources.skypeicon;
                        break;
                    case ChatIcon.Admin:
                        chatIcon = Properties.Resources.adminicon;
                        break;
                    case ChatIcon.Goodgame:
                        chatIcon = Properties.Resources.goodgameicon;
                        break;
                    case ChatIcon.Battlelog:
                        chatIcon = Properties.Resources.bf3icon;
                        break;
                    default:
                        chatIcon = null;
                        break;
                }
                if( tb.Text.Length > 0 )
                    tb.AppendText(Environment.NewLine);

                if (text != null)
                {
                    tb.AppendText(DateTime.Now.GetDateTimeFormats('T')[0] + " ");
                    if(chatIcon != null)
                        tb.InsertImage( chatIcon );
                    tb.AppendText(" " + text);
                }
                tb.ScrollToEnd();
            }
        }
Ejemplo n.º 10
0
 public ChatIndex(int index = 0, ChatIcon icon = ChatIcon.None, string who = "", ChatColor color = ChatColor.Default)
 {
     _index = index;
     Icon   = icon;
     if (who != null && who.Length >= 1)
     {
         //first character of the who string is capitalized: always!
         who = who.Substring(0, 1).ToUpper() + who.Substring(1).ToLower();
     }
     Who = who;
     col = color;
 }
Ejemplo n.º 11
0
 public void Close()
 {
     ChatWindows.Remove(this);
     if (Storage.Settings[SettingType.ChatWindow] == "0" ^ SettingsForm.ApplyingSettings) //Ha az új beállítás szerint(!) külön ablakokban kell megjeleníteni, akkor hajtsa végre
     {                                                                                    //2014.10.31.
         this.Dispose();
         if (ChatIcon != null)                                                            //Most már nem feltétlenül változik a beállítás
         {
             ChatIcon.Dispose();
         }
     }
 }
Ejemplo n.º 12
0
        public static Texture2D GetChatIcon(ChatIcon icon)
        {
            Texture2D ret = new Texture2D(EOGame.Instance.GraphicsDevice, 13, 13);

            if (icon == ChatIcon.None)
            {
                return(ret);
            }

            Color[] data = new Color[169]; //each icon is 13x13
            EOGame.Instance.GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 32, true).GetData(0, new Rectangle(0, (int)icon * 13, 13, 13), data, 0, 169);
            ret.SetData(data);

            return(ret);
        }
Ejemplo n.º 13
0
    private void RpcToggleChatIcon(bool turnOn)
    {
        if (!chatIcon)
        {
            chatIcon = GetComponentInChildren <ChatIcon>();
        }

        if (turnOn)
        {
            chatIcon.TurnOnTalkIcon();
        }
        else
        {
            chatIcon.TurnOffTalkIcon();
        }
    }
Ejemplo n.º 14
0
 public Bitmap GetChatBitmap( ChatIcon icon)
 {            
     switch (icon)
     {
         case ChatIcon.Sc2Tv:
             return Properties.Resources.sc2icon;
         case ChatIcon.TwitchTv:
             return Properties.Resources.twitchicon;
         case ChatIcon.Steam:
             return Properties.Resources.steamicon;
         case ChatIcon.Skype:
             return Properties.Resources.skypeicon;
         case ChatIcon.Admin:
             return Properties.Resources.adminicon;
         case ChatIcon.Goodgame:
             return Properties.Resources.goodgameicon;
         case ChatIcon.Battlelog:
             return Properties.Resources.bf3icon;
         case ChatIcon.Empire:
             return Properties.Resources.empire;
         case ChatIcon.Goha:
             return Properties.Resources.goha;
         case ChatIcon.Cybergame:
             return Properties.Resources.cybergame;
         case ChatIcon.Default:
             return Properties.Resources.adminicon;
         case ChatIcon.Hashd:
             return Properties.Resources.hashd;
         case ChatIcon.Music:
             return Properties.Resources.music;
         case ChatIcon.Youtube:
             return Properties.Resources.youtube;
         case ChatIcon.GamersTv:
             return Properties.Resources.gamerstvicon;
         case ChatIcon.JetSet:
             return Properties.Resources.jetset;
         case ChatIcon.HitBox:
             return Properties.Resources.hitbox;
         default:
             return null;
     }
 }
Ejemplo n.º 15
0
    public Chat(IMessagesBox messageBox, ChatIcon icon, ChatAudio audio, string name)
    {
        m_history   = DataManager.LoadHistory(name);
        m_chatState = m_history.GetState();

        m_name    = name;
        m_replics = new ReplicaController(m_name);

        m_messageBox = messageBox;
        m_messageBox.LoadFromHistory(m_history);
        m_messageBox.AddPlayerTurnEvent(SetState);

        m_icon = icon;
        m_icon.onClickEvent += Activate;
        m_icon.InitChat(m_name);
        m_icon.SetVisible(true);

        m_audio = audio;

        InitUsers();
    }
Ejemplo n.º 16
0
        public ChatData(string who,
                        string message,
                        ChatIcon icon   = ChatIcon.None,
                        ChatColor color = ChatColor.Default)
        {
            if (who == null)
            {
                who = "";
            }
            else if (who.Length >= 1)
            {
                who = char.ToUpper(who[0]) + who.Substring(1).ToLower();
            }

            if (message == null)
            {
                message = "";
            }

            Icon      = icon;
            Who       = who;
            Message   = message;
            ChatColor = color;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Writes a line to the textbox. Automaticall adds newline character
        /// </summary>
        /// <param name="text"></param>
        public void WriteLine(Ubiquitous.MainForm.UbiMessage message, ChatIcon icon = ChatIcon.Default, bool highlight = false, Color? foreColor = null, Color? backColor = null)
        {
            if (tb == null)
                return;
            if (tb.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(WriteLine);
                try
                {
                    tb.Parent.Invoke(d, new object[] { message, icon, highlight, foreColor, backColor });
                }
                catch { }
            }
            else
            {

                Bitmap chatIcon = GetChatBitmap(icon);


                if (tb.Text.Length > 0)
                    tb.AppendText(Environment.NewLine);
                

                if (!string.IsNullOrEmpty(message.Text))
                {
                    if (tb.TimeStamp)
                        tb.AppendTextAsRtf(DateTime.Now.GetDateTimeFormats('T')[0] + " ", tb.TimestampFont, tb.TimestampColor);

                    if (chatIcon != null)
                        tb.InsertImage(chatIcon);

                    tb.AppendTextAsRtf(" ", tb.Font, tb.TextColor);

                    if (message.TextOnly)
                    {
                        if (highlight)
                            tb.AppendTextAsRtf(message.Text, tb.PersonalMessageFont, tb.PersonalMessageColor, tb.PersonalMessageBack);
                        else if (foreColor.HasValue && backColor.HasValue)
                            tb.AppendTextAsRtf(message.Text, tb.Font, foreColor.Value, backColor.Value);
                        else
                            tb.AppendTextAsRtf(message.Text, tb.Font, tb.TextColor);
                    }
                    else
                    {
                        String messageFormat = String.Empty;

                        if (!String.IsNullOrEmpty(message.FromGroupName))
                            messageFormat = settings.appearanceGrpMessageFormat;
                        else if (!String.IsNullOrEmpty(message.FromName))
                            messageFormat = settings.appearanceMsgFormat;

                        String[] messageFormatParts = messageFormat.Split('%');
                        String suffix = String.Empty;
                        foreach (String messageFormatPart in messageFormatParts)
                        {
                            if( messageFormatPart.StartsWith("t") )
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;

                                if (highlight)
                                    tb.AppendTextAsRtf(message.Text, tb.PersonalMessageFont, tb.PersonalMessageColor, tb.PersonalMessageBack);
                                else if (foreColor.HasValue && backColor.HasValue)
                                    tb.AppendTextAsRtf(message.Text, tb.Font, foreColor.Value, backColor.Value);
                                else
                                    tb.AppendTextAsRtf(message.Text, tb.Font, tb.TextColor);

                                if (!String.IsNullOrEmpty(suffix))
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                            }
                            else if (messageFormatPart.StartsWith("sg"))
                            {
                                suffix = messageFormatPart.Length > 2 ? messageFormatPart.Substring(2) : String.Empty;
                                tb.AppendTextAsRtf(message.FromGroupName == null ? String.Empty : message.FromGroupName, tb.Font, message.NickColor);
                                if (!String.IsNullOrEmpty(suffix))
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                            }
                            else if (messageFormatPart.StartsWith("s"))
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;
                                tb.AppendTextAsRtf(message.FromName == null ? String.Empty : message.FromName, tb.Font, message.NickColor);
                                if (!String.IsNullOrEmpty(suffix))
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                            }
                            else if( messageFormatPart.StartsWith("d") )
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;
                                tb.AppendTextAsRtf(message.ToName == null ? String.Empty : "->" + message.ToName, tb.Font, message.NickColor);
                                
                                if( !String.IsNullOrEmpty(suffix))
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                            }
                            else if( messageFormatPart.StartsWith("c") )
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;
                                tb.AppendTextAsRtf(message.FromEndPoint.ToString(), tb.Font, message.NickColor);
                                if (!String.IsNullOrEmpty(suffix))
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                            }
                            
                        }

                    }


                    //tb.AppendText(" " + text);
                }
                tb.SelectionStart = tb.Text.Length;
                tb.SelectionLength = 0;
                tb.ScrollToEnd();

            }
        }
Ejemplo n.º 18
0
 private static Rectangle?GetChatIconRectangle(ChatIcon icon)
 {
     return(icon == ChatIcon.None ? Rectangle.Empty : new Rectangle(0, (int)icon * 13, 13, 13));
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Adds text to the tab. For multi-line text strings, does text wrapping. For text length > 415 pixels, does text wrapping
        /// </summary>
        /// <param name="who">Person that spoke</param>
        /// <param name="text">Message that was spoken</param>
        /// <param name="icon">Icon to display next to the chat</param>
        /// <param name="col">Rendering color (enumerated value)</param>
        public void AddText(string who, string text, ChatIcon icon = ChatIcon.None, ChatColor col = ChatColor.Default)
        {
            const int LINE_LEN = 380;

            //special case: blank line, like in the news panel between news items
            if (string.IsNullOrWhiteSpace(who) && string.IsNullOrWhiteSpace(text))
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), " ");
                scrollBar.UpdateDimensions(chatStrings.Count);
                if (chatStrings.Count > 7)
                {
                    scrollBar.ScrollToEnd();
                }
                if (!Selected)
                {
                    tabLabel.ForeColor = Color.White;
                }
                if (!Visible)
                {
                    Visible = true;
                }
                return;
            }

            string whoPadding = "  "; //padding string for additional lines if it is a multi-line message

            if (!string.IsNullOrEmpty(who))
            {
                while (EOGame.Instance.DBGFont.MeasureString(whoPadding).X < EOGame.Instance.DBGFont.MeasureString(who).X)
                {
                    whoPadding += " ";
                }
            }

            TextSplitter ts = new TextSplitter(text, EOGame.Instance.DBGFont)
            {
                LineLength = LINE_LEN,
                LineEnd    = "",
                LineIndent = whoPadding
            };

            if (!ts.NeedsProcessing)
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), text);
            }
            else
            {
                List <string> chatStringsToAdd = ts.SplitIntoLines();

                for (int i = 0; i < chatStringsToAdd.Count; ++i)
                {
                    lock (ChatStringsLock)
                    {
                        if (i == 0)
                        {
                            chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), chatStringsToAdd[0]);
                        }
                        else
                        {
                            chatStrings.Add(new ChatIndex(chatStrings.Count, ChatIcon.None, "", col), chatStringsToAdd[i]);
                        }
                    }
                }
            }

            scrollBar.UpdateDimensions(chatStrings.Count);
            if (chatStrings.Count > 7)
            {
                scrollBar.ScrollToEnd();
            }
            if (!Selected)
            {
                tabLabel.ForeColor = Color.White;
            }
            if (!Visible)
            {
                Visible = true;
            }
        }
Ejemplo n.º 20
0
        private EOPaperdollDialog(PacketAPI api, OldCharacter character, PaperdollDisplayData data)
            : base(api)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Paperdoll is already open!");
            }
            Instance = this;

            CharRef = character;

            Texture2D bgSprites = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 49);

            _setSize(bgSprites.Width, bgSprites.Height / 2);

            Color[] dat = new Color[DrawArea.Width * DrawArea.Height];
            bgTexture = new Texture2D(Game.GraphicsDevice, DrawArea.Width, DrawArea.Height);
            bgSprites.GetData(0, DrawArea.WithPosition(new Vector2(0, CharRef.RenderData.gender * DrawArea.Height)), dat, 0, dat.Length);
            bgTexture.SetData(dat);

            //not using caption/message since we have other shit to take care of

            //ok button
            XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(276, 253), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
            {
                Visible = true
            };

            ok.OnClick += (s, e) => Close(ok, XNADialogResult.OK);
            ok.SetParent(this);
            dlgButtons.Add(ok);

            //items
            for (int i = (int)EquipLocation.Boots; i < (int)EquipLocation.PAPERDOLL_MAX; ++i)
            {
                var info = OldWorld.Instance.EIF[CharRef.PaperDoll[i]];

                Rectangle itemArea = _getEquipLocRectangle((EquipLocation)i);

                //create item using itemArea
                if (CharRef.PaperDoll[i] > 0)
                {
                    // ReSharper disable once UnusedVariable
                    PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, info, (EquipLocation)i); //auto-added as child of this dialog
                }
                else
                {
                    // ReSharper disable once UnusedVariable
                    PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, null, (EquipLocation)i);
                }
            }

            //labels next
            XNALabel[] labels =
            {
                new XNALabel(new Rectangle(228,  22, 1, 1), Constants.FontSize08pt5)
                {
                    Text = CharRef.Name.Length > 0 ? char.ToUpper(CharRef.Name[0]) + CharRef.Name.Substring(1) : ""
                },                              //name
                new XNALabel(new Rectangle(228,  52, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Home.Length > 0 ? char.ToUpper(data.Home[0]) + data.Home.Substring(1) : ""
                },                              //home
                new XNALabel(new Rectangle(228,  82, 1, 1), Constants.FontSize08pt5)
                {
                    Text = (OldWorld.Instance.ECF[CharRef.Class] ?? new ECFRecord()).Name ?? ""
                },                              //class
                new XNALabel(new Rectangle(228, 112, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Partner.Length > 0 ? char.ToUpper(data.Partner[0]) + data.Partner.Substring(1) : ""
                },                              //partner
                new XNALabel(new Rectangle(228, 142, 1, 1), Constants.FontSize08pt5)
                {
                    Text = CharRef.Title.Length > 0 ? char.ToUpper(CharRef.Title[0]) + CharRef.Title.Substring(1) : ""
                },                              //title
                new XNALabel(new Rectangle(228, 202, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Guild.Length > 0 ? char.ToUpper(data.Guild[0]) + data.Guild.Substring(1) : ""
                },                              //guild
                new XNALabel(new Rectangle(228, 232, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Rank.Length > 0 ? char.ToUpper(data.Rank[0]) + data.Rank.Substring(1) : ""
                } //rank
            };

            labels.ToList().ForEach(_l => { _l.ForeColor = ColorConstants.LightGrayText; _l.SetParent(this); });

            ChatIcon icon = OldChatRenderer.GetChatTypeFromPaperdollIcon(data.Icon);

            m_characterIcon = OldChatTab.GetChatIcon(icon);

            //should not be centered vertically: only display in game window
            //first center in the game display window, then move it 15px from top, THEN call end constructor logic
            //if not done in this order some items DrawAreaWithOffset field does not get updated properly when setting DrawLocation
            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 15);
            endConstructor(false);
        }
Ejemplo n.º 21
0
 public void AddTextToTab(ChatTab tab, string who, string text, ChatIcon icon = ChatIcon.None, ChatColor col = ChatColor.Default)
 {
     tabs[(int)tab].AddText(who, text, icon, col);
 }
Ejemplo n.º 22
0
 public ChatAlias(string alias, EndPoint endpoint, ChatIcon icon = ChatIcon.Default, String mynick = "")
 {
     Alias = alias;
     Endpoint = endpoint;
     Icon = icon;
     MyNick = mynick;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Writes a line to the textbox. Automaticall adds newline character
        /// </summary>
        /// <param name="text"></param>
        public void WriteLine(Ubiquitous.MainForm.UbiMessage message, ChatIcon icon = ChatIcon.Default, bool highlight = false, Color?foreColor = null, Color?backColor = null)
        {
            if (tb == null)
            {
                return;
            }
            if (tb.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(WriteLine);
                try
                {
                    tb.Parent.Invoke(d, new object[] { message, icon, highlight, foreColor, backColor });
                }
                catch { }
            }
            else
            {
                Bitmap chatIcon = GetChatBitmap(icon);


                if (tb.Text.Length > 0)
                {
                    tb.AppendText(Environment.NewLine);
                }


                if (!string.IsNullOrEmpty(message.Text))
                {
                    if (tb.TimeStamp)
                    {
                        tb.AppendTextAsRtf(DateTime.Now.GetDateTimeFormats('T')[0] + " ", tb.TimestampFont, tb.TimestampColor);
                    }

                    if (chatIcon != null)
                    {
                        tb.InsertImage(chatIcon);
                    }

                    tb.AppendTextAsRtf(" ", tb.Font, tb.TextColor);

                    if (message.TextOnly)
                    {
                        if (highlight)
                        {
                            tb.AppendTextAsRtf(message.Text, tb.PersonalMessageFont, tb.PersonalMessageColor, tb.PersonalMessageBack);
                        }
                        else if (foreColor.HasValue && backColor.HasValue)
                        {
                            tb.AppendTextAsRtf(message.Text, tb.Font, foreColor.Value, backColor.Value);
                        }
                        else
                        {
                            tb.AppendTextAsRtf(message.Text, tb.Font, tb.TextColor);
                        }
                    }
                    else
                    {
                        String messageFormat = String.Empty;

                        if (!String.IsNullOrEmpty(message.FromGroupName))
                        {
                            messageFormat = settings.appearanceGrpMessageFormat;
                        }
                        else if (!String.IsNullOrEmpty(message.FromName))
                        {
                            messageFormat = settings.appearanceMsgFormat;
                        }

                        String[] messageFormatParts = messageFormat.Split('%');
                        String   suffix             = String.Empty;
                        foreach (String messageFormatPart in messageFormatParts)
                        {
                            if (messageFormatPart.StartsWith("t"))
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;

                                if (highlight)
                                {
                                    tb.AppendTextAsRtf(message.Text, tb.PersonalMessageFont, tb.PersonalMessageColor, tb.PersonalMessageBack);
                                }
                                else if (foreColor.HasValue && backColor.HasValue)
                                {
                                    tb.AppendTextAsRtf(message.Text, tb.Font, foreColor.Value, backColor.Value);
                                }
                                else
                                {
                                    tb.AppendTextAsRtf(message.Text, tb.Font, tb.TextColor);
                                }

                                if (!String.IsNullOrEmpty(suffix))
                                {
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                                }
                            }
                            else if (messageFormatPart.StartsWith("sg"))
                            {
                                suffix = messageFormatPart.Length > 2 ? messageFormatPart.Substring(2) : String.Empty;
                                tb.AppendTextAsRtf(message.FromGroupName == null ? String.Empty : message.FromGroupName, tb.Font, message.NickColor);
                                if (!String.IsNullOrEmpty(suffix))
                                {
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                                }
                            }
                            else if (messageFormatPart.StartsWith("s"))
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;
                                tb.AppendTextAsRtf(message.FromName == null ? String.Empty : message.FromName, tb.Font, message.NickColor);
                                if (!String.IsNullOrEmpty(suffix))
                                {
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                                }
                            }
                            else if (messageFormatPart.StartsWith("d"))
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;
                                tb.AppendTextAsRtf(message.ToName == null ? String.Empty : "->" + message.ToName, tb.Font, message.NickColor);

                                if (!String.IsNullOrEmpty(suffix))
                                {
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                                }
                            }
                            else if (messageFormatPart.StartsWith("c"))
                            {
                                suffix = messageFormatPart.Length > 1 ? messageFormatPart.Substring(1) : String.Empty;
                                tb.AppendTextAsRtf(message.FromEndPoint.ToString(), tb.Font, message.NickColor);
                                if (!String.IsNullOrEmpty(suffix))
                                {
                                    tb.AppendTextAsRtf(suffix, tb.Font, tb.TextColor);
                                }
                            }
                        }
                    }


                    //tb.AppendText(" " + text);
                }
                tb.SelectionStart  = tb.Text.Length;
                tb.SelectionLength = 0;
                tb.ScrollToEnd();
            }
        }
Ejemplo n.º 24
0
 public void AddChat(ChatTab whichTab, string who, string message, ChatIcon chatIcon = ChatIcon.None, ChatColor chatColor = ChatColor.Default)
 {
     chatRenderer.AddTextToTab(whichTab, who, message, chatIcon, chatColor);
 }