/// <summary> /// 选择要转发的聊天室 /// </summary> /// <param name="obj"></param> private void SelectedChatItemChanged(object obj) { var tempChatInfo = obj as ChatInfo; var tempSelectedItem = SelectedChatList.FirstOrDefault(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup); var tempChatItems = ChatItems.Where(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup)?.ToList(); if (tempSelectedItem == null) { if (SelectedChatList.Count == 9) { //IsMsgExist = true; //FowardTips = "最多只能选择9个联系人"; IsMoreContact = true; timer.Tick += new EventHandler(Timer_Tick); timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); return; } SelectedChatList.Add(tempChatInfo); if (tempChatItems?.Count > 0) { foreach (var chatItem in tempChatItems) { chatItem.IsChatSelected = true; } } } else { SelectedChatList.Remove(tempSelectedItem); if (tempChatItems?.Count > 0) { foreach (var chatItem in tempChatItems) { chatItem.IsChatSelected = false; } } } if (SelectedChatList.Count > 0) { IsEnabled = true; } else { IsEnabled = false; } }
/// <summary> /// 删除选中的聊天室 /// </summary> /// <param name="obj"></param> private void RemoveSelectedChat(object obj) { var tempChatInfo = obj as ChatInfo; var tempSelectedItem = SelectedChatList.FirstOrDefault(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup); if (tempSelectedItem != null) { SelectedChatList.Remove(tempSelectedItem); var tempChatItems = ChatItems.Where(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup)?.ToList(); if (tempChatItems?.Count > 0) { foreach (var chatItem in tempChatItems) { chatItem.IsChatSelected = false; } } } if (SelectedChatList?.Count == 0) { IsEnabled = false; } }