Пример #1
0
        private void ApplySelectionMode(IEnumerable <FriendHeader> headers)
        {
            IEnumerator <FriendHeader> enumerator = headers.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    FriendHeader current = enumerator.Current;
                    current.IsInSelectedState = this.IsInSelectionMode;
                    current.IsSelected        = false;
                    if (this._isInSelectionMode)
                    {
                        current.PropertyChanged += new PropertyChangedEventHandler(this.fh_PropertyChanged);
                    }
                    else
                    {
                        current.PropertyChanged -= new PropertyChangedEventHandler(this.fh_PropertyChanged);
                    }
                }
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.Dispose();
                }
            }
        }
Пример #2
0
        internal List <FriendHeader> GetAllSelected()
        {
            List <FriendHeader> friendHeaderList            = new List <FriendHeader>();
            IEnumerator <Group <FriendHeader> > enumerator1 = ((Collection <Group <FriendHeader> >) this.Friends.Collection).GetEnumerator();

            try
            {
                while (enumerator1.MoveNext())
                {
                    IEnumerator <FriendHeader> enumerator2 = ((Collection <FriendHeader>)enumerator1.Current).GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            FriendHeader current = enumerator2.Current;
                            if (current.IsSelected)
                            {
                                friendHeaderList.Add(current);
                            }
                        }
                    }
                    finally
                    {
                        if (enumerator2 != null)
                        {
                            enumerator2.Dispose();
                        }
                    }
                }
            }
            finally
            {
                if (enumerator1 != null)
                {
                    enumerator1.Dispose();
                }
            }
            IEnumerator <FriendHeader> enumerator3 = ((Collection <FriendHeader>) this.Lists.Collection).GetEnumerator();

            try
            {
                while (enumerator3.MoveNext())
                {
                    FriendHeader current = enumerator3.Current;
                    if (current.IsSelected)
                    {
                        friendHeaderList.Add(current);
                    }
                }
            }
            finally
            {
                if (enumerator3 != null)
                {
                    enumerator3.Dispose();
                }
            }
            return(friendHeaderList);
        }
Пример #3
0
 internal void Remove(FriendHeader fh)
 {
     foreach (Collection <FriendHeader> allowedDenied in (Collection <Group <FriendHeader> >) this.AllowedDeniedCollection)
     {
         allowedDenied.Remove(fh);
     }
     this.SetToPreviousIfNeeded();
     this.GenerateAllowedDenied();
     this.NotifyPropertyChanged <string>((System.Linq.Expressions.Expression <Func <string> >)(() => this.UserFriendlyDesc));
     this.Save();
 }
Пример #4
0
        internal void HandlePickedUsers(List <User> pickedUsers, List <FriendsList> pickedLists)
        {
            Group <FriendHeader> source1 = this._allowedDeniedCollection.FirstOrDefault <Group <FriendHeader> >((Func <Group <FriendHeader>, bool>)(g => g.Id == this._idOfGroupForUsersPick));
            Group <FriendHeader> source2 = this._allowedDeniedCollection.FirstOrDefault <Group <FriendHeader> >((Func <Group <FriendHeader>, bool>)(g => g.Id != this._idOfGroupForUsersPick));

            if (source1 != null)
            {
                if (!pickedUsers.IsNullOrEmpty())
                {
                    foreach (User pickedUser in pickedUsers)
                    {
                        User u = pickedUser;
                        if (!source1.Any <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.UserId == u.id)))
                        {
                            source1.Add(new FriendHeader(u, false));
                        }
                        if (source2 != null)
                        {
                            FriendHeader friendHeader = source2.FirstOrDefault <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.UserId == u.id));
                            if (friendHeader != null)
                            {
                                source2.Remove(friendHeader);
                            }
                        }
                    }
                }
                if (!pickedLists.IsNullOrEmpty())
                {
                    foreach (FriendsList pickedList in pickedLists)
                    {
                        FriendsList l = pickedList;
                        if (!source1.Any <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.FriendListId == l.id)))
                        {
                            source1.Add(new FriendHeader(l));
                        }
                        if (source2 != null)
                        {
                            FriendHeader friendHeader = source2.FirstOrDefault <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.FriendListId == l.id));
                            if (friendHeader != null)
                            {
                                source2.Remove(friendHeader);
                            }
                        }
                    }
                }
            }
            this.SetToPreviousIfNeeded();
            this.NotifyPropertyChanged <string>((System.Linq.Expressions.Expression <Func <string> >)(() => this.UserFriendlyDesc));
            this.GenerateAllowedDenied();
            this.Save();
        }
Пример #5
0
 public void Handle(UserIsFavedOrUnfavedEvent message)
 {
     if (message.IsFaved)
     {
         this._usersVM.Insert(new FriendHeader(message.user, false), 0);
     }
     else
     {
         FriendHeader friendHeader = (FriendHeader)Enumerable.FirstOrDefault <FriendHeader>(this._usersVM.Collection, (Func <FriendHeader, bool>)(u => u.UserId == message.user.id));
         if (friendHeader == null)
         {
             return;
         }
         this._usersVM.Delete(friendHeader);
     }
 }
Пример #6
0
 public void Handle(UserIsBannedOrUnbannedEvent message)
 {
     if (message.IsBanned)
     {
         FriendHeader friendHeader = new FriendHeader(message.user, false);
         friendHeader.IsInSelectedState = true;
         friendHeader.PropertyChanged  += new PropertyChangedEventHandler(this.p_PropertyChanged);
         this.BannedVM.Insert(friendHeader, 0);
     }
     else
     {
         FriendHeader friendHeader = this.BannedVM.Collection.FirstOrDefault <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.UserId == message.user.uid));
         if (friendHeader == null)
         {
             return;
         }
         this.BannedVM.Delete(friendHeader);
     }
 }
Пример #7
0
 public void Handle(UserIsSubcribedUnsubscribedToEvent message)
 {
     if (this._manageSourcesMode != ManageSourcesMode.ManagePushNotificationsSources)
     {
         return;
     }
     if (message.IsSubscribed)
     {
         this.FriendsVM.LoadData(true, false, null, false);
     }
     else
     {
         FriendHeader friendHeader = (FriendHeader)Enumerable.FirstOrDefault <FriendHeader>(this.FriendsVM.Collection, (Func <FriendHeader, bool>)(fh => fh.UserId == message.user.id));
         if (friendHeader == null)
         {
             return;
         }
         this.FriendsVM.Delete(friendHeader);
     }
 }
Пример #8
0
 public void Handle(UserIsSubcribedUnsubscribedToEvent message)
 {
     if (this._manageSourcesMode != ManageSourcesMode.ManagePushNotificationsSources)
     {
         return;
     }
     if (message.IsSubscribed)
     {
         this.FriendsVM.LoadData(true, false, (Action <BackendResult <ProfilesAndGroups, ResultCode> >)null, false);
     }
     else
     {
         FriendHeader friendHeader = this.FriendsVM.Collection.FirstOrDefault <FriendHeader>((Func <FriendHeader, bool>)(fh => fh.UserId == message.user.id));
         if (friendHeader == null)
         {
             return;
         }
         this.FriendsVM.Delete(friendHeader);
     }
 }
Пример #9
0
        internal void DeleteSelected()
        {
            if (this._isDeleting)
            {
                return;
            }
            this._isDeleting = true;
            List <FriendHeader> fhToDelete = ((IEnumerable <FriendHeader>)Enumerable.Where <FriendHeader>(this._bannedVM.Collection, (Func <FriendHeader, bool>)(fh => fh.IsSelected))).ToList <FriendHeader>();

            if (fhToDelete.Count <= 0)
            {
                return;
            }
            //Action action;
            AccountService.Instance.UnbanUsers((Enumerable.Select <FriendHeader, long>(fhToDelete, (Func <FriendHeader, long>)(fh => fh.UserId))).ToList <long>(), (Action <BackendResult <ResponseWithId, ResultCode> >)(res =>
            {
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    Action arg_27_0 = null;
                    if (arg_27_0 == null)
                    {
                        arg_27_0 = (delegate
                        {
                            using (List <FriendHeader> .Enumerator enumerator = fhToDelete.GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    FriendHeader current = enumerator.Current;
                                    this._bannedVM.Delete(current);
                                }
                            }
                            this.SelectedCount = this.SelectedCount - fhToDelete.Count;
                        });
                    }
                    Execute.ExecuteOnUIThread(arg_27_0);
                }
                this._isDeleting = false;
            }));
        }
Пример #10
0
        internal void Remove(FriendHeader fh)
        {
            IEnumerator <Group <FriendHeader> > enumerator = ((Collection <Group <FriendHeader> >) this.AllowedDeniedCollection).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ((Collection <FriendHeader>)enumerator.Current).Remove(fh);
                }
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.Dispose();
                }
            }
            this.SetToPreviousIfNeeded();
            this.GenerateAllowedDenied();
            // ISSUE: method reference
            this.NotifyPropertyChanged <string>((System.Linq.Expressions.Expression <Func <string> >)(() => this.UserFriendlyDesc));
            this.Save();
        }