public GroupEditWindowViewModel(Action close, List <string> memberIds, AntSdkGroupInfo groupInfo) { IsCreateGroup = false; Title = "邀请加入讨论组"; this.GroupInfo = groupInfo; OriginalMemberIds = memberIds; this.close = close; ContactInfoViewModel.StateImageClickEvent += StateImageClickEvent; ContactListViewModel = new ContactListViewModel(GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewLeft, this); LeftPartViewModel = ContactListViewModel; foreach (string memberId in memberIds) { AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == memberId); if (user == null)//离职人员信息 { user = new AntSdkContact_User(); user.picture = "pack://application:,,,/AntennaChat;Component/Images/离职人员.png"; user.userName = "******"; user.userId = memberId; } ContactInfoViewModel myselfVM = new ContactInfoViewModel(user, GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewRight); if (myselfVM == null) { continue; } myselfVM.StateImageVisibility = Visibility.Collapsed; GroupMemberList.Add(myselfVM); } MemberCount = string.Format("已选择{0}个联系人", _GroupMemberList.Count()); //GroupName = groupInfo.groupName; GroupNameWateMark = groupInfo.groupName; GroupNameIsReadOnly = true; }
public GroupEditWindowViewModel(Action close, List <string> memberIds) { OriginalMemberIds = memberIds; IsCreateGroup = true; Title = "创建讨论组"; this.close = close; ContactInfoViewModel.StateImageClickEvent += StateImageClickEvent; ContactListViewModel = new ContactListViewModel(GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewLeft, this); LeftPartViewModel = ContactListViewModel; foreach (string id in memberIds) { ContactInfoViewModel vm = new ContactInfoViewModel(AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == id), GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewRight); vm.StateImageVisibility = Visibility.Collapsed; GroupMemberList.Add(vm); } MemberCount = string.Format("已选择{0}个联系人", _GroupMemberList.Count()); }
public MultiContactsSelectViewModel(List <string> memberIds) { OriginalMemberIds = memberIds; Title = "选择联系人"; ContactInfoViewModel.StateImageClickEvent += StateImageClickEvent; ContactListViewModel = new ContactListViewModel(GlobalVariable.ContactInfoViewContainer.MultiContactsSelectLeft, this); LeftPartViewModel = ContactListViewModel; if (memberIds != null) { foreach (string id in memberIds) { ContactInfoViewModel vm = new ContactInfoViewModel(AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == id), GlobalVariable.ContactInfoViewContainer.MultiContactsSelectRight); GroupMemberList.Add(vm); } } MemberCount = string.Format("已选择{0}个联系人", _GroupMemberList.Count()); }
/// <summary> /// 状态图点击事件 /// </summary> /// <param name="sender"></param> /// <param name="isSelect">True表示在创建讨论组左侧选中,False表示在左侧取消选择,Null表示在右侧点击</param> private void StateImageClickEvent(object sender, bool?isSelect) { ContactInfoViewModel senderVM = sender as ContactInfoViewModel; if (senderVM == null) { return; } ContactInfoViewModel existVM = GroupMemberList.FirstOrDefault(c => c.User.userId == senderVM.User.userId); ContactInfoViewModel ContactListTempVM = null; if (ContactListViewModel.ContactInfoViewModelList != null) { ContactListTempVM = ContactListViewModel.ContactInfoViewModelList.FirstOrDefault(c => c.User.userId == senderVM.User.userId); } if (isSelect == true)//选择组织结构列表中联系人 { if (existVM == null) { ContactInfoViewModel tempVM = new ContactInfoViewModel(senderVM.User, GlobalVariable.ContactInfoViewContainer.GroupEditWindowViewRight); GroupMemberList.Add(tempVM); MemberCount = string.Format("已选择{0}个联系人", _GroupMemberList.Count()); //tempVM.MouseLeftButtonDownEvent += ModifyColorOnMouseClick; } //if (ContactListTempVM != null && ContactListTempVM != sender)//如果是从搜索列表里来的 if (ContactListTempVM != null && ContactListTempVM.IsMouseClick == false)//如果是从搜索列表里来的 { ContactListTempVM.OnStateImageClickEventEvent(ContactListTempVM, true); } } else if (isSelect == false)//取消选中组织结构列表中联系人 { if (existVM != null) { GroupMemberList.Remove(existVM); MemberCount = string.Format("已选择{0}个联系人", _GroupMemberList.Count()); } if (ContactListTempVM != null && ContactListTempVM.IsMouseClick == true) { ContactListTempVM.OnStateImageClickEventEvent(ContactListTempVM, false); } } else //从右侧讨论成员中删除联系人 { bool isLeftExist = false; if (ContactListTempVM != null && ContactListTempVM != sender) { ContactListTempVM.OnStateImageClickEventEvent(ContactListTempVM, false); isLeftExist = true; } if (_QueryContactList != null && _QueryContactList.QueryContactList != null) { ContactInfoViewModel tempVM = _QueryContactList.QueryContactList.FirstOrDefault(c => c.User.userId == senderVM.User.userId); if (tempVM != null) { tempVM.OnStateImageClickEventEvent(tempVM, false); isLeftExist = true; } } if (isLeftExist == false)//左侧组织结构或者搜索列表中都还未加载,则直接从右侧列表删除即可 { if (existVM != null) { GroupMemberList.Remove(existVM); MemberCount = string.Format("已选择{0}个联系人", _GroupMemberList.Count()); } } } }