public BitChatPanel(BitChat chat, ChatListItem chatItem) { InitializeComponent(); _chat = chat; _chat.FileAdded += _chat_FileAdded; _chat.PeerAdded += _chat_PeerAdded; _chat.MessageReceived += _chat_MessageReceived; //create view _view = new ChatMessageView(_chat, chatItem); _view.Dock = DockStyle.Fill; _view.AllowDrop = true; _view.SettingsModified += _view_SettingsModified; _view.DragEnter += lstFiles_DragEnter; _view.DragDrop += lstFiles_DragDrop; //load all peers foreach (BitChat.Peer peer in _chat.GetPeerList()) { lstUsers.AddItem(new UserListItem(peer)); peer.StateChanged += _view.peer_StateChanged; peer.StateChanged += peer_StateChanged; } //load all files foreach (SharedFile sharedFile in _chat.GetSharedFileList()) _chat_FileAdded(chat, sharedFile); //add view to panel bitChatPanelSplitContainer.Panel1.Controls.Add(_view); }
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(); }