示例#1
0
        public async Task DownloadNews()
        {
            //Task downloadTask = MainNewsViewModel.DownloadNews();
            //await downloadTask.ContinueWith(OnDownloadCompleted);
            if (!IsInternet())
            {
                VisibilityLoading = Visibility.Visible;
                VisibilityProgressRing = Visibility.Collapsed;
                LoadingTextBlockText = "No internet connection :(";
                return;
            }

            Task downloadNewsTask = _news.DownloadNews();
            await downloadNewsTask.ContinueWith(OnDownloadCompleted);

            //add to articles
            foreach (var article in _news.Articles)
            {
                ArticleViewModel newArticleViewModel = new ArticleViewModel(
                    article.Date,
                    article.Link,
                    article.Title
                    );

                _articles.Add(newArticleViewModel);
            }
            VisibilityProgressRing = Visibility.Collapsed;

        }
示例#2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            RotationStoryboard.Begin();

            _article = e.Parameter as ArticleViewModel;
            await DownloadArticle();
            //fillContent(content);
            base.OnNavigatedTo(e);
        }
示例#3
0
        public void ConstructorTest()
        {
            //arrange
            //act

            string date = "28.08.15";
            string link = "link";
            string title = "title";
            ArticleViewModel articleViewModel = new ArticleViewModel(date, link, title);

            Assert.AreEqual(date, articleViewModel.Date);
            Assert.AreEqual(link, articleViewModel.Link);
            Assert.AreEqual(title, articleViewModel.Title);
        }
示例#4
0
        private async Task FillRTB(ArticleViewModel article)
        {
            var blocks = await ArticleContentDownloader.GetRichTextBoxContentByLink(article.Link);


            RichContent.Blocks.Clear();
            foreach (Block b in blocks)
                RichContent.Blocks.Add(b);
            TextBlockLoading.Visibility = Visibility.Collapsed;
            RotationStoryboard.Stop();
        }