Пример #1
0
 public PostViewModel(Post post, ApiConfig config)
 {
     _post       = post;
     IsAdmin     = post.Admin != 0;
     Saged       = post.Sage == 1;
     Locked      = post.Lock == 1;
     Top         = post.Top == 1;
     Cookie      = post.Id;
     Name        = post.Name;
     Content     = post.Com;
     ReplyCount  = post.Hr + post.Replys.Count;
     Time        = post.Time;
     No          = post.No;
     _thumbSrc   = post.Img;
     _fullImgSrc = post.Src;
     Threads     = new IncrementalLoadingCollection <ThreadLoader, ThreadViewModel>(
         new ThreadLoader(this._post, config),
         () => { _onError = false; FooterText = Bible.OnLoading; RefreshCommand.RaiseCanExecuteChanged(); }
         , () => { if (!_onError)
                   {
                       FooterText = Bible.OnFinished;
                   }
                   RefreshCommand.RaiseCanExecuteChanged(); },
         (ex) => { FooterText = Bible.OnError; _onError = true; RefreshCommand.RaiseCanExecuteChanged(); });
     ImageSource    = "http:" + _thumbSrc;
     ShowImage      = !string.IsNullOrEmpty((_thumbSrc ?? _fullImgSrc));
     RefreshCommand = new RelayCommand(() => { if (_onError)
                                               {
                                                   Threads.RetryFailed();
                                               }
                                               else
                                               {
                                                   Threads.RefreshAsync();
                                               } }, () => !Threads.IsLoading, true);
 }
Пример #2
0
 public ForumViewModel(Forum forum, ApiConfig config)
 {
     Name  = forum.Name;
     ID    = forum.Id;
     Posts = new IncrementalLoadingCollection <PostLoader, PostViewModel>(
         new PostLoader(this, config),
         () => { _onError = false; FooterText = Bible.OnLoading; RefreshCommand.RaiseCanExecuteChanged(); }
         , () => { if (!_onError)
                   {
                       FooterText = Bible.OnFinished;
                   }
                   RefreshCommand.RaiseCanExecuteChanged(); },
         (ex) => { FooterText = Bible.OnError; _onError = true; RefreshCommand.RaiseCanExecuteChanged(); });
     RefreshCommand = new RelayCommand(() => { if (_onError)
                                               {
                                                   Posts.RetryFailed();
                                               }
                                               else
                                               {
                                                   Posts.RefreshAsync();
                                               } }, () => !Posts.IsLoading, true);
 }