public ChatListItem(BitChat chat) { InitializeComponent(); _chat = chat; SetTitle(_chat.NetworkDisplayName); labLastMessage.Text = ""; SetLastMessageDate(); ResetUnreadMessageCount(); _chat.FileAdded += chat_FileAdded; _chat.MessageReceived += chat_MessageReceived; _chat.PeerAdded += chat_PeerAdded; _chat.PeerTyping += chat_PeerTyping; if (_chat.NetworkType == BitChatCore.Network.BitChatNetworkType.PrivateChat) { foreach (BitChat.Peer peer in _chat.GetPeerList()) { if (!peer.IsSelf) { _peer = peer; peer.ProfileImageChanged += peer_ProfileImageChanged; peer.StateChanged += peer_StateChanged; } } } else { SetImageIcon(_chat.GroupImage); _chat.GroupImageChanged += chat_GroupImageChanged; } this.GoOffline = (_chat.NetworkStatus == BitChatCore.Network.BitChatNetworkStatus.Offline); _chatPanel = new BitChatPanel(_chat, this); _chatPanel.Dock = DockStyle.Fill; }
private void AddChatView(BitChat chat) { string title; if (chat.NetworkType == BitChatClient.Network.BitChatNetworkType.PrivateChat) { if (chat.NetworkName == null) title = chat.PeerEmailAddress.Address; else title = chat.NetworkName; } else { title = chat.NetworkName; } ChatListItem itm = new ChatListItem(title); BitChatPanel chatPanel = new BitChatPanel(chat, itm); chatPanel.Dock = DockStyle.Fill; chatPanel.SettingsModified += chatPanel_SettingsModified; chatPanel.MessageNotification += chatPanel_MessageNotification; mainContainer.Panel2.Controls.Add(chatPanel); itm.Tag = chatPanel; lstChats.AddItem(itm); if (lstChats.Controls.Count == 1) ShowSelectedChatView(); }