private async void UserName_Click(UserListModel data) { try { var IsAnyUserNameSelected = UserListItems.Where(x => x.Radiobtnimg == "radio_select.png").ToList(); if (IsAnyUserNameSelected.Count > 0 && IsAnyUserNameSelected != null) { foreach (var item in IsAnyUserNameSelected) { item.Radiobtnimg = "radio_unselect.png"; item.NamelblStyle = (Style)App.Current.Resources["LatoRegularGrayLableStyle"]; } } if (data != null) { if (data.Radiobtnimg == "radio_unselect.png") { data.Radiobtnimg = "radio_select.png"; data.NamelblStyle = (Style)App.Current.Resources["LatoBoldDarkBlueLableStyle"]; } else { data.Radiobtnimg = "radio_unselect.png"; data.NamelblStyle = (Style)App.Current.Resources["LatoRegularGrayLableStyle"]; } SelectedUser = data; App.SelectedUserData = SelectedUser; if (!string.IsNullOrEmpty(SelectedUser.name)) { Name = SelectedUser.name; App.SelectedUserData.name = Name; } } } catch (Exception ex) { await ClosePopup(); Debug.WriteLine(ex.Message); } }
/// <summary> /// Resets the user list visually and internally. Must be called on UI thread. /// </summary> private void ResetUserList(User[] fullList, User[] filteredList) { lock (resestLocker) { //Add all users that should exist foreach (var u in fullList) { if (this.UserListItems.All(x => x.User != u)) { UserListItems.Add(new ChatUserListItem(this.Room, u)); } } // remove any users that aren't on the fullList foreach (var u in UserListItems.ToArray()) { if (!fullList.Contains(u.User)) { UserListItems.Remove(u); u.Dispose(); } } // Remove and re add subbed users var tlist = new OrderedObservableCollection <ChatUserListItem>(); foreach (var i in UserListItems) { tlist.Add(i); } foreach (var u in UserListItems.Where(x => x.User.IsSubbed).ToArray()) { var u2 = new ChatUserListItem(Room, u.User); tlist.Remove(u); tlist.Add(u2); if (tlist.IndexOf(u2) == UserListItems.IndexOf(u)) { continue; } UserListItems.Remove(u); u.Dispose(); UserListItems.Add(u2); } foreach (var u in tlist) { u.Dispose(); } tlist.Clear(); // Show all users that should be shown for (var i = 0; i < UserListItems.Count; i++) { if (!filteredList.Contains(UserListItems[i].User)) { //UserListItems[i].Visibility = Visibility.Collapsed; UserListItems[i].Hide(); } else { //UserListItems[i].Visibility = Visibility.Visible; UserListItems[i].Show(); } } foreach (var u in UserListItems) { if (u.ContextMenu == null) { u.ContextMenu = UserContextMenu; } } OnPropertyChanged("IsAdmin"); OnPropertyChanged("IsModerator"); OnPropertyChanged("BanMenuVisible"); } }