private void DepartMouseDoubleClick(object expander) { if (Owner == null || (!(Owner is GroupEditWindowViewModel) && !(Owner is MultiContactsSelectViewModel)) || !dicExpanderNode.Keys.Contains(expander)) { return; } string parentDepartId = dicExpanderNode[expander as Expander].DepartId; UserListByDepartId = new List <AntSdkContact_User>(); GetUserListByDepartId(parentDepartId); if (UserListByDepartId.Count == 0) { return; } GroupEditWindowViewModel ownerVM = Owner as GroupEditWindowViewModel; if (ownerVM != null)//编辑讨论组 { foreach (AntSdkContact_User user in UserListByDepartId) { if (ownerVM.GroupMemberList.FirstOrDefault(c => c.User.userId == user.userId) != null) { continue; } ContactInfoViewModel contactInfoVM = ContactInfoViewModelList.FirstOrDefault(c => c.User.userId == user.userId); if (contactInfoVM == null) { ContactInfoViewModel vm = new ContactInfoViewModel(user, GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewRight); ownerVM.GroupMemberList.Add(vm); } else { contactInfoVM.OnStateImageClickEventEvent(contactInfoVM, true); } } ownerVM.MemberCount = string.Format("已选择{0}个联系人", ownerVM.GroupMemberList.Count()); } else { //选择群发联系人 MultiContactsSelectViewModel selectVM = Owner as MultiContactsSelectViewModel; if (selectVM != null) { foreach (AntSdkContact_User user in UserListByDepartId) { if (user.userId == AntSdkService.AntSdkCurrentUserInfo.userId || selectVM.GroupMemberList.FirstOrDefault(c => c.User.userId == user.userId) != null) { continue; } ContactInfoViewModel contactInfoVM = ContactInfoViewModelList.FirstOrDefault(c => c.User.userId == user.userId); if (contactInfoVM == null) { ContactInfoViewModel vm = new ContactInfoViewModel(user, GlobalVariable.ContactInfoViewContainer.MultiContactsSelectRight); selectVM.GroupMemberList.Add(vm); } else { contactInfoVM.OnStateImageClickEventEvent(contactInfoVM, true); } } selectVM.MemberCount = string.Format("已选择{0}个联系人", selectVM.GroupMemberList.Count()); } } }
/// <summary> /// 展开子节点 /// </summary> /// <param name="stackPanel">父面板</param> /// <param name="parentDepartId">父部门ID</param> /// <param name="level">在第几层</param> private void RecursionLoadSource(StackPanel stackPanel, string parentDepartId, int level) { if (AntSdkService.AntSdkListContactsEntity == null) { return; } AsyncHandler.AsyncCall(Application.Current.Dispatcher, () => { if (AntSdkService.AntSdkListContactsEntity.departs != null) { List <AntSdkContact_Depart> departList = AntSdkService.AntSdkListContactsEntity.departs.Where(c => c.parentDepartId == parentDepartId) .ToList(); if (AntSdkService.AntSdkListContactsEntity.users != null) { if (stackPanel == null) { stackPanel = new StackPanel(); } List <AntSdkContact_User> userList = AntSdkService.AntSdkListContactsEntity.users.Where(c => c.departmentId == parentDepartId && c.status == 2) .OrderBy(c => c.userId) .ToList(); if (userList.Count > 0) { stackPanel?.Children.Clear(); foreach (AntSdkContact_User user in userList) { ContactInfoView contactInfo = new ContactInfoView(user, this.Container); ContactInfoViewModel contactInfoViewModel = contactInfo.DataContext as ContactInfoViewModel; var tempContactInfo = ContactInfoViewModelList.FirstOrDefault(m => m.User.userId == user.userId); //if (tempContactInfo?.User != null && tempContactInfo.User.departmentId == user.departmentId) continue; if (tempContactInfo?.User != null && tempContactInfo.User.departmentId != user.departmentId) { tempContactInfo.User = user; } stackPanel.Children.Add(contactInfo); if (Container == GlobalVariable.ContactInfoViewContainer.ContactListView) { contactInfo.MouseDown += ModifyColorOnMouseClick; } else if (Container == GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewLeft) { GroupEditWindowViewModel groupEditVM = Owner as GroupEditWindowViewModel; if (groupEditVM?.GroupMemberList != null && groupEditVM.GroupMemberList.Select(c => c.User.userId).Contains(user.userId)) { if (groupEditVM.OriginalMemberIds != null && groupEditVM.OriginalMemberIds.Contains(user.userId)) { contactInfoViewModel?.SetExistGroupMember(); } else { contactInfoViewModel?.OnStateImageClickEventEvent(contactInfoViewModel, true); } } } else if (Container == GlobalVariable.ContactInfoViewContainer.MultiContactsSelectLeft) { MultiContactsSelectViewModel vm = Owner as MultiContactsSelectViewModel; if (vm != null && vm.GroupMemberList != null && vm.GroupMemberList.Select(c => c.User.userId).Contains(user.userId)) { //if (vm.OriginalMemberIds != null && vm.OriginalMemberIds.Contains(user.userId)) //{ // contactInfoViewModel.SetExistGroupMember(); //} //else //{ contactInfoViewModel?.OnStateImageClickEventEvent(contactInfoViewModel, true); //} } } if (contactInfoViewModel != null) { contactInfoViewModel.PlaceholderWidth = 30; ContactInfoViewModelList.Add(contactInfoViewModel); } } } else if (stackPanel?.Children.Count > 0) { stackPanel?.Children.Clear(); } } if (departList.Count <= 0) { return; } foreach (AntSdkContact_Depart depart in departList) { AdddepartData(depart, stackPanel, level); } } }); }