コード例 #1
0
        private static void OnIsSeparatorVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GameRequestHeaderUC gameRequestHeaderUc = d as GameRequestHeaderUC;

            if (gameRequestHeaderUc == null)
            {
                return;
            }
            // ISSUE: explicit reference operation
            bool newValue = (bool)e.NewValue;

            ((UIElement)gameRequestHeaderUc.separator).Opacity = (newValue ? 1.0 : 0.0);
        }
コード例 #2
0
        public void MarkAllAsRead()
        {
            if (this.ItemsSource == null)
            {
                return;
            }
            List <long> longList = new List <long>();
            IEnumerator <GameRequestHeaderUC> enumerator = ((IEnumerable <GameRequestHeaderUC>)Enumerable.Where <GameRequestHeaderUC>(this.ActualItemsSource, (Func <GameRequestHeaderUC, bool>)(item =>
            {
                if (item.DataProvider != null)
                {
                    return(!item.DataProvider.IsRead);
                }
                return(false);
            }))).GetEnumerator();

            try
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    GameRequestHeaderUC current = enumerator.Current;
                    longList.Add(current.DataProvider.GameRequest.id);
                    current.MarkAsRead();
                    EventAggregator.Current.Publish(new GameRequestReadEvent(current.DataProvider));
                }
            }
            finally
            {
                if (enumerator != null)
                {
                    ((IDisposable)enumerator).Dispose();
                }
            }
            if (longList.Count <= 0)
            {
                return;
            }
            AppsService.Instance.MarkRequestAsRead((IEnumerable <long>)longList, (Action <BackendResult <OwnCounters, ResultCode> >)(result =>
            {
                if (result.ResultCode != ResultCode.Succeeded)
                {
                    return;
                }
                CountersManager.Current.Counters = result.ResultData;
            }));
        }
コード例 #3
0
        private static void DataProvider_OnChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GameRequestHeaderUC gameRequestHeaderUc = d as GameRequestHeaderUC;

            if (gameRequestHeaderUc == null)
            {
                return;
            }
            // ISSUE: explicit reference operation
            GameRequestHeader newValue = e.NewValue as GameRequestHeader;

            if (newValue == null)
            {
                return;
            }
            ((UIElement)gameRequestHeaderUc.textBlockDescription).Visibility = (!string.IsNullOrEmpty(newValue.GameRequest.text) ? Visibility.Visible : Visibility.Collapsed);
        }
コード例 #4
0
        private void DeleteRequestAction(GameRequestHeader gameRequestHeader, Action callback)
        {
            GameRequestHeaderUC uc = this.ActualItemsSource.FirstOrDefault <GameRequestHeaderUC>((Func <GameRequestHeaderUC, bool>)(item => item.DataProvider == gameRequestHeader));

            if (uc == null || uc.DataProvider == null || uc.DataProvider.GameRequest == null)
            {
                return;
            }
            AppsService.Instance.DeleteRequest(uc.DataProvider.GameRequest.id, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    CountersManager.Current.Counters = result.ResultData;
                }
                this.ItemsSource.Remove(this.ItemsSource.FirstOrDefault <GameRequestHeader>(/*func ?? (func = (*/ new Func <GameRequestHeader, bool>(header => header.GameRequest.id == uc.DataProvider.GameRequest.id)));//omg_re
                this.UpdateData();
                if (callback == null)
                {
                    return;
                }
                callback();
            }))));
        }
コード例 #5
0
        private void UpdateData()
        {
            this.ActualItemsSource = null;
            if (this.ItemsSource == null)
            {
                return;
            }
            this._gameRequests = (List <GameRequestHeader>)Enumerable.ToList <GameRequestHeader>(Enumerable.Where <GameRequestHeader>(this.ItemsSource, (Func <GameRequestHeader, bool>)(item =>
            {
                if (item != null)
                {
                    return(!item.IsInvite);
                }
                return(false);
            })));
            List <GameRequestHeader> gameRequestHeaderList = new List <GameRequestHeader>((IEnumerable <GameRequestHeader>)Enumerable.Where <GameRequestHeader>(this._gameRequests, (Func <GameRequestHeader, bool>)(item => !item.IsRead)));

            if (gameRequestHeaderList.Count < this.MaxDisplayedItemsCount && gameRequestHeaderList.Count < this._gameRequests.Count)
            {
                int num = Math.Min(this.MaxDisplayedItemsCount, this._gameRequests.Count) - gameRequestHeaderList.Count;
                gameRequestHeaderList.AddRange((IEnumerable <GameRequestHeader>)Enumerable.Take <GameRequestHeader>(Enumerable.Skip <GameRequestHeader>(this._gameRequests, gameRequestHeaderList.Count), num));
            }
            this.ActualItemsSource = new ObservableCollection <GameRequestHeaderUC>();
            List <GameRequestHeader> .Enumerator enumerator = gameRequestHeaderList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    GameRequestHeader current = enumerator.Current;
                    ObservableCollection <GameRequestHeaderUC> actualItemsSource = this.ActualItemsSource;
                    GameRequestHeaderUC gameRequestHeaderUc = new GameRequestHeaderUC();
                    gameRequestHeaderUc.DataProvider = current;
                    // ISSUE: method pointer
                    Action <GameRequestHeader, Action> action = new Action <GameRequestHeader, Action>(this.DeleteRequestAction);
                    gameRequestHeaderUc.DeleteRequestAction = action;
                    ((Collection <GameRequestHeaderUC>)actualItemsSource).Add(gameRequestHeaderUc);
                }
            }
            finally
            {
                enumerator.Dispose();
            }
            int number = this._gameRequests.Count - ((Collection <GameRequestHeaderUC>) this.ActualItemsSource).Count;

            if (number == 1)
            {
                // ISSUE: method pointer
                ((Collection <GameRequestHeaderUC>) this.ActualItemsSource).Add(new GameRequestHeaderUC()
                {
                    DataProvider        = (GameRequestHeader)Enumerable.Last <GameRequestHeader>(this._gameRequests),
                    DeleteRequestAction = new Action <GameRequestHeader, Action>(this.DeleteRequestAction)
                });
                --number;
            }
            this.UpdateFooterVisibility();
            this.ucFooter.FooterText = UIStringFormatterHelper.FormatNumberOfSomething(number, CommonResources.Games_ShowMoreRequestsOneFrm, CommonResources.Games_ShowMoreRequestsTwoFourFrm, CommonResources.Games_ShowMoreRequestsFiveFrm, true, null, false);
            if (((UIElement)this.ucFooter).Visibility != Visibility.Collapsed || ((Collection <GameRequestHeaderUC>) this.ActualItemsSource).Count <= 0)
            {
                return;
            }
            ((GameRequestHeaderUC)Enumerable.Last <GameRequestHeaderUC>(this.ActualItemsSource)).IsSeparatorVisible = false;
        }