private void PopulateFriendList() { List <Friend> friends = SteamUserHandler.GetFriendList(_account.SteamId, "friend"); foreach ( PlayerSummary friendSummary in friends.Select( friend => SteamUserHandler.GetPlayerSummariesV2(new List <ulong> { friend.SteamId }).FirstOrDefault()) .Where(friendSummary => friendSummary != null)) { FriendSummaries.Add(friendSummary); FriendStateResponse state = ChatHandler.FriendState(IdConversions.UlongToAccountId(friendSummary.SteamId)); friendsStackPanel.Dispatcher.Invoke(() => { var control = new FriendControl(new ChatUser { State = state, Summary = friendSummary }); control.MouseDoubleClick += FriendItem_Clicked; friendsStackPanel.Children.Add(control); }); } friendsStackPanel.Dispatcher.Invoke(() => { //sort List <FriendControl> controls = friendsStackPanel.Children.Cast <FriendControl>().OrderBy(x => x.Friend.Summary.PersonaName).ToList(); friendsStackPanel.Children.Clear(); foreach (FriendControl friendControl in controls) { friendsStackPanel.Children.Add(friendControl); } }); }
private void PopulateFriendList() { List<Friend> friends = SteamUserHandler.GetFriendList(_account.SteamId, "friend"); foreach ( PlayerSummary friendSummary in friends.Select( friend => SteamUserHandler.GetPlayerSummariesV2(new List<ulong> { friend.SteamId }).FirstOrDefault()) .Where(friendSummary => friendSummary != null)) { FriendSummaries.Add(friendSummary); FriendStateResponse state = ChatHandler.FriendState(IdConversions.UlongToAccountId(friendSummary.SteamId)); friendsStackPanel.Dispatcher.Invoke(() => { var control = new FriendControl(new ChatUser { State = state, Summary = friendSummary }); control.MouseDoubleClick += FriendItem_Clicked; friendsStackPanel.Children.Add(control); }); } friendsStackPanel.Dispatcher.Invoke(() => { //sort List<FriendControl> controls = friendsStackPanel.Children.Cast<FriendControl>().OrderBy(x => x.Friend.Summary.PersonaName).ToList(); friendsStackPanel.Children.Clear(); foreach (FriendControl friendControl in controls) { friendsStackPanel.Children.Add(friendControl); } }); }