コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: xinyangz/FZChat
        //属于命令ChatWithUserCommand
        private void ChatWithUser(object obj)
        {
            ChatListVisibility   = Visibility.Visible;
            ChatMainVisibility   = Visibility.Visible;
            FriendListVisibility = Visibility.Hidden;
            FriendMainVisibility = Visibility.Hidden;
            //查看有无现有聊天
            bool ExistChat = false;

            if (Chats.Count != 0)
            {
                var searchedChats = from c in Chats
                                    where c.Name == selectedUser.NickName
                                    select c;
                if (searchedChats.Count() != 0)
                {
                    ExistChat = true;
                }
            }

            //若已存在,则进入聊天
            if (ExistChat)
            {
                SelectedChat = (from c in Chats
                                where c.Name == selectedUser.NickName
                                select c).Single();
            }
            //若不存在,则创建聊天
            else
            {
                PrivateChat newPrivateChat = new PrivateChat(selectedUser);
                Chats.Add(newPrivateChat);
                SelectedChat = newPrivateChat;
                dataService.GetAllChats();
                Utilities.Messenger.Default.Send(new UpdateChatsMessage(Chats));
            }
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: t103z/FZChat
        //属于命令ChatWithUserCommand
        private void ChatWithUser(object obj)
        {
            ChatListVisibility = Visibility.Visible;
            ChatMainVisibility = Visibility.Visible;
            FriendListVisibility = Visibility.Hidden;
            FriendMainVisibility = Visibility.Hidden;
            //查看有无现有聊天
            bool ExistChat = false;
            if (Chats.Count != 0)
            {
                var searchedChats = from c in Chats
                               where c.Name == selectedUser.NickName
                               select c;
                if (searchedChats.Count() != 0)
                {
                    ExistChat = true;
                }
            }

            //若已存在,则进入聊天
            if (ExistChat)
            {
                SelectedChat = (from c in Chats
                                where c.Name == selectedUser.NickName
                                select c).Single();
            }
            //若不存在,则创建聊天
            else
            {
                PrivateChat newPrivateChat = new PrivateChat(selectedUser);
                Chats.Add(newPrivateChat);
                SelectedChat = newPrivateChat;
                dataService.GetAllChats();
                Utilities.Messenger.Default.Send(new UpdateChatsMessage(Chats));
            }
        }