コード例 #1
0
        static void Main(string[] args)

        {
            FriendList obj = new FriendList();

            obj.Add("Envy");

            obj.Add("Meeny");

            obj.Add("Miny");

            obj.Add("T");

            obj.Remove("T");

            obj.PrintAll();



            Console.WriteLine($"{obj.Capacity}");

            obj.Capacity = 10;

            Console.WriteLine($"{obj.Capacity}");



            Console.WriteLine($"{obj[0]}");

            obj[0] = "Moe";

            obj.PrintAll();
        }
コード例 #2
0
        public async void LoadFriends(string username)
        {
            IsLoading = true;
            var friendManager = new FriendManager();
            var friendEntity  = await friendManager.GetFriendsList(username, Offset, BlockedPlayer, RecentlyPlayed, PersonalDetailSharing, FriendStatus, Requesting, Requested, OnlineFilter, UserAccountEntity);

            if (friendEntity == null)
            {
                //HasMoreItems = false;
                return;
            }
            foreach (var friend in friendEntity.FriendList)
            {
                FriendList.Add(friend);
            }
            if (friendEntity.FriendList.Any())
            {
                HasMoreItems = true;
                Offset       = Offset += 32;
            }
            else
            {
                HasMoreItems = false;
            }
            IsLoading = false;
        }
コード例 #3
0
        private void FriendList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (var friend in e.NewItems.Cast <Friend>())
                {
                    FriendList.Add(new FriendViewModel(friend));
                }
            }

            if (e.OldItems != null)
            {
                var list = e.OldItems
                           .Cast <Friend>()
                           .Select(s => new FriendViewModel(s))
                           .ToList();

                foreach (var friend in FriendList.Where(w => list.Any(a => a.FirebaseKey == w.FirebaseKey)).ToList())
                {
                    FriendList.Remove(friend);
                }
            }

            TestHook?.NotifyOtherThreads();
        }
コード例 #4
0
 /// <summary>
 /// 重置属性
 /// </summary>
 public void InitialProperties()
 {
     groupDesc = "";
     groupName = "";
     SelectedMember.Clear();//清空列表
     FriendList.Clear();
     EnableCreate = true;
     Snackbar     = new SnackbarMessageQueue();
     Task.Run(() =>
     {
         Task.Delay(100);
         var friends = new DataOfFriends().GetFriendsList();
         //填充好友列表
         App.Current.Dispatcher.Invoke(() =>
         {
             foreach (var item in friends)
             {
                 if (item.toUserId == "10000")
                 {
                     continue;
                 }
                 FriendList.Add(item.ToMsgListItem());
             }
         });
     });
 }
コード例 #5
0
        static void Main(string[] args)
        {
            FriendList obj = new FriendList();

            obj.Add("아이유");
            obj.Add("장만월");
            obj.Add("이선균");
            obj.Add("현승이");
            obj.Remove("장만월");
            obj.PrintAll();

            Console.WriteLine($"{obj.Capacity}");
            obj.Capacity = 10;
            Console.WriteLine($"{obj.Capacity}");

            Console.WriteLine(obj[0]);
        }
コード例 #6
0
 private void btnFriendAddOne_Click(object sender, RoutedEventArgs e)
 {
     //ellFriend.Visibility = (ellFriend.Visibility == Visibility.Collapsed) ? Visibility.Visible : Visibility.Visible;
     model.AllFriendWaitReads += 1;
     friends.Add(new Friend {
         UserId = "8888", UserName = "******", IP = "192.168.1.1", status = Status.Offline
     });
 }
コード例 #7
0
        static void Main(string[] args)
        {
            FriendList obj = new FriendList();

            obj.Add("아이유");
            obj.Add("구천성");
            obj.Add("산체스");
            obj.Remove("구천성");
            obj.PrintAll();

            Console.WriteLine(obj.Capacity);
            obj.Capacity = 10;
            Console.WriteLine(obj.Capacity);

            Console.WriteLine(obj[0]);
            obj[0] = "오늘 일찍 끝난다.";
            obj.PrintAll();
        }
コード例 #8
0
        static void Main(string[] args)
        {
            FriendList obj = new FriendList();

            obj.Add("Alice");
            obj.Add("Optimus");
            obj.Add("Bumblebee");
            obj.Add("Thundercracker");
            obj.Remove("Thundercracker");
            obj.PrintAll();

            Console.WriteLine($"{obj.Capacity}");
            obj.Capacity = 10;
            Console.WriteLine($"{obj.Capacity}");

            Console.WriteLine($"{obj[0]}");
            obj[0] = "Jazz";
            obj.PrintAll();
        }
コード例 #9
0
        public void RPC_GetTopAndFriend(ulong roleId, ushort planesId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            TopList.Clear();
            FriendList.Clear();
            var role = this.GetRole(roleId);

            if (role == null)
            {
                Log.Log.Server.Print("RPC_GetTopAndFriend role is null , {0}", roleId);
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)1);
            InitVisitTimes(role);
            pkg.Write(role.RoleData.WorldVisitCount);
            pkg.Write(role.RoleData.FriendVisitCount);
            pkg.Write(role.RoleData.BuyVisitCount);
            pkg.Write(role.RoleData.ByVisitCount);
            List <RankData> rds = _GetFightTopPlayer(planesId);

            pkg.Write((byte)rds.Count);
            foreach (var i in rds)
            {
                pkg.Write(i.RoleId);
                pkg.Write(i.RoleName);
                if (role.VisitTopList.Contains(i.RoleId))
                {
                    pkg.Write((byte)CSCommon.eBoolState.True);
                }
                else
                {
                    pkg.Write((byte)CSCommon.eBoolState.False);
                }
                TopList.Add(i.RoleId);
            }
            UpdateSocialInfoList(CSCommon.eSocialType.Friend, role);
            pkg.Write((byte)role.mSocialInfoList.Count);
            foreach (var j in role.mSocialInfoList.Values)
            {
                pkg.Write(j.id);
                pkg.Write(j.name);
                if (role.VisitFriendList.Contains(j.id))
                {
                    pkg.Write((byte)CSCommon.eBoolState.True);
                }
                else
                {
                    pkg.Write((byte)CSCommon.eBoolState.False);
                }
                FriendList.Add(j.id);
            }
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
コード例 #10
0
 private void ExecuteAddFriend()
 {
     if (addFriend != null && addFriend != "")
     {
         FriendList.Add(addFriend);
     }
     else
     {
         DisplayNoFriendName();
     }
 }
コード例 #11
0
 public FriendViewModel(INavigationService navigationService) : base(navigationService)
 {
     FriendList.Add(new FriendItem()
     {
         Name = "aaaaa", Pubished = DateTime.Parse("2011-10-11")
     });
     FriendList.Add(new FriendItem()
     {
         Name = "aa", Avatar = "/Assets/StoreLogo.png", Content = "24343243243242343243243243243243", Count = 3, Pubished = DateTime.Now
     });
 }
コード例 #12
0
 /// <summary>
 /// Adds or removes an user from the friend list depending on whether
 /// they already are on the friend list.
 /// </summary>
 /// <param name="name">The name of the user.</param>
 public void ToggleFriend(string name)
 {
     if (IsFriend(name))
     {
         FriendList.Remove(name);
     }
     else
     {
         FriendList.Add(name);
     }
 }
コード例 #13
0
        public static void Main(string[] args)
        {
            FriendList obj = new FriendList();

            obj.Add("아이유");
            obj.Add("장만월");
            obj.Add("이선균");
            obj.Add("문재인");
            obj.Remove("장만월");
            obj.PrintAll();

            Console.WriteLine(obj.Capacity);
            obj.Capacity = 10;
            Console.WriteLine(obj.Capacity);

            Console.WriteLine(obj[0]);

            obj[2] = "조국";
            obj.PrintAll();
        }
コード例 #14
0
        static void Main(string[] args)
        {
            FriendList obj = new FriendList();

            obj.Add("Lulu");
            obj.Add("Jinx");
            obj.Add("Nami");
            obj.Add("Sena");
            obj.Add("Lulu");
            obj.PrintAll();

            Console.WriteLine("---------------");

            obj.Capacity = 10;
            obj[0]       = "Niko";
            obj.PrintAll();

            Console.WriteLine("---------------");

            obj.Remove("Nami");
            obj.PrintAll();
        }
コード例 #15
0
        private void DataHandle_UpdateFriendHandler(object sender, User e)
        {
            Friend newfriend = new Friend
            {
                UserId   = e.UserId,
                UserName = e.UserName,
                IP       = e.ip,
                status   = e.IsOnline
            };

            Dispatcher.Invoke(() =>
            {
                friends.Add(newfriend);
            });
        }
コード例 #16
0
        /// <summary>
        /// Adds or removes a specified user to or from the friend list
        /// depending on whether they already are on the friend list.
        /// </summary>
        /// <param name="name">The name of the user.</param>
        public void ToggleFriend(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (IsFriend(name))
            {
                FriendList.Remove(name);
            }
            else
            {
                FriendList.Add(name);
            }

            UserFriendToggled?.Invoke(this, new UserNameEventArgs(name));
        }
コード例 #17
0
        /// <summary>
        /// 异步的加载好友信息
        /// </summary>
        private async Task LoadFriendAsync()
        {
            await ClientHelper.WaitAsync(() => RequestResultAction == null, -1);

            RequestResultAction = new Action <RequestResult>((RequestResult result) =>
            {
                User[] users = result.Object as User[];
                if (users == null)
                {
                    return;
                }

                Home.HomeWindow.Dispatcher.Invoke(() =>
                {
                    var messageRecord = CopyMessageRecord();
                    MessageRecord.Clear();
                    FriendList.Clear();

                    foreach (var user in users)
                    {
                        FriendList.Add(_dataService.GetUserModel(user));
                        MessageRecord.Add(user.UserName, new List <MessageModel>());
                        if (messageRecord.ContainsKey(user.UserName))
                        {
                            foreach (var messageModel in messageRecord[user.UserName])
                            {
                                MessageRecord[user.UserName].Add(messageModel);
                            }
                        }
                    }
                });
            });

            if (!Config.MiniClient.SendDatabaseRequest(new User()
            {
                UserName = UserModel.UserName
            }, "GetFriends", null))
            {
                RequestResultAction = null;
                MessageBox.Show("加载好友数据时发生错误!", Config.Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #18
0
 public void AddToFriendList(User user)
 {
     FriendList.Add(user);
 }
コード例 #19
0
        public ClientWindow(TCPHelper helper, List <User> users, List <TalkContract> talks, List <AddFriend> addFriends, string id, string name)
        {
            this.UserName            = name;
            model                    = new ClientViewModel();
            friends                  = new FriendList();
            chats                    = new ChatList();
            notices                  = new NoticeList();
            model.AllNoticeWaitReads = 0;
            model.AllFriendWaitReads = 0;
            model.AllChatWaitReads   = 0;
            #region 数据到视图模型的转换
            foreach (var u in users)
            {
                friends.Add(new Friend {
                    UserId = u.UserId, UserName = u.UserName, IP = u.ip, status = u.IsOnline
                });
            }
            var senders = talks.Select(p => p.SenderId).ToList().Distinct();
            foreach (var s in senders)
            {
                MsgList m       = new MsgList();
                var     records = talks.Where(p => p.SenderId.Equals(s)).Select(q => q).ToList();
                foreach (var r in records)
                {
                    m.Add(new PerMsg
                    {
                        SenderName = talks.Where(p => p.SenderId.Equals(r.SenderId)).Select(q => q.SenderName).FirstOrDefault(),
                        Msg        = r.Content
                    });
                }
                chats.Add(new Chat {
                    SenderId = s, SenderName = talks.Where(p => p.SenderId.Equals(s)).Select(p => p.SenderName).FirstOrDefault(), ReceiverId = talks.Where(x => x.SenderId.Equals(s)).Select(y => y.ReceiverId).FirstOrDefault(), Msgs = m, WaitReadNum = m.Count
                });
            }
            foreach (var n in addFriends)
            {
                notices.Add(new Notice {
                    UserId = n.UserId, UserName = "******", status = Status.Waiting
                });
            }

            foreach (var c in chats)
            {
                model.AllChatWaitReads += c.WaitReadNum;
            }
            model.AllNoticeWaitReads = notices.Count();
            #endregion

            this.LocalId = id;

            InitializeComponent();
            this.Closing += ClientWindow_Closing;
            CC.DataHandle.UpdateFriendHandler += DataHandle_UpdateFriendHandler;
            CC.DataHandle.SearchHandler       += SearchCallBack;
            CC.DataHandle.AddComfirmHandler   += AddComfimCallback;
            CC.DataHandle.RemoveFriendHandler += DataHandle_RemoveFriendHandler;
            CC.DataHandle.GetMsgHandler       += GetMsgHandler;
            WindowStartupLocation              = WindowStartupLocation.CenterScreen;
            this.lblID.Content = LocalId;
            this.helper        = helper;
            //绑定关联数据

            this.tabMain.DataContext = model;
            this.gChat.DataContext   = chats;
            this.gFriend.DataContext = friends;
            this.gNotice.DataContext = notices;

            this.listChat.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(listChat_MouseLeftButtonDown), true);
            this.listChat.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(listChat_MouseRightButtonDown), true);
            this.listNotice.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(listNotice_MouseLeftButtonDown), true);
        }
コード例 #20
0
        public void ProcessRequest()
        {
            AuthUser my = My;
            int      friendGroupID;
            bool     useDefault = _Request.Get("default", Method.Get, "").ToLower() == "true";

            if (useDefault)
            {
                friendGroupID = my.SelectFriendGroupID;
            }
            else
            {
                friendGroupID = _Request.Get <int>("groupid", Method.Get, -1);
            }

            if (my.SelectFriendGroupID != friendGroupID)
            {
                my.SelectFriendGroupID = friendGroupID;
                try
                {
                    UserBO.Instance.UpdateUserSelectFriendGroupID(my, friendGroupID);
                }
                catch (Exception ex)
                {
                    LogHelper.CreateErrorLog(ex);
                }
            }

            List <int>       currentGroupUserIDs = new List <int>();
            FriendCollection friends             = FriendBO.Instance.GetFriends(my.UserID);

            Dictionary <int, int> onlineCount = new Dictionary <int, int>();

            foreach (Friend friend in friends)
            {
                if (friend.GroupID == friendGroupID)
                {
                    currentGroupUserIDs.Add(friend.UserID);
                    if (friend.GroupID == my.SelectFriendGroupID)
                    {
                        FriendList.Add(friend);
                    }
                }

#if !Passport
                if (friend.IsOnline)
                {
                    if (onlineCount.ContainsKey(friend.GroupID))
                    {
                        onlineCount[friend.GroupID] += 1;
                    }
                    else
                    {
                        onlineCount.Add(friend.GroupID, 1);
                    }
                }
#endif
            }

            foreach (FriendGroup group in my.FriendGroups)
            {
                int count;
                if (
                    onlineCount.TryGetValue(group.GroupID, out count))
                {
                    group.OnlineCount = count;
                }
                group.IsSelect = group.GroupID == my.SelectFriendGroupID;
            }

            UserBO.Instance.FillSimpleUsers <Friend>(this.FriendList);

            //SimpleUserCollection users = UserBO.Instance.GetSimpleUsers(currentGroupUserIDs, GetUserOption.Default);
        }