Пример #1
0
        private void UpdateDisplayPanel(Entities.TextMessage msg)
        {
            if (msg.Type == TextMessageType.TextMessage)
            {
                txtRecieved.Text = msg.Msg;
                ChatBallon ballon = new ChatBallon()
                {
                    ChatText = msg.Msg, ChatBallonDirection = Direction.LeftToRight
                };

                ChatBallon cb = null;
                try
                {
                    cb = (ChatBallon)panel1.Controls[panel1.Controls.Count - 1];
                    ballon.Location = new Point(0, cb.Location.Y + cb.Height);
                    panel1.Controls.Add(ballon);
                }
                catch
                {
                    panel1.Controls.Add(ballon);
                }
            }
            else if (msg.Type == TextMessageType.StatusMessage)
            {
                if (usersList.Count(x => x.IPAddress == msg.User.IPAddress) == 0)
                {
                    usersList.Add(msg.User);
                    StatusIndicator si = new StatusIndicator(msg.User.DisplayName, msg.User.Status, msg.User.IPAddress);
                    flowLayoutPanel1.Controls.Add(si);
                }
                listBox1.DataSource = usersList.Select(u => u.DisplayName).ToList <string>();
            }
        }
Пример #2
0
        private void UpdateDisplayPanel(Entities.TextMessage msg)
        {
            if (msg.Type == TextMessageType.TextMessage)
            {
                //txtRecieved.Text = msg.Msg;
                ChatBallon ballon = new ChatBallon()
                {
                    ChatText = msg.Msg, ChatBallonDirection = Direction.LeftToRight
                };
                int top = 0;
                //ChatBallon cb = null;
                try
                {
                    //cb = (ChatBallon)pnlChatDisplay.Controls[pnlChatDisplay.Controls.Count - 1];

                    foreach (Control c in pnlChatDisplay.Controls)
                    {
                        top += c.Height;
                    }
                    ballon.Location = new Point(0, top);
                    pnlChatDisplay.Controls.Add(ballon);
                }
                catch
                {
                    //pnlChatDisplay.Controls.Add(ballon);
                }
            }
            //else if (msg.Type == MessageType.StatusMessage)
            //{
            //    //if (usersList.Count(x => x.IPAddress == msg.User.IPAddress) == 0)
            //    //{
            //    //    usersList.Add(msg.User);
            //    //    StatusIndicator si = new StatusIndicator(msg.User.DisplayName, msg.User.Status, msg.User.IPAddress);
            //    //    flowLayoutPanel1.Controls.Add(si);
            //    //}
            //    //listBox1.DataSource = usersList.Select(u => u.DisplayName).ToList<string>();

            //}
        }