Example #1
0
        public void Load(Forum forum, int page)
        {
            _forum   = forum;
            _curPage = page;
            var api = MainPage.api;

            Title     = _forum.Title; //doesn't do anything other than notify .xaml
            IsLoading = true;

            api.GetThreads(forum.ForumID, page, result =>
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    foreach (Thread t in result)
                    {
                        ThreadsCollection.Add(new ThreadModel(t));
                    }
                    IsLoading = false;
                });
            }, (err, ex) =>
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    System.Windows.MessageBox.Show("Unable to load threads.");
                    Logger.WriteLine(ex);
                    IsLoading = false;
                });
            });
        }
Example #2
0
        public void ChangePage(PageDirection dir)
        {
            var api = MainPage.api;

            if (dir == PageDirection.PREVIOUS)
            {
                if (_curPage == 1)
                {
                    return;
                }
                _curPage--;
            }
            else if (dir == PageDirection.NEXT)
            {
                _curPage++;
            }

            //TODO page count
            ThreadsCollection.Clear();
            IsLoading = true;

            api.GetThreads(_forum.ForumID, _curPage, result =>
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    foreach (Thread t in result)
                    {
                        ThreadsCollection.Add(new ThreadModel(t));
                    }
                    IsLoading = false;
                });
            }, (err, ex) =>
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    System.Windows.MessageBox.Show("Unable to load threads.");
                    IsLoading = false;
                });
            });
        }