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 void ContactInfoViewModel_GetFocusedEvent(object sender, EventArgs args)
        {
            ContactInfoViewModel contractInfoVm = QueryContactList.FirstOrDefault(p => p.IsFocused);

            if (contractInfoVm != null && Container == GlobalVariable.ContactInfoViewContainer.ContactListView)
            {
                contractInfoVm.IsFocused = false;
            }
        }
 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());
 }
Esempio n. 4
0
 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());
 }
Esempio n. 5
0
 /// <summary>
 /// 个人详情
 /// </summary>
 private void PersonalDetail(object personal)
 {
     if (personal is ContactInfoViewModel)
     {
         _contactInfoViewModel = personal as ContactInfoViewModel;
         if (_contactInfoViewModel.User.userId == AntSdkService.AntSdkLoginOutput.userId)
         {
             if (!string.IsNullOrEmpty(AntSdkService.AntSdkCurrentUserInfo.userNum))
             {
                 InfoName = AntSdkService.AntSdkCurrentUserInfo.userNum + AntSdkService.AntSdkCurrentUserInfo.userName;
             }
             else
             {
                 InfoName = AntSdkService.AntSdkCurrentUserInfo.userName;
             }
             LogoBitmapImage = !string.IsNullOrEmpty(AntSdkService.AntSdkCurrentUserInfo.picture)
                 ? AntSdkService.AntSdkCurrentUserInfo.picture
                 : "pack://application:,,,/AntennaChat;Component/Images/198-头像.png";
             Introduce = !string.IsNullOrEmpty(AntSdkService.AntSdkCurrentUserInfo.signature)
                 ? AntSdkService.AntSdkCurrentUserInfo.signature
                 : "这个人很懒,什么都没留下";
             Attribution    = AntSdkService.AntSdkCurrentUserInfo.departName;
             Position       = AntSdkService.AntSdkCurrentUserInfo.position;
             TelphoneNumber = AntSdkService.AntSdkCurrentUserInfo.phone;
             Email          = AntSdkService.AntSdkCurrentUserInfo.email;
         }
         else
         {
             var load = Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 QueryUserInfo(_contactInfoViewModel.User.userId);
             }));
             load.Completed += Load_Completed;
         }
     }
 }
        /// <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());
                    }
                }
            }
        }
 /// <summary>
 /// 查询(暂时支持汉字和首字母查询)
 /// </summary>
 /// <param name="condition"></param>
 public void ResetQueryCondition(string condition)
 {
     AsyncHandler.AsyncCall(Application.Current.Dispatcher, () =>
     {
         if (string.IsNullOrWhiteSpace(condition))
         {
             return;
         }
         if (QueryContactList == null)
         {
             QueryContactList = new ObservableCollection <ContactInfoViewModel>();
         }
         QueryContactList.Clear();
         try
         {
             if (AntSdkService.AntSdkListContactsEntity.users != null)
             {
                 //var userList =
                 //    AntSdkService.AntSdkListContactsEntity.contacts.users.Where(
                 //        m => IsconditionsSatisfy(m.userName, m.userNum));
                 //foreach (AntSdkContact_User user in userList)
                 //{
                 //    ContactInfoViewModel contactInfoViewModel = new ContactInfoViewModel(user, Container, condition);
                 //    contactInfoViewModel.MouseEnter = new DefaultCommand(mouseEnter);
                 //    contactInfoViewModel.MouseLeave = new DefaultCommand(mouseEnter);
                 //    contactInfoViewModel.PlaceholderWidth = 20;
                 //    QueryContactList.Add(contactInfoViewModel);
                 //}
                 var tempUsers = AntSdkService.AntSdkListContactsEntity.users.Where(m => m.status == 2);
                 var i         = 0;
                 foreach (var user in tempUsers)
                 {
                     string pinYin = string.Empty;
                     if (IsconditionsSatisfy(user.userName, user.userNum, ref pinYin))
                     {
                         i++;
                         ContactInfoViewModel contactInfoViewModel = new ContactInfoViewModel(user, Container,
                                                                                              condition, pinYin);
                         contactInfoViewModel.MouseEnter       = new DefaultCommand(mouseEnter);
                         contactInfoViewModel.MouseLeave       = new DefaultCommand(mouseEnter);
                         contactInfoViewModel.PlaceholderWidth = 20;
                         QueryContactList.Add(contactInfoViewModel);
                         if (i > 80)
                         {
                             break;
                         }
                     }
                 }
             }
             if (_groupListViewModel != null)
             {
                 //var groupList =
                 //    _groupListViewModel.GroupInfoList.Where(c => IsconditionsSatisfy(c.GroupInfo.groupName, string.Empty));
                 //foreach (GroupInfoViewModel group in groupList)
                 //{
                 //    ContactInfoViewModel contactInfoViewModel = new ContactInfoViewModel(group, Container, condition)
                 //    {
                 //        MouseEnter = new DefaultCommand(mouseEnter),
                 //        MouseLeave = new DefaultCommand(mouseEnter)
                 //    };
                 //    QueryContactList.Add(contactInfoViewModel);
                 //}
                 foreach (var group in _groupListViewModel.GroupInfoList)
                 {
                     string pinYin = string.Empty;
                     if (IsconditionsSatisfy(group.GroupName, string.Empty, ref pinYin))
                     {
                         ContactInfoViewModel contactInfoViewModel = new ContactInfoViewModel(group, Container,
                                                                                              condition, pinYin)
                         {
                             MouseEnter = new DefaultCommand(mouseEnter),
                             MouseLeave = new DefaultCommand(mouseEnter)
                         };
                         QueryContactList.Add(contactInfoViewModel);
                     }
                 }
             }
             //RaisePropertyChanged(() => QueryContactList);
         }
         catch (Exception e)
         {
             return;
         }
         if (QueryContactList.Count == 0)
         {
             BackImage = Visibility.Visible;
         }
         else
         {
             SelectContactItem = QueryContactList[0];
             BackImage         = Visibility.Collapsed;
         }
     }, DispatcherPriority.Background);
 }
Esempio n. 8
0
        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());
                }
            }
        }
Esempio n. 9
0
        /// <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);
                    }
                }
            });
        }