Пример #1
0
 private void btn_change_Click(object sender, RoutedEventArgs e)
 {
     if (pages < datas?.Posts.Count - 1)
     {
         pages++;
         Posts posts = datas?.Posts[pages];
         if (posts?.Attachments.Count > 0)
         {
             a_pic.Source = ToolHelper.showNetImage(posts?.Attachments?[0].Url);
         }
         a_content.NavigateToString(ToolHelper.ConvertExtendedASCII(posts?.Content));
         a_author.Content = "by : " + posts?.Author?.Nickname;
         a_title.Content  = posts?.Title;
         a_time.Content   = posts?.Date;
         a_url.Content    = posts?.Url;
     }
     else
     {
         pages = 0;
         Posts posts = datas?.Posts[pages];
         a_pic.Source = ToolHelper.showNetImage(posts?.Attachments?[0].Url);
         a_content.NavigateToString(ToolHelper.ConvertExtendedASCII(posts?.Content));
         a_author.Content = "by : " + posts?.Author?.Nickname;
         a_title.Content  = posts?.Title;
         a_time.Content   = posts?.Date;
         a_url.Content    = posts?.Url;
     }
 }
Пример #2
0
        private void init()
        {
            int code = 0;
            //显示最新文章
            string result = HttpHelper.RequestUrl(Contacts.getAllArticles(), out code);

            a_content.Navigating += a_content_Navigating;

            if (code != -1)
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                datas = js.Deserialize <Datas>(HttpHelper.formatJsonString(result));
                if (datas?.Count > 0)
                {
                    Posts posts = datas?.Posts[0];
                    a_pic.Source = ToolHelper.showNetImage(posts?.Attachments?[0].Url);
                    a_content.NavigateToString(ToolHelper.ConvertExtendedASCII(posts?.Content));
                    a_author.Content = "by : " + posts?.Author?.Nickname;
                    a_title.Content  = posts?.Title;
                    a_time.Content   = posts?.Date;
                    a_url.Content    = posts?.Url;
                }
            }
        }