Beispiel #1
0
 /// <summary>
 /// Resets the user list visually and internally. Must be called on UI thread.
 /// </summary>
 private void ResetUserList(IEnumerable <User> usersToAdd, IEnumerable <User> usersToRemove)
 {
     foreach (var u in usersToAdd)
     {
         UserListItems.Add(new ChatUserListItem(this.room, u));
     }
     foreach (var u in usersToRemove)
     {
         UserListItems.Remove(new ChatUserListItem(this.room, u));
     }
     UserListItems.Sort();
     this.needsRefresh = false;
 }
Beispiel #2
0
        /// <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");
            }
        }