/// <summary> /// 被移出讨论组时调用 /// </summary> /// <param name="groupId"></param> public void DropOutGroup(string groupId) { AsyncHandler.AsyncCall(System.Windows.Application.Current.Dispatcher, () => { GroupInfoViewModel vm = GroupInfoList.FirstOrDefault(c => c.GroupInfo.groupId == groupId); if (vm == null) { return; } GroupIds.Remove(vm.GroupInfo.groupId); //GroupInfoList.Remove(vm); GroupInfoList.Remove(vm); GroupInfos.Remove(vm.GroupInfo); if (ManageGroupInfoList.Contains(vm)) { ManageGroupInfoList.Remove(vm); } if (JoinGroupInfoList.Contains(vm)) { JoinGroupInfoList.Remove(vm); } ManageGroupCount = ManageGroupInfoList.Count; JoinGroupCount = JoinGroupInfoList.Count; if (ManageGroupCount == 0) { IsManageGroup = false; } if (JoinGroupCount == 0) { IsJoinGroup = false; } List <string> topics = new List <string>(); topics.Add(vm.GroupInfo.groupId); }); }
/// <summary> /// 退出讨论组时调用 /// </summary> /// <param name="viewModel"></param> /// <param name="args"></param> private void DropOutGroup(object viewModel, EventArgs args) { GroupInfoViewModel vm = viewModel as GroupInfoViewModel; if (vm == null) { return; } GroupIds.Remove(vm.GroupInfo.groupId); GroupInfoList.Remove(vm); GroupInfos.Remove(vm.GroupInfo); if (ManageGroupInfoList.Contains(vm)) { ManageGroupInfoList.Remove(vm); } if (JoinGroupInfoList.Contains(vm)) { JoinGroupInfoList.Remove(vm); } ManageGroupCount = ManageGroupInfoList.Count; JoinGroupCount = JoinGroupInfoList.Count; if (ManageGroupCount == 0) { IsManageGroup = false; } if (JoinGroupCount == 0) { IsJoinGroup = false; } List <string> topics = new List <string>(); topics.Add(vm.GroupInfo.groupId); }
private void GroupMemberViewModel_DismissGroupHandlerHidden(object sender, EventArgs e) { if (GroupInfoList != null && GroupInfoList.Any()) { GroupInfoViewModel groupInfo = GroupInfoList.SingleOrDefault(m => m.GroupInfo.groupId == sender as string); if (groupInfo != null) { groupInfo.DeleteGroupVisibility = Visibility.Collapsed; groupInfo.GroupClassify = 2; //groupInfo.GroupClassifyName = "我加入的"; ManageGroupInfoList.Remove(groupInfo); JoinGroupInfoList.Insert(0, groupInfo); GroupInfoList.Remove(groupInfo); GroupInfoList.Add(groupInfo); //CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(GroupInfoList); //if (view != null) //{ // view.GroupDescriptions.Clear(); // PropertyGroupDescription groupDescription = new PropertyGroupDescription("GroupClassifyName"); // view.GroupDescriptions.Add(groupDescription); //} } } }
//加载界面集合数据 public void LoadGroupListData() { AsyncHandler.AsyncCall(Application.Current.Dispatcher, () => { if (GroupInfoList != null && GroupInfoList.Count > 0) { //var groupInfoLst = GroupInfoList.Where(m => m.GroupClassify == 0); //if (groupInfoLst != null) //{ // var tempGroupLst = groupInfoLst.ToList(); // for (int i = 0; i < tempGroupLst.Count; i++) // { // var groupInfo = tempGroupLst[i]; // groupInfo.GetMembers(); // tempGroupLst[i] = groupInfo; // } //} //我管理的 var tempGroupInfoLst = GroupInfoList.Where(m => m.GroupClassify == 1); var groupInfoViewModels = tempGroupInfoLst as IList <GroupInfoViewModel> ?? tempGroupInfoLst.ToList(); if (ManageGroupInfoList.Count == 0 || ManageGroupInfoList.Count != groupInfoViewModels.Count()) { foreach (var groupInfo in groupInfoViewModels) { if (!ManageGroupInfoList.Contains(groupInfo) && !JoinGroupInfoList.Contains(groupInfo)) { ManageGroupInfoList.Add(groupInfo); } } } //我加入的 var tempJoinGroupInfoLst = GroupInfoList.Where(m => m.GroupClassify == 2); var joinGroupInfoLst = tempJoinGroupInfoLst as IList <GroupInfoViewModel> ?? tempJoinGroupInfoLst.ToList(); if (JoinGroupInfoList.Count == 0 || JoinGroupInfoList.Count != joinGroupInfoLst.Count()) { foreach (var groupInfo in joinGroupInfoLst) { if (!JoinGroupInfoList.Contains(groupInfo) && !ManageGroupInfoList.Contains(groupInfo)) { JoinGroupInfoList.Add(groupInfo); } } } ManageGroupCount = ManageGroupInfoList.Count; JoinGroupCount = JoinGroupInfoList.Count; IsManageGroup = ManageGroupCount != 0; IsJoinGroup = JoinGroupCount != 0; } }, DispatcherPriority.Background); }
/// <summary> /// 讨论组成员信息修改后刷新列表 /// </summary> /// <param name="vm"></param> private void GroupInfoListUpdate(GroupInfoViewModel vm) { if (vm.Members == null) { return; } var tempUser = vm.Members.Find(c => c.userId == AntSdkService.AntSdkLoginOutput.userId && (c.roleLevel == (int)GlobalVariable.GroupRoleLevel.GroupOwner || c.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin)); if (tempUser != null) { if (JoinGroupInfoList.Contains(vm)) { JoinGroupInfoList.Remove(vm); } if (!ManageGroupInfoList.Contains(vm)) { vm.GroupClassify = 1; vm.DeleteGroupVisibility = Visibility.Visible; ManageGroupInfoList.Insert(0, vm); } } else { if (ManageGroupInfoList.Contains(vm)) { ManageGroupInfoList.Remove(vm); } if (!JoinGroupInfoList.Contains(vm)) { vm.GroupClassify = 2; vm.DeleteGroupVisibility = Visibility.Collapsed; JoinGroupInfoList.Insert(0, vm); } } ManageGroupCount = ManageGroupInfoList.Count; JoinGroupCount = JoinGroupInfoList.Count; IsManageGroup = ManageGroupCount != 0; IsJoinGroup = JoinGroupCount != 0; }
/// <summary> /// 新增群组model组装 /// </summary> /// <param name="newGroup"></param> /// <returns></returns> private GroupInfoViewModel AddGroupInfoModel(AntSdkGroupInfo newGroup) { //if (GroupInfoList.FirstOrDefault(c => c.GroupInfo.groupId == group.groupId) != null) return; if (GroupIds.Contains(newGroup.groupId)) { var tempGroupInfoVm = GroupInfoList.FirstOrDefault(c => c.GroupInfo.groupId == newGroup.groupId); if (tempGroupInfoVm != null) { if (tempGroupInfoVm.GroupPicture != newGroup.groupPicture) { tempGroupInfoVm.GroupPicture = newGroup.groupPicture; } var classify = newGroup.groupOwnerId == AntSdkService.AntSdkCurrentUserInfo.userId || (newGroup.managerIds != null && newGroup.managerIds.Contains(AntSdkService.AntSdkCurrentUserInfo.userId)) ? 1 : 2; if (tempGroupInfoVm.GroupClassify != classify) { tempGroupInfoVm.GroupClassify = classify; if (ManageGroupInfoList.Contains(tempGroupInfoVm)) { ManageGroupInfoList.Remove(tempGroupInfoVm); } if (JoinGroupInfoList.Contains(tempGroupInfoVm)) { JoinGroupInfoList.Remove(tempGroupInfoVm); } if (tempGroupInfoVm.GroupClassify == 1) { ManageGroupInfoList.Insert(0, tempGroupInfoVm); } else { JoinGroupInfoList.Insert(0, tempGroupInfoVm); } ManageGroupCount = ManageGroupInfoList.Count; JoinGroupCount = JoinGroupInfoList.Count; } } //tempGroupInfoVm = groupInfoVM; return(tempGroupInfoVm); } GroupInfoViewModel groupInfoVM = new GroupInfoViewModel(newGroup); if (GroupInfos == null) { GroupInfos = new List <AntSdkGroupInfo>(); } GroupInfos.Add(newGroup); GroupIds.Add(newGroup.groupId); GroupInfoList.Add(groupInfoVM); if (groupInfoVM.GroupClassify == 1) { ManageGroupInfoList.Insert(0, groupInfoVM); } else { JoinGroupInfoList.Insert(0, groupInfoVM); } ManageGroupCount = ManageGroupInfoList.Count; JoinGroupCount = JoinGroupInfoList.Count; if (ManageGroupCount > 0) { IsManageGroup = true; } if (JoinGroupCount > 0) { IsJoinGroup = true; } //if (GroupInfoList != null && GroupInfoList.Any()) //{ // CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(GroupInfoList); // if (view != null) // { // view.GroupDescriptions.Clear(); // PropertyGroupDescription groupDescription = new PropertyGroupDescription("GroupClassify"); // view.GroupDescriptions.Add(groupDescription); // } //} List <string> topics = new List <string>(); topics.Add(newGroup.groupId); return(groupInfoVM); }