/// <summary> /// 检查当前聊天对象是否存在 /// </summary> /// <param name="chatUserName"></param> /// <returns></returns> private bool CheckItemExist(string chatUserName) { ChatItem item; for (int i = 0; i < Chanel1_Info.Controls.Count; i++) { item = (ChatItem)Chanel1_Info.Controls[i]; if (item.UserName == chatUserName) { Chanel1_Info.Show(); // item.ChatItem_Click(item, null); return(true); } } for (int i = 0; i < Chanel2_Info.Controls.Count; i++) { item = (ChatItem)Chanel2_Info.Controls[i]; if (item.UserName == chatUserName) { Chanel2_Info.Show(); item.SetSelect(); // item.ChatItem_Click(item, null); return(true); } } return(false); }
private void AddNewChatItem(ChatType type, string userName, string displayName) { for (int i = 0; i < 20; i++) { ChatItem item = new ChatItem(userName, displayName); if (type == ChatType.GroupChat || type == Common.ChatType.TeamChat) { Chanel1_Info.Show(); this.Chanel1_Info.Controls.Add(item); } else { Chanel2_Info.Show(); this.Chanel2_Info.Controls.Add(item); } item.Dock = DockStyle.Top; item.BringToFront(); item.ChatItemSelect += Item_ChatItemSelect; item.SetSelect(); } }