Exemple #1
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="e"></param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            object[] parameters = e.Parameter as object[];
            if (parameters != null)
            {
                if (parameters.Length == 1 && (parameters[0] as CNBlog) != null)
                {
                    _blog = parameters[0] as CNBlog;

                    BlogTitle.Text     = _blog.Title;
                    AuthorName.Content = _blog.AuthorName;
                    PublishTime.Text   = _blog.PublishTime;
                    Views.Text         = _blog.Views;
                    Diggs.Text         = "[" + _blog.Diggs + "]";
                    Comments.Text      = _blog.Comments;
                    BitmapImage bi = new BitmapImage {
                        UriSource = new Uri(_blog.AuthorAvator)
                    };
                    Avatar.Source  = bi;
                    AuthorName.Tag = _blog.BlogApp;
                    string blog_body = await BlogService.GetBlogContentAsync(_blog.ID);

                    if (blog_body != null)
                    {
                        if (App.Theme == ApplicationTheme.Dark)  //暗主题
                        {
                            blog_body += "<style>body{background-color:black;color:white;}</style>";
                        }
                        BlogContent.NavigateToString(blog_body);
                    }
                    Loading.IsActive = false;
                }
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            object[] parameters = e.Parameter as object[];
            if (parameters != null)
            {
                if (parameters.Length == 1 && (parameters[0] as CnBlog) != null)
                {
                    _blog = parameters[0] as CnBlog;

                    BlogTitle.Text     = _blog.Title;
                    AuthorName.Content = _blog.AuthorName;
                    PublishTime.Text   = _blog.PublishTime;
                    Views.Text         = _blog.Views;
                    Diggs.Text         = "[" + _blog.Diggs + "]";
                    Comments.Text      = _blog.Comments;
                    BitmapImage bi = new BitmapImage {
                        UriSource = new Uri(_blog.AuthorAvator)
                    };
                    Avatar.Source  = bi;
                    AuthorName.Tag = _blog.BlogApp;
                    string blogBody = await BlogService.GetBlogContentAsync(_blog.Id);

                    if (blogBody != null)
                    {
                        HideScrollbar(ref blogBody);
                        BlogContent.NavigateToString(blogBody);
                    }

                    // 获取评论数据
                    _commentHtml = CommentTool.BaseChatHtml;
                    HideScrollbar(ref _commentHtml);
                    BlogComment.NavigateToString(_commentHtml);
                    List <CnBlogComment> listComments = await BlogService.GetBlogCommentsAsync(_blog.Id, 1, 199);

                    if (listComments != null)
                    {
                        string comments = "";
                        foreach (CnBlogComment comment in listComments)
                        {
                            comments += CommentTool.Receive(comment.AuthorAvatar,
                                                            comment.AuthorName == _blog.AuthorName ? "[博主]" + _blog.AuthorName : comment.AuthorName,
                                                            comment.Content, comment.PublishTime, comment.Id);
                        }

                        _commentHtml = _commentHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>";
                        Debug.Write(_commentHtml);
                        HideScrollbar(ref _commentHtml);
                        BlogComment.NavigateToString(_commentHtml);
                    }

                    Loading.IsActive = false;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 点击标题栏上的刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            Loading.IsActive = true;
            string blog_body = await BlogService.GetBlogContentAsync(_blog.ID);

            if (blog_body != null)
            {
                BlogContent.NavigateToString(blog_body);
                Loading.IsActive = false;
            }
        }
Exemple #4
0
        private async void Refresh(uint id)
        {
            blog = await blogApi.GetBlog(id);

            BlogContent.NavigateToString(blog.Content);
        }