Esempio n. 1
0
        /// <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;
            }
        }
Esempio n. 2
0
        /// <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;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 确认选中聊天室转发
        /// </summary>
        /// <param name="obj"></param>
        private void SureSelectedChat(object obj)
        {
            ChatInfo chatinfo = SelectedChatList.FirstOrDefault();

            List <FriendViewModel> listFriend = AppData.MainMV.FriendListVM.Items.ToList();
            List <GroupViewModel>  listGroup  = AppData.MainMV.GroupListVM.Items.ToList();
            List <ChatViewModel>   listChat   = AppData.MainMV.ChatListVM.Items.ToList();

            if (_isFromCard)
            {
                var chatvm = AppData.MainMV.ChatListVM.GetChat(chatinfo.ChatID, chatinfo.IsGroup);
                if (chatvm != null)
                {
                    if (_userModel == null)
                    {
                        return;
                    }
                    //if (!AppData.CanInternetAction())
                    //    return;
                    //else
                    //{
                    var          phone = string.Empty;
                    MessageModel msg   = new MessageModel()
                    {
                        Sender       = AppData.Current.LoginUser.User,
                        SendTime     = DateTime.Now,
                        IsMine       = true,
                        MsgType      = MessageType.usercard,
                        MessageState = MessageStates.Loading,
                        Content      = "[个人名片]",
                        TipMessage   = "[个人名片]" + _userModel.DisplayName,
                        Target       = new List <int>()
                        {
                            chatinfo.ID
                        },
                    };
                    if (!string.IsNullOrEmpty(_userModel.PhoneNumber) && _userModel.PhoneNumber.Length == 11)
                    {
                        phone = _userModel.PhoneNumber.Remove(3, 4);
                        phone = phone.Insert(3, "****");
                    }
                    PersonCardModel pcm = new PersonCardModel()
                    {
                        PhoneNumber = phone,
                        PhotoImg    = _userModel.HeadImg,
                        Name        = _userModel.DisplayName,
                        UserId      = _userModel.ID
                    };
                    msg.ContentMD5      = _userModel.HeadImgMD5;
                    msg.PersonCardModel = pcm;
                    chatvm.SendPersonCardToserver(msg);
                }
                //}
            }
            else
            {
                ChatViewModel   chatvm          = AppData.MainMV.ChatListVM.GetChat(this._chatID, this._isGroup);
                FriendViewModel friendViewModel = AppData.MainMV.FriendListVM.Items.ToList().FirstOrDefault(x => x.ID == chatinfo.ChatID);
                //ChatViewModel chatVMNeedSend = AppData.MainMV.ChatListVM.Items.FirstOrDefault(x => x.ID == this._chatID);
                if (friendViewModel.ID == chatvm.ID)
                {
                    AppData.MainMV.TipMessage = "不能给该对象发送名片";
                    return;
                }
                if (chatvm != null && chatvm.Model is ChatModel chatModel)
                {
                    if (friendViewModel.Model is UserModel user)
                    {
                        //if (!AppData.CanInternetAction())
                        //    return;
                        //else
                        //{
                        var          phone = string.Empty;
                        MessageModel msg   = new MessageModel()
                        {
                            Sender       = AppData.Current.LoginUser.User,
                            SendTime     = DateTime.Now,
                            IsMine       = true,
                            MessageState = MessageStates.Loading,
                            MsgType      = MessageType.usercard,
                            Content      = "[个人名片]",
                            TipMessage   = "[个人名片]" + user.DisplayName,
                            Target       = new List <int>()
                            {
                                chatinfo.ID
                            },
                        };
                        if (!string.IsNullOrEmpty(user.PhoneNumber) && user.PhoneNumber.Length == 11)
                        {
                            phone = user.PhoneNumber.Remove(3, 4);
                            phone = phone.Insert(3, "****");
                        }
                        PersonCardModel pcm = new PersonCardModel()
                        {
                            PhoneNumber = phone,
                            PhotoImg    = user.HeadImg,
                            Name        = user.DisplayName,
                            UserId      = user.ID
                        };
                        msg.ContentMD5      = user.HeadImgMD5;
                        msg.PersonCardModel = pcm;
                        chatvm.SendPersonCardToserver(msg);
                    }
                    //}
                }
            }



            App.Current.Dispatcher.Invoke(new Action(() =>
            {
                AppData.MainMV.ChatListVM.ResetSort();
                Thread.Sleep(100);
                AppData.PersonCardWindow?.Close();
            }));
        }