Exemplo n.º 1
0
        public async void OpenCommentStack(string CommId)
        {
            CommInit = true;

            DisplayControls(CommentControls);

            CommentSection.Visibility = Visibility.Visible;

            bool LoadFirst = true;
            Func <SHTarget, int, uint, string[], PostData> StackRequest = (a, b, c, Ids) =>
            {
                if (LoadFirst)
                {
                    LoadFirst = false;
                    return(Shared.ShRequest.GetCommentStack(Ids[0]));
                }

                return(Shared.ShRequest.GetComments(a, b, c, Ids));
            };

            HSLoader <HSComment> CLoader = new HSLoader <HSComment>(CommId, SHTarget.COMMENT, StackRequest)
            {
                ConvertResult = (x) => x.Flattern(y => y.Replies)
            };

            IEnumerable <HSComment> FirstPage = await CLoader.NextPage();

            CommentsSource = new Observables <HSComment, HSComment>(FirstPage.ToArray());

            CommentsSource.LoadStart += (x, y) => MarkLoading();
            CommentsSource.LoadEnd   += (x, y) => MarkNotLoading();

            CommentsSource.ConnectLoader(CLoader);
            CommentList.ItemsSource = CommentsSource;
        }
Exemplo n.º 2
0
        private async void ReloadComments()
        {
            if (0 < LoadLevel)
            {
                return;
            }

            MarkLoading();
            HSLoader <HSComment> CLoader = new HSLoader <HSComment>(BindItem.Id, SHTarget.SCRIPT, Shared.ShRequest.GetComments)
            {
                ConvertResult = (x) => x.Flattern(y => y.Replies)
            };

            IList <HSComment> FirstPage = await CLoader.NextPage();

            MarkNotLoading();

            if (BindItem.Encrypted)
            {
                if (Crypt == null)
                {
                    CommentsSource = new Observables <HSComment, HSComment>(CrippledComments(FirstPage));
                    CommentsSource.ConnectLoader(CLoader, CrippledComments);
                }
                else
                {
                    CommentsSource = new Observables <HSComment, HSComment>(DecryptComments(FirstPage));
                    CommentsSource.ConnectLoader(CLoader, DecryptComments);
                }
            }
            else
            {
                CommentsSource = new Observables <HSComment, HSComment>(FirstPage);
                CommentsSource.ConnectLoader(CLoader);
            }

            CommentsSource.LoadStart += (x, y) => MarkLoading();
            CommentsSource.LoadEnd   += (x, y) => MarkNotLoading();
            CommentList.ItemsSource   = CommentsSource;
        }
Exemplo n.º 3
0
        private async void ReloadRequests(SHTarget Target)
        {
            if (0 < LoadLevel)
            {
                return;
            }

            ReqTarget = Target;
            MarkLoading();
            HSLoader <SHRequest> CLoader = new HSLoader <SHRequest>(
                BindItem.Id
                , Target
                , (_Target, _Skip, _Limit, _Ids) => Shared.ShRequest.GetRequests(_Target, _Ids[0], _Skip, _Limit)
                );

            CLoader.ConvertResult = xs =>
            {
                XParameter XParam = XGrant.Parameter(BindItem.Id);
                if (XParam != null)
                {
                    foreach (SHRequest x in xs)
                    {
                        x.Granted = XParam.FindParameter(x.Id) != null;
                    }
                }
                return(xs.ToArray());
            };

            IList <SHRequest> FirstPage = await CLoader.NextPage();

            MarkNotLoading();

            RequestsSource = new Observables <SHRequest, SHRequest>(FirstPage);
            RequestsSource.ConnectLoader(CLoader);

            RequestsSource.LoadStart += (x, y) => MarkLoading();
            RequestsSource.LoadEnd   += (x, y) => MarkNotLoading();
            RequestList.ItemsSource   = RequestsSource;
        }
Exemplo n.º 4
0
        private void CommentList_ItemClick(object sender, ItemClickEventArgs e)
        {
            HSComment HSC = ( HSComment )e.ClickedItem;

            if (HSC.Folded)
            {
                if (HSC == HSComment.ActiveInstance)
                {
                    return;
                }
                int i = CommentsSource.IndexOf(HSC);

                // The Load more always appeared in the next level
                // i.e. previous item is always a parent
                HSComment ParentHSC = CommentsSource[i - 1];

                HSLoader <HSComment> CLoader = new HSLoader <HSComment>(ParentHSC.Id, SHTarget.COMMENT, Shared.ShRequest.GetComments)
                {
                    ConvertResult = (x) =>
                                    x.Flattern(y =>
                    {
                        y.Level += HSC.Level;
                        return(y.Replies);
                    })
                };

                CommentsSource.LoadStart += (x, y) => MarkLoading();
                CommentsSource.LoadEnd   += (x, y) => MarkNotLoading();

                // Remove the LoadMore thing
                CommentsSource.RemoveAt(i);
                CommentsSource.InsertLoader(i, CLoader);

                // Load it or else will only be triggered when pgae reads bottom
                var j = CommentsSource.LoadMoreItemsAsync(20);
            }

            HSC.MarkSelect();
        }
Exemplo n.º 5
0
        private void CommentList_ItemClick( object sender, ItemClickEventArgs e )
        {
            HSComment HSC = ( HSComment ) e.ClickedItem;

            if ( HSC.Folded )
            {
                if ( HSC == HSComment.ActiveInstance ) return;
                int i = CommentsSource.IndexOf( HSC );

                // The Load more always appeared in the next level
                // i.e. previous item is always a parent
                HSComment ParentHSC = CommentsSource[ i - 1 ];

                HSLoader<HSComment> CLoader = new HSLoader<HSComment>( ParentHSC.Id, SHTarget.COMMENT, Shared.ShRequest.GetComments )
                {
                    ConvertResult = ( x ) =>
                        x.Flattern( y =>
                        {
                            y.Level += HSC.Level;
                            return y.Replies;
                        } )
                };

                CommentsSource.LoadStart += ( x, y ) => MarkLoading();
                CommentsSource.LoadEnd += ( x, y ) => MarkNotLoading();


                // Remove the LoadMore thing
                CommentsSource.RemoveAt( i );
                CommentsSource.InsertLoader( i, CLoader );
            }

            HSC.MarkSelect();
        }
Exemplo n.º 6
0
        private async void ReloadComments()
        {
            if ( LoadingRing.IsActive ) return;

            MarkLoading();
            HSLoader<HSComment> CLoader = new HSLoader<HSComment>( BindItem.Id, SHTarget.SCRIPT, Shared.ShRequest.GetComments )
            {
                ConvertResult = ( x ) => x.Flattern( y => y.Replies )
            };

            IList<HSComment> FirstPage = await CLoader.NextPage();
            MarkNotLoading();

            if ( BindItem.Encrypted )
            {
                if ( Crypt == null )
                {
                    CommentsSource = new Observables<HSComment, HSComment>( CrippledComments( FirstPage ) );
                    CommentsSource.ConnectLoader( CLoader, CrippledComments );
                }
                else
                {
                    CommentsSource = new Observables<HSComment, HSComment>( DecryptComments( FirstPage ) );
                    CommentsSource.ConnectLoader( CLoader, DecryptComments );
                }
            }
            else
            {
                CommentsSource = new Observables<HSComment, HSComment>( FirstPage );
                CommentsSource.ConnectLoader( CLoader );
            }

            CommentsSource.LoadStart += ( x, y ) => MarkLoading();
            CommentsSource.LoadEnd += ( x, y ) => MarkNotLoading();
            CommentList.ItemsSource = CommentsSource;
        }
Exemplo n.º 7
0
        public async void OpenCommentStack( string CommId )
        {
            CommInit = true;

            DisplayControls( CommentControls );

            SimpleStory.DoubleAnimation(
                CommentStory, CommentSection
                , "(UIElement.RenderTransform).(TranslateTransform.Y)"
                , 0.25 * LayoutSettings.ScreenHeight, 0
            );

            SimpleStory.DoubleAnimation( CommentStory, CommentSection, "Opacity", 0, 1 );

            CommentSection.Visibility = Visibility.Visible;

            bool LoadFirst = true;
            Func<SHTarget, int, uint, string[], PostData> StackRequest = ( a, b, c, Ids ) =>
            {
                if ( LoadFirst )
                {
                    LoadFirst = false;
                    return Shared.ShRequest.GetCommentStack( Ids[ 0 ] );
                }

                return Shared.ShRequest.GetComments( a, b, c, Ids );
            };

            HSLoader<HSComment> CLoader = new HSLoader<HSComment>( CommId, SHTarget.COMMENT, StackRequest )
            {
                ConvertResult = ( x ) => x.Flattern( y => y.Replies )
            };

            IEnumerable<HSComment> FirstPage = await CLoader.NextPage();

            CommentsSource = new Observables<HSComment, HSComment>( FirstPage.ToArray() );

            CommentsSource.LoadStart += ( x, y ) => MarkLoading();
            CommentsSource.LoadEnd += ( x, y ) => MarkNotLoading();

            CommentsSource.ConnectLoader( CLoader );
            CommentList.ItemsSource = CommentsSource;

            CommentStory.Begin();
        }
Exemplo n.º 8
0
        private async void ReloadRequests( SHTarget Target )
        {
            if ( LoadingRing.IsActive ) return;

            ReqTarget = Target;
            MarkLoading();
            HSLoader<SHRequest> CLoader = new HSLoader<SHRequest>(
                BindItem.Id
                , Target
                , ( _Target, _Skip, _Limit, _Ids ) => Shared.ShRequest.GetRequests( _Target, _Ids[0], _Skip, _Limit )
            );
            CLoader.ConvertResult = xs =>
            {
                XParameter XParam = XGrant.Parameter( BindItem.Id );
                if ( XParam != null )
                {
                    foreach ( SHRequest x in xs )
                    {
                        x.Granted = XParam.FindParameter( x.Id ) != null;
                    }
                }
                return xs.ToArray();
            };

            IList<SHRequest> FirstPage = await CLoader.NextPage();
            MarkNotLoading();

            RequestsSource = new Observables<SHRequest, SHRequest>( FirstPage );
            RequestsSource.ConnectLoader( CLoader );

            RequestsSource.LoadStart += ( x, y ) => MarkLoading();
            RequestsSource.LoadEnd += ( x, y ) => MarkNotLoading();
            RequestList.ItemsSource = RequestsSource;
        }