Exemplo n.º 1
0
        public void ChangeChannel(string channelId)
        {
            if (activeChat != null)
            {
                if (activeChat.Id.Equals(channelId))
                {
                    return;
                }

                activeChat.Hide();
            }

            if (chats.ContainsKey(channelId))
            {
                chats[channelId].Show();
                activeChat = chats[channelId];
            }
            else
            {
                MessagesAdapter adapter = null;
                switch (channelId[0])
                {
                case 'D':
                    adapter = new DirectMessageAdapter(Client.DirectMessages.Find((c) => c.id == channelId), this, Client);
                    break;

                case 'C':
                    adapter = new ChannelAdapter(Client.ChannelLookup[channelId], this, Client);
                    break;

                case 'G':
                    adapter = new GroupAdapter(Client.GroupLookup[channelId], this, Client);
                    break;
                }

                if (adapter != null)
                {
                    activeChat          = new ChatInterface(adapter, this);
                    activeChat.Location = new Point(220, 0);
                    activeChat.Width    = Width - 220;
                    activeChat.Height   = Height;
                    activeChat.Anchor   = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top;
                    chats.Add(channelId, activeChat);
                    Controls.Add(activeChat);
                }
                else if (activeChat != null)
                {
                    activeChat.Show();
                }
            }
        }