<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using HtmlAgilityPack;

namespace cnblogs.ContentViews
{
    public partial class itemSearch : PhoneApplicationPage
    {

        private string searchValueHttpUri;

        private int pageValue = 1;

        public itemSearch()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

            if (NavigationContext.QueryString.Count > 0)
            {
                searchValueHttpUri = NavigationContext.QueryString["searchParam"];
                getSearchResult(searchValueHttpUri, pageValue);
            }
            


        }

        private void getSearchResult(string searchValueHttpUri, int pageParam)
        {

            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocCompleteSearch);

            htmlDoc.LoadAsync("http://zzk.cnblogs.com/s?w=" + searchValueHttpUri + "&t=b&p=" + pageParam + "");

        }


        private void htmlDocCompleteSearch(object sender, HtmlDocumentLoadCompleted e)
        {

            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;
                if (htmlDoc != null)
                {
                    List<SearchEntity> searchList = new List<SearchEntity>();

                    HtmlNode node = htmlDoc.GetElementbyId("searchResult");

                    HtmlNodeCollection noC = node.SelectNodes("//*[@class=\"searchItem\"]");

                    foreach (HtmlNode h in noC)
                    {
                        HtmlNode hn1 = HtmlNode.CreateNode(h.OuterHtml);
                        SearchEntity search = new SearchEntity();

                        foreach (HtmlNode child in hn1.ChildNodes)
                        {

                            if (child.Attributes["class"] != null && child.Attributes["class"].Value == "searchItemTitle")
                            {
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);

                                string searchTitleValue = hsn.SelectSingleNode("//*[@class=\"searchItemTitle\"]").InnerText.Trim();
                                search.searchTitle = searchTitleValue;
                                //MessageBox.Show("searchTitle--------------" + searchTitleValue);
                            }

                            else if (child.Attributes["class"] != null && child.Attributes["class"].Value == "searchCon")
                            {
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);


                                string searchConValue = hsn.SelectSingleNode("//*[@class=\"searchCon\"]").InnerText.Trim();
                                search.searchCon = searchConValue;

                                //MessageBox.Show("searchCon--------------" + searchConValue);
                            }

                            else if (child.Attributes["class"] != null && child.Attributes["class"].Value == "searchItemInfo")
                            {


                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                foreach (HtmlNode searchItemInfoChild in hsn.ChildNodes)
                                {
                                    if (searchItemInfoChild.Attributes["class"] != null && searchItemInfoChild.Attributes["class"].Value == "searchItemInfo")
                                    {
                                        string userName = searchItemInfoChild.SelectSingleNode("//*[@class=\"searchItemInfo-userName\"]").InnerText.Trim();
                                        string publishDate = searchItemInfoChild.SelectSingleNode("//*[@class=\"searchItemInfo-publishDate\"]").InnerText.Trim();
                                        string good = searchItemInfoChild.SelectSingleNode("//*[@class=\"searchItemInfo-good\"]").InnerText.Trim();
                                        string comments = searchItemInfoChild.SelectSingleNode("//*[@class=\"searchItemInfo-comments\"]").InnerText.Trim();
                                        string views = searchItemInfoChild.SelectSingleNode("//*[@class=\"searchItemInfo-views\"]").InnerText.Trim();
                                        string searchInfoValue = userName + publishDate + good + comments + views;
                                        search.searchInfo = searchInfoValue;
                                        //MessageBox.Show("searchInfo--------------" + userName+publishDate+good+comments+views);
                                    }

                                    if (searchItemInfoChild.Attributes["class"] != null && searchItemInfoChild.Attributes["class"].Value == "searchURL")
                                    {
                                        string searchURLValue = searchItemInfoChild.SelectSingleNode("//*[@class=\"searchURL\"]").InnerText.Trim();
                                        search.searchURL = searchURLValue;
                                        //MessageBox.Show("searchInfo--------------" + searchURLValue);
                                    }
                                }



                                //string searchInfo = child.SelectSingleNode("//*[@class=\"searchItemInfo\"]").InnerText;
                                //MessageBox.Show("searchInfo--------------" + searchInfo);
                            }


                        }

                        searchList.Add(search);
                    }


                    this.listBox1.ItemsSource = searchList;

                }

            }

        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("button1");
            pageValue--;
            if (pageValue < 1)
            {
                pageValue = 1;
            }
            getSearchResult(searchValueHttpUri, pageValue);
        }

        private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
        {
            pageValue++;
            if (pageValue >= 100)
            {
                pageValue = 100;
            }
            getSearchResult(searchValueHttpUri, pageValue);
        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using WP7_WebLib.HttpPost;
using System.IO;

namespace cnblogs.Views
{
    public partial class login : PhoneApplicationPage
    {
        public login()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            /**Dictionary<string, object> parameters = new Dictionary<string, object>();

            parameters.Add("__EVENTARGUMENT", "");
            parameters.Add("__EVENTTARGET", "");
            parameters.Add("__EVENTVALIDATION", "/w<KEY>");
            parameters.Add("__VIEWSTATE", "/wEPDwULLTE1MzYzODg2NzZkGAEFHl9fQ29udHJvbHNSZX<KEY>");

            parameters.Add("btnLogin", "登 录");
            //parameters.Add("chkRemember", "on");
            parameters.Add("tbPassword", "<PASSWORD>..");
            parameters.Add("tbUserName", "shandowsoftware");
            parameters.Add("txtReturnUrl", "http://home.cnblogs.com/");*/

            //getResponseHtml(parameters);


            /**CookieContainer myCookie = new CookieContainer();
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://passport.cnblogs.com/login.aspx");
            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            
            myRequest.CookieContainer = myCookie;
            myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);*/
            string username=this.username.Text;
            string password = this.password.Password;
            
            NavigationService.Navigate(new Uri("/Views/flashMemory.xaml?username="+username+"&password="+password+"", UriKind.Relative));
        }


        private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
            System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);

            // Prepare Parameters String
            string parametersString = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE1MzYzODg2NzZkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQtjaGtSZW1lbWJlcm1QYDyKKI9af4b67Mzq2xFaL9Bt&__EVENTVALIDATION=%2FwEdAAUyDI6H%2Fs9f%2BZALqNAA4PyUhI6Xi65hwcQ8%2FQoQCF8JIahXufbhIqPmwKf992GTkd0wq1PKp6%2B%2F1yNGng6H71Uxop4oRunf14dz2Zt2%2BQKDEIYpifFQj3yQiLk3eeHVQqcjiaAP&tbUserName=shandowsoftware&tbPassword=<PASSWORD>..&chkRemember=on&btnLogin=%E7%99%BB++%E5%BD%95&txtReturnUrl=http://home.cnblogs.com/";
                
                
            //foreach (KeyValuePair<string, string> parameter in parameters)
            //{
            //    parametersString = parametersString + (parametersString != "" ? "&" : "") + string.Format("{0}={1}", parameter.Key, parameter.Value);
            //}

            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(parametersString);
            // Write to the request stream.
            postStream.Write(byteArray, 0, parametersString.Length);
            postStream.Close();
            // Start the asynchronous operation to get the response
            request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
        }



        private void GetResponseCallback(IAsyncResult asynchronousResult)
        {
            Stream streamResponse = null;
            string responseString = null;
            try 
            {
                HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                streamResponse = response.GetResponseStream();
                CookieCollection cookieColl = response.Cookies;
                using (StreamReader streamRead = new StreamReader(streamResponse))
                {
                    responseString = streamRead.ReadToEnd();
                }
            }
            catch { }
            finally 
            {
                if(streamResponse!=null)
                {
                    streamResponse.Close();
                }
            }

            if(responseString!=null)
            {
                Dispatcher.BeginInvoke(() => 
                {
                    string result=responseString.Substring(400,1400);
                    textBlockResult.Text =result; 
                });
            }



            /**StreamReader streamRead = new StreamReader(streamResponse);
            string responseString = streamRead.ReadToEnd();

            Dispatcher.BeginInvoke(() => { textBlockResult.Text = responseString; });



            // Close the stream object
            streamResponse.Close();
            streamRead.Close();*/


        }




       /** private void GetResponseCallback(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
            Stream streamResponse = response.GetResponseStream();
            CookieCollection cookieColl = response.Cookies;
            StreamReader streamRead = new StreamReader(streamResponse);
            string responseString = streamRead.ReadToEnd();
        
            Dispatcher.BeginInvoke(() => { textBlockResult.Text = responseString; });

            

            // Close the stream object
            streamResponse.Close();
            streamRead.Close();

        
        }*/






        /**public void getResponseHtml(Dictionary<string, object> parameters)
        {

            PostClient proxy = new PostClient(parameters);
            proxy.DownloadStringCompleted += (sender, e) =>
            {
                if (e.Error == null)
                {
                    //Process the result... 
                    string data = e.Result;

                    MessageBox.Show(data);
                }
            };
            proxy.DownloadStringAsync(new Uri("http://passport.cnblogs.com/login.aspx", UriKind.Absolute));
        
        }  */     

    }
}<file_sep>﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PhoneApp1
{
    public class Question
    {
        public string questionTitle { get; set; }
        public string questionLink { get; set; }
        public string questionIntroduce { get; set; }
        public string questionInfo { get; set; }
        public string questionUserImage { get; set; }
        public string questionGoldImage { get; set; }
        public string questionGoldCount { get; set; }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using HtmlAgilityPack;
using System.IO;
using System.Text;

namespace cnblogs.ContentViews
{
    public partial class QuestionContent : PhoneApplicationPage
    {
        public QuestionContent()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (NavigationContext.QueryString.Count > 0)
            {
                string titleHttpUri = NavigationContext.QueryString["titleLinkValue"];
                string questionUrl = "http://q.cnblogs.com"+titleHttpUri;
                //MessageBox.Show(questionUrl);

                HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();

                htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocComplete);
                htmlDoc.LoadAsync(questionUrl);

            }
        }



        private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;
                if (htmlDoc != null)
                {
                    HtmlNode node = htmlDoc.GetElementbyId("main");
                    //HtmlNode answerNode= htmlDoc.GetElementbyId("panelAnswerList");
                    //MessageBox.Show(node.InnerHtml);
                    string str = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" +
                    "<title></title></head><body>" + node.InnerHtml + "<p></p>"+"</body></html>";

                    string result = ConvertEncode(str);
                    myWebBrowser.NavigateToString(result);

                }
            }

        }

        /// <summary>
        /// 将字符串编码格式转换为unicode
        /// </summary>
        /// <param name="strSource"></param>
        /// <returns></returns>
        private string ConvertEncode(string strSource)
        {
            MemoryStream mstream = new MemoryStream(Encoding.UTF8.GetBytes(strSource));
            StreamReader reader = new StreamReader(mstream, Encoding.Unicode);
            string strResult = reader.ReadToEnd();
            reader.Close();
            mstream.Dispose();
            reader.Dispose();
            return strResult;
        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using PhoneApp1;
using HtmlAgilityPack;
using System.Xml.XPath;


namespace cnblogs
{
    public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            // 将 listbox 控件的数据上下文设置为示例数据
            DataContext = App.ViewModel;
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        // 为 ViewModel 项加载数据
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData();
            }
        }

        private void PanoramaItem_Loaded(object sender, RoutedEventArgs e)
        {
            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocComplete);

            htmlDoc.LoadAsync("http://www.cnblogs.com/");
        }

        private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;


                if (htmlDoc != null)
                {
                    HtmlNode node = htmlDoc.GetElementbyId("headline_block");
                    //IEnumerable<HtmlNode>  nodeList =htmlDoc.DocumentNode.Descendants("a");
                    HtmlNode hn = HtmlNode.CreateNode(node.OuterHtml);
                    IEnumerable<HtmlNode> nodeList = hn.Descendants("a");
                    List<Recom> listContent = new List<Recom>();
                    
                    int index = 0;

                    foreach (HtmlNode item in nodeList)
                    {


                        index++;
    
                        string title = item.InnerText;

                        if (title == null || title.Length < 2)
                            continue;
                        
                        //MessageBox.Show("test-----------" + index);
                        string recomTitle = title;
                        //MessageBox.Show("out--------" + title);
                        string titlelnk = item.GetAttributeValue("href", "");
                        //MessageBox.Show("titlelnk--------" + titlelnk);
                        string viewsTitleLnk="";
                        Recom recom = new Recom();

                        if(index==1){
                            viewsTitleLnk=  titlelnk + "&&" + "/ContentViews/";
                        }else if(index==3||index==5){
                            viewsTitleLnk=  titlelnk + "&&" + "/ContentViews/indexContent.xaml";
                            recom.viweImages = "/images/cream.png";
                        }else if(index==6||index==8){
                            viewsTitleLnk = titlelnk + "&&" + "/ContentViews/nowNewsContent.xaml";
                            recom.viweImages = "/images/news.png";
                        }

                        
                        recom.recomTitle = recomTitle;
                        recom.titleLink = viewsTitleLnk;
                        listContent.Add(recom);

                        
                    }

                    this.listBox1.ItemsSource = listContent;

                }
            }

        }

        private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TextBlock textBlock = (TextBlock)e.OriginalSource;

            string tagLink = (string)textBlock.Tag;
            int index=tagLink.IndexOf("&&");
            

            string titleLink = tagLink.Substring(0,tagLink.IndexOf("&&"));
            string viewsLink = tagLink.Substring(tagLink.IndexOf("&&")+2);
            //MessageBox.Show("viewsLink--------" + viewsLink);
            //MessageBox.Show("this is -----------" + titleLink);


            NavigationService.Navigate(new Uri("" + viewsLink + "?titleLinkValue=" + titleLink + "", UriKind.Relative));
        }


        /// <summary>
        /// 首页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost1_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/index.xaml", UriKind.Relative));
        }
        /// <summary>
        /// 候选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost2_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/wait.xaml", UriKind.Relative));
        }
        /// <summary>
        /// 推荐
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost5_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/login.xaml", UriKind.Relative));
        }
        /// <summary>
        /// 精华
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost4_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/cream.xaml", UriKind.Relative));
        }
        /// <summary>
        /// 新闻
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost3_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/nowNews.xaml", UriKind.Relative));
        }
        /// <summary>
        /// 关于
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost6_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/about.xaml", UriKind.Relative));
        }

        /// <summary>
        /// 加载问答列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PanoramaItem_Loaded_1(object sender, RoutedEventArgs e)
        {
            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocCompleteQuestion);

            htmlDoc.LoadAsync("http://q.cnblogs.com/");
        }


        private void htmlDocCompleteQuestion(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;
                if (htmlDoc != null)
                {

                    List<Question> listContent = new List<Question>();

                    HtmlNode node = htmlDoc.GetElementbyId("main");
                    HtmlNode hn = HtmlNode.CreateNode(node.OuterHtml);
                    HtmlNodeCollection noC = hn.SelectNodes("//*[@class=\"one_entity\"]");



                    foreach (HtmlNode h in noC)
                    {

                        HtmlNode hn1 = HtmlNode.CreateNode(h.OuterHtml);


                        //MessageBox.Show("hn1------"+hn1.InnerHtml);
                        foreach (HtmlNode child in hn1.ChildNodes)
                        {

                            Question question = new Question();
                            /**if (child.Attributes["class"] == null || child.Attributes["class"].Value != "answercount")
                                continue;
                                
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                string answerCount = hsn.InnerText.Trim();
                                MessageBox.Show(answerCount.Substring(0,answerCount.IndexOf("回答数")).Trim());*/


                            if (child.Attributes["class"] != null && child.Attributes["class"].Value == "answercount")
                            {
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                string answerCount = hsn.InnerText.Trim();
                                //MessageBox.Show(answerCount.Substring(0, answerCount.IndexOf("回答数")).Trim());//回答人数


                            }
                            else if (child.Attributes["class"] != null && child.Attributes["class"].Value == "news_item")
                            {
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                HtmlNode gold = hsn.SelectSingleNode("//*[@class=\"gold\"]");
                                string goldCount = "";
                                if (gold != null)
                                {
                                    goldCount = gold.InnerText.Trim();
                                    //MessageBox.Show("gold----------" + gold.InnerText.Trim());  //悬赏金币
                                }
                                else
                                {
                                    goldCount = "0";
                                    //MessageBox.Show("gold----------0");                   //悬赏金币 空则为0
                                }

                                IEnumerable<HtmlNode> nodeList = hsn.SelectSingleNode("//*[@class=\"news_entry\"]").Descendants("a");
                                string title = "";
                                string titlelink = "";
                                foreach (HtmlNode item in nodeList)
                                {
                                    title = item.InnerHtml.Trim();
                                    titlelink = item.GetAttributeValue("href", "");

                                    //MessageBox.Show("out--------" + item.InnerHtml.Trim());  //问题标题
                                }


                                HtmlNode questionIntroduce = hsn.SelectSingleNode("//*[@class=\"news_summary\"]");
                                HtmlNode questionAuthor = hsn.SelectSingleNode("//*[@class=\"news_contributor\"]");
                                HtmlNode questionPushDate = hsn.SelectSingleNode("//*[@class=\"date\"]");

                                IEnumerable<HtmlNode> imgAuthorList = hsn.SelectSingleNode("//*[@class=\"author\"]").Descendants("img");

                                foreach (HtmlNode imgAuthor in imgAuthorList)
                                {

                                    string userImage = imgAuthor.GetAttributeValue("src", "");
                                    if (userImage.IndexOf(".gif") > -1)
                                    {
                                        question.questionUserImage = "/images/UserNo-Frame.png";
                                    }
                                    else
                                    {
                                        question.questionUserImage = userImage;
                                    }

                                    //MessageBox.Show("out--------" + item.InnerHtml.Trim());  //问题标题
                                }



                                string introduce = questionIntroduce.InnerText.Trim();
                                string author = questionAuthor.InnerText.Trim();
                                string date = questionPushDate.InnerText.Trim();

                                question.questionTitle = title;
                                question.questionLink = titlelink;
                                question.questionIntroduce = introduce;
                                question.questionInfo = author + "  " + date;
                                question.questionGoldImage = "/images/gold.png";
                                question.questionGoldCount = goldCount;

                                listContent.Add(question);
                                //MessageBox.Show("questionIntroduce------------" + questionIntroduce.InnerText.Trim());   //问题简介
                                //MessageBox.Show("news_footer----------" + questionAuthor.InnerText.Trim());    //提问者
                                //MessageBox.Show("date----------" + questionPushDate.InnerText.Trim());         //发布时间

                                //string answerCount = hsn.InnerText.Trim();



                            }
                            else
                            {
                                continue;
                            }




                        }


                        //HtmlNode newnode = hn.SelectSingleNode("/div/div/div[3]");

                        /**IEnumerable<HtmlNode> nodeList = node.Ancestors();  //获取该元素所有的父节点的集合
                        foreach (HtmlNode item in nodeList)
                        {
                            Console.Write(item.Name + " ");   //输出 div div body html #document
                        }*/


                    }

                    this.listBox2.ItemsSource = listContent;


                }

            }

        }

        private void TextBlock_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TextBlock textBlock = (TextBlock)e.OriginalSource;

            string tagLink = (string)textBlock.Tag;

            NavigationService.Navigate(new Uri("/ContentViews/QuestionContent.xaml?titleLinkValue=" + tagLink + "", UriKind.Relative));

        }

        private void btnSearch_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            string searchValue = this.searchValue.Text;
            if (searchValue == null || searchValue.Equals(""))
            {
                MessageBox.Show("写点什么吧!");
            }
            else {
                NavigationService.Navigate(new Uri("/ContentViews/itemSearch.xaml?searchParam=" + searchValue + "", UriKind.Relative));
                //NavigationService.Navigate(new Uri("/ContentViews/itemSearch.xaml", UriKind.Relative));
            
            }

            
            
            
            
            


        }




    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using HtmlAgilityPack;

namespace PhoneApp1.Views
{
    public partial class question : PhoneApplicationPage
    {
        public question()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocComplete);

            htmlDoc.LoadAsync("http://q.cnblogs.com/");
        }


        private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;
                if (htmlDoc != null)
                {

                    List<Question> listContent = new List<Question>();

                    HtmlNode node = htmlDoc.GetElementbyId("main");
                    HtmlNode hn = HtmlNode.CreateNode(node.OuterHtml);
                    HtmlNodeCollection noC = hn.SelectNodes("//*[@class=\"one_entity\"]");



                    foreach (HtmlNode h in noC)
                    {

                        HtmlNode hn1 = HtmlNode.CreateNode(h.OuterHtml);


                        //MessageBox.Show("hn1------"+hn1.InnerHtml);
                        foreach (HtmlNode child in hn1.ChildNodes)
                        {

                            Question question = new Question();
                            /**if (child.Attributes["class"] == null || child.Attributes["class"].Value != "answercount")
                                continue;
                                
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                string answerCount = hsn.InnerText.Trim();
                                MessageBox.Show(answerCount.Substring(0,answerCount.IndexOf("回答数")).Trim());*/


                            if (child.Attributes["class"] != null && child.Attributes["class"].Value == "answercount")
                            {
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                string answerCount = hsn.InnerText.Trim();
                                //MessageBox.Show(answerCount.Substring(0, answerCount.IndexOf("回答数")).Trim());//回答人数


                            }
                            else if (child.Attributes["class"] != null && child.Attributes["class"].Value == "news_item")
                            {
                                HtmlNode hsn = HtmlNode.CreateNode(child.OuterHtml);
                                HtmlNode gold = hsn.SelectSingleNode("//*[@class=\"gold\"]");
                                string goldCount = "";
                                if (gold != null)
                                {
                                    goldCount = gold.InnerText.Trim();
                                    //MessageBox.Show("gold----------" + gold.InnerText.Trim());  //悬赏金币
                                }
                                else
                                {
                                    goldCount = "0";
                                    //MessageBox.Show("gold----------0");                   //悬赏金币 空则为0
                                }

                                IEnumerable<HtmlNode> nodeList = hsn.SelectSingleNode("//*[@class=\"news_entry\"]").Descendants("a");
                                string title = "";
                                foreach (HtmlNode item in nodeList)
                                {
                                    title = item.InnerHtml.Trim();
                                    //MessageBox.Show("out--------" + item.InnerHtml.Trim());  //问题标题
                                }


                                HtmlNode questionIntroduce = hsn.SelectSingleNode("//*[@class=\"news_summary\"]");
                                HtmlNode questionAuthor = hsn.SelectSingleNode("//*[@class=\"news_contributor\"]");
                                HtmlNode questionPushDate = hsn.SelectSingleNode("//*[@class=\"date\"]");

                                IEnumerable<HtmlNode> imgAuthorList = hsn.SelectSingleNode("//*[@class=\"author\"]").Descendants("img");

                                foreach (HtmlNode imgAuthor in imgAuthorList)
                                {

                                    string userImage = imgAuthor.GetAttributeValue("src", "");
                                    if (userImage.IndexOf(".gif") > 0)
                                    {
                                        question.questionUserImage = "/images/skydrive.png";
                                    }
                                    else
                                    {
                                        question.questionUserImage = userImage;
                                    }

                                    //MessageBox.Show("out--------" + item.InnerHtml.Trim());  //问题标题
                                }



                                string introduce = questionIntroduce.InnerText.Trim();
                                string author = questionAuthor.InnerText.Trim();
                                string date = questionPushDate.InnerText.Trim();

                                question.questionTitle = title;
                                question.questionIntroduce = introduce;
                                question.questionInfo = author + "  " + date;
                                question.questionGoldImage = "/images/gold.png";
                                question.questionGoldCount = goldCount;

                                listContent.Add(question);
                                //MessageBox.Show("questionIntroduce------------" + questionIntroduce.InnerText.Trim());   //问题简介
                                //MessageBox.Show("news_footer----------" + questionAuthor.InnerText.Trim());    //提问者
                                //MessageBox.Show("date----------" + questionPushDate.InnerText.Trim());         //发布时间

                                //string answerCount = hsn.InnerText.Trim();



                            }
                            else
                            {
                                continue;
                            }




                        }


                        //HtmlNode newnode = hn.SelectSingleNode("/div/div/div[3]");

                        /**IEnumerable<HtmlNode> nodeList = node.Ancestors();  //获取该元素所有的父节点的集合
                        foreach (HtmlNode item in nodeList)
                        {
                            Console.Write(item.Name + " ");   //输出 div div body html #document
                        }*/


                    }

                    this.listBox1.ItemsSource = listContent;


                }

            }

        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using HtmlAgilityPack;
using cnblogs;

namespace PhoneApp1.Views
{
    public partial class index : PhoneApplicationPage
    {
        public index()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            

            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocComplete);

            htmlDoc.LoadAsync("http://www.cnblogs.com/");
        }


        private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;
                if (htmlDoc != null)
                {
                    HtmlNode node = htmlDoc.GetElementbyId("post_list");

                    List<BlogIndexContent> listContent = new List<BlogIndexContent>();
                   

                    foreach (HtmlNode child in node.ChildNodes)
                    {

                        if (child.Attributes["class"] == null || child.Attributes["class"].Value != "post_item")
                            continue;
                        HtmlNode hn = HtmlNode.CreateNode(child.OuterHtml);
                        BlogIndexContent listContextObj = new BlogIndexContent();
                        string tuijian = hn.SelectSingleNode("//*[@class=\"diggnum\"]").InnerText;
                        string title = hn.SelectSingleNode("//*[@class=\"titlelnk\"]").InnerText;
                        string jieshao = hn.SelectSingleNode("//*[@class=\"post_item_summary\"]").InnerText;

                        string xinxi = hn.SelectSingleNode("//*[@class=\"post_item_foot\"]").InnerText;
                        string xinxi2 = hn.SelectSingleNode("//*[@class=\"lightblue\"]").InnerText.Trim();
                        string xinxi3 = hn.SelectSingleNode("//*[@class=\"article_comment\"]").InnerText.Trim();
                        string xinxi4 = hn.SelectSingleNode("//*[@class=\"article_view\"]").InnerText.Trim();


                        string titleIDValue = hn.SelectSingleNode("//*[@class=\"diggnum\"]").InnerText;
                        
                        string titlelnk = hn.SelectSingleNode("//*[@class=\"titlelnk\"]").GetAttributeValue("href", "");
                        



                        IEnumerable<HtmlNode> userImageNode = hn.SelectSingleNode("//*[@class=\"post_item_summary\"]").Descendants("img");
                        
                        
                            foreach (HtmlNode imgAuthor in userImageNode)
                            {


                                string userImage = imgAuthor.GetAttributeValue("src", "");
                                //MessageBox.Show("userimage----------"+userImage);
                               if (userImage != null && userImage.IndexOf(".png") > -1 || userImage.IndexOf(".jpg") > -1)
                                {
                                    listContextObj.userImage = userImage;
                                }
                                else {
                                    listContextObj.userImage = "/images/skydrive.png";
                                }
                                
                           

                                
                                 
                                
                            
                                

                            //MessageBox.Show("out--------" + item.InnerHtml.Trim());  //问题标题
                            }
                        
                        



                        //string userImage = hn.SelectSingleNode("//*[@class=\"pfs\"]").GetAttributeValue("src", "");
                     

                        listContextObj.Title = title;
                        listContextObj.Introduce = jieshao;
                        listContextObj.Info = xinxi2 + xinxi3 + xinxi4;
                        listContextObj.titleLink = titlelnk;
                        listContextObj.recommendCount = tuijian;
                        //listContextObj.userImage = userImage;
                        listContextObj.recommendImage = "/images/cream.png";
                        listContent.Add(listContextObj);

                    }
                    this.listBox1.ItemsSource = listContent;

                

                }
            }

        }

       

        private void TextBlock_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TextBlock textBlock = (TextBlock)e.OriginalSource;

            string tagLink = (string)textBlock.Tag;
            //MessageBox.Show(tagLink);
            NavigationService.Navigate(new Uri("/ContentViews/indexContent.xaml?titleLinkValue=" + tagLink + "", UriKind.Relative));
        }

     

      

    }
}<file_sep>﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace cnblogs
{
    public class FlashMemory
    {
        public string userImage { get; set; }
        public string userAuthor { get; set; }
        public string userContent { get; set; }
        public string userReleaseDate { get; set; }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using HtmlAgilityPack;

namespace PhoneApp1.Views
{
    public partial class recommend : PhoneApplicationPage
    {
        public recommend()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {


            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocComplete);

            htmlDoc.LoadAsync("http://www.cnblogs.com/");
        }


        private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e)
        {
            if (e.Error == null)
            {
                HtmlDocument htmlDoc = e.Document;


                if (htmlDoc != null)
                {
                    HtmlNode node = htmlDoc.GetElementbyId("headline_block");
                    //IEnumerable<HtmlNode>  nodeList =htmlDoc.DocumentNode.Descendants("a");
                    HtmlNode hn = HtmlNode.CreateNode(node.OuterHtml);
                    IEnumerable<HtmlNode> nodeList=hn.Descendants("a");
                    List<Recom> listContent = new List<Recom>();

                    foreach (HtmlNode item in nodeList)
                    {
                        //MessageBox.Show("out--------"+item.InnerHtml);
                        //MessageBox.Show("out--------" + item.InnerText);
                        string title = item.InnerText;

                        if(title==null||title.Length<2)
                            continue;
                            string recomTitle = title;
                            //MessageBox.Show("out--------" + title);
                            string titlelnk = item.GetAttributeValue("href", "");
                            //MessageBox.Show("titlelnk--------" + titlelnk);
                            Recom recom = new Recom();
                            recom.recomTitle = recomTitle;
                            recom.titleLink = titlelnk;
                            listContent.Add(recom);

                    }

                    this.listBox1.ItemsSource = listContent;

                }
            }

        }

       

        private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TextBlock textBlock = (TextBlock)e.OriginalSource;

            string tagLink = (string)textBlock.Tag;

            //MessageBox.Show("this is -----------" + tagLink);


            NavigationService.Navigate(new Uri("/Views/Pasta.xaml?titleLinkValue=" + tagLink + "", UriKind.Relative));
        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO;
using HtmlAgilityPack;

namespace cnblogs.Views
{
    public partial class flashMemory : PhoneApplicationPage
    {
        public flashMemory()
        {
            InitializeComponent();
        }

        public CookieContainer cookieContainer = new CookieContainer();
        public HttpWebRequest myRequest;
        private string username;
        private string password;
        private string flashMemoryValue;

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
           
            //myRequest = (HttpWebRequest)WebRequest.Create("http://passport.cnblogs.com/login.aspx");
            if (NavigationContext.QueryString.Count > 0) {
                username = NavigationContext.QueryString["username"];
                password = NavigationContext.QueryString["password"];
            
            }
            myRequest = (HttpWebRequest)WebRequest.Create("http://m.cnblogs.com/mobileLoginPost.aspx");
            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            if (cookieContainer==null)
            {
                myRequest.CookieContainer = new CookieContainer();
            }
            myRequest.CookieContainer = cookieContainer;
            
            myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), myRequest);
            getFlashMemoryList();
            
        }



        private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
            System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);

            // Prepare Parameters String
            //string parametersString = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE1MzYzODg2NzZkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQtjaGtSZW1lbWJlcm1QYDyKKI9af4b67Mzq2xFaL9Bt&__EVENTVALIDATION=%2FwEdAAUyDI6H%2Fs9f%2BZALqNAA4PyUhI6Xi65hwcQ8%2FQoQCF8JIahXufbhIqPmwKf992GTkd0wq1PKp6%2B%2F1yNGng6H71Uxop4oRunf14dz2Zt2%2BQKDEIYpifFQj3yQiLk3eeHVQqcjiaAP&tbUserName=shandowsoftware&tbPassword=<PASSWORD>..&chkRemember=on&btnLogin=%E7%99%BB++%E5%BD%95&txtReturnUrl=http://home.cnblogs.com/";
            string parametersString = "tbUserName="+username+"&tbPassword="+password+"&chkRemember=on&txtReturnUrl=";
            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(parametersString);
            // Write to the request stream.
            postStream.Write(byteArray, 0, parametersString.Length);
            postStream.Close();
            // Start the asynchronous operation to get the response
            request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
        }



        private void GetResponseCallback(IAsyncResult asynchronousResult)
        {
            Stream streamResponse = null;
            string responseString = null;
            try
            {
                HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                streamResponse = response.GetResponseStream();
                
                CookieCollection cookieCollection = response.Cookies;
                cookieContainer.Add(new Uri("http://space.cnblogs.com/mobile/ming_post.aspx"), cookieCollection);
                //cookieContainer.Add(new Uri("http://home.cnblogs.com/ajax/ing/Publish"), cookieCollection);
                using (StreamReader streamRead = new StreamReader(streamResponse))
                {
                    responseString = streamRead.ReadToEnd();
                }
            }
            catch { }
            finally
            {
                if (streamResponse != null)
                {
                    streamResponse.Close();
                }
            }

            if (responseString != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    string result = responseString;

                  
                    //textBlockResult.Text = result;
                });
            }

        }









        //得到get响应html
        private void getFlashMemoryList()
        {

            HtmlAgilityPack.HtmlWeb htmlDoc = new HtmlAgilityPack.HtmlWeb();
            htmlDoc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(htmlDocComplete);
            htmlDoc.LoadAsync("http://home.cnblogs.com/ing/mobile/home");

        }

        private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e){
            if(e.Error==null){
                HtmlDocument htmlDoc = e.Document;
                if(htmlDoc!=null){
                    List<FlashMemory> flashMemoryList = new List<FlashMemory>();

                    HtmlNode node = htmlDoc.GetElementbyId("feed_list");
                    //MessageBox.Show("node--------------"+node.InnerHtml);
                    HtmlNode hn = HtmlNode.CreateNode(node.OuterHtml);
                    IEnumerable<HtmlNode> nodeList = hn.Descendants("li");
                    foreach(HtmlNode item in nodeList){
                        //MessageBox.Show(item.InnerHtml);
                        HtmlNode hnChild = HtmlNode.CreateNode(item.OuterHtml);

                        if (item.Attributes["class"] != null && item.Attributes["class"].Value == "entry_b")
                        {
                            FlashMemory flashMemoryb = new FlashMemory();

                            IEnumerable<HtmlNode> userImageNodeList = hnChild.SelectSingleNode("//*[@class=\"feed_avatar\"]").Descendants("img");
                            string userImageLink = "";
                            foreach (HtmlNode authorImage in userImageNodeList)
                            {

                                string userImageb = authorImage.GetAttributeValue("src", "");
                                //MessageBox.Show("userImage-------"+userImageb);
                                if (userImageb.IndexOf(".gif") > 0)
                                {
                                    userImageLink = "/images/skydrive.png";
                                }
                                else
                                {
                                    userImageLink = userImageb;
                                }

                            }
                            
                            string authorb = hnChild.SelectSingleNode("//*[@class=\"ing-author\"]").InnerText.Trim();
                            string authorContentb = hnChild.SelectSingleNode("//*[@class=\"ing_body\"]").InnerText.Trim();
                            string authorReleaseDateb = hnChild.SelectSingleNode("//*[@class=\"ing_time gray\"]").InnerText.Trim();
                            /**MessageBox.Show("authorb----------" + authorb);
                            MessageBox.Show("authorContentb----------" + authorContentb);
                            MessageBox.Show("authorReleaseDateb----------" + authorReleaseDateb);*/
                            flashMemoryb.userImage=userImageLink;
                            flashMemoryb.userAuthor = authorb;
                            flashMemoryb.userContent = authorContentb;
                            flashMemoryb.userReleaseDate = authorReleaseDateb;
                            flashMemoryList.Add(flashMemoryb);
                        
                        }
                        if (item.Attributes["class"] != null && item.Attributes["class"].Value == "entry_a")
                        {
                            FlashMemory flashMemorya = new FlashMemory();

                            IEnumerable<HtmlNode> userImageNodeList = hnChild.SelectSingleNode("//*[@class=\"feed_avatar\"]").Descendants("img");
                            string userImageLink = "";
                            foreach (HtmlNode authorImage in userImageNodeList)
                            {

                                string userImagea = authorImage.GetAttributeValue("src", "");
                                //MessageBox.Show("userImagea--------"+userImagea);
                                if (userImagea.IndexOf(".gif") > 0)
                                {
                                    userImageLink = "/images/skydrive.png";
                                }
                                else
                                {
                                    userImageLink = userImagea;
                                }

                            }

                            string authora = hnChild.SelectSingleNode("//*[@class=\"ing-author\"]").InnerText.Trim();
                            string authorContenta = hnChild.SelectSingleNode("//*[@class=\"ing_body\"]").InnerText.Trim();
                            string authorReleaseDatea = hnChild.SelectSingleNode("//*[@class=\"ing_time gray\"]").InnerText.Trim();
                            /**MessageBox.Show("authora----------" + authora);
                            MessageBox.Show("authorContenta----------" + authorContenta);
                            MessageBox.Show("authorReleaseDatea----------" + authorReleaseDatea);*/

                            flashMemorya.userImage = userImageLink;
                            flashMemorya.userAuthor = authora;
                            flashMemorya.userContent = authorContenta;
                            flashMemorya.userReleaseDate = authorReleaseDatea;
                            flashMemoryList.Add(flashMemorya);
                        
                        }
                    }


                    this.listBox1.ItemsSource = flashMemoryList;

                }

            }


        }







        private void submitData_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {

            flashMemoryValue=this.flashMemoryContent.Text.Trim();

            if (flashMemoryValue == null||flashMemoryValue.Equals(""))
            {
                
                MessageBox.Show("写点什么吧!");
            }
            else {

                myRequest = (HttpWebRequest)WebRequest.Create("http://space.cnblogs.com/mobile/ming_post.aspx");
                //myRequest = (HttpWebRequest)WebRequest.Create("http://home.cnblogs.com/ajax/ing/Publish");
                myRequest.Method = "POST";

                myRequest.ContentType = "application/x-www-form-urlencoded";
                //myRequest.Accept = "application/json,text/javascript,*/*;q=0.01";
                //myRequest.ContentType = "application/json;chartset=utf-8";
                if (cookieContainer == null)
                {
                    myRequest.CookieContainer = new CookieContainer();

                }
                myRequest.CookieContainer = cookieContainer;

                myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallbackqq), myRequest);
                this.listBox1.ItemsSource = null;
                getFlashMemoryList();
            
            }

            
        }

        private void GetRequestStreamCallbackqq(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
            System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);

            // Prepare Parameters String
            //string parametersString = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTE1MzYzODg2NzZkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQtjaGtSZW1lbWJlcm1QYDyKKI9af4b67Mzq2xFaL9Bt&__EVENTVALIDATION=%2FwEdAAUyDI6H%2Fs9f%2BZALqNAA4PyUhI6Xi65hwcQ8%2FQoQCF8JIahXufbhIqPmwKf992GTkd0wq1PKp6%2B%2F1yNGng6H71Uxop4oRunf14dz2Zt2%2BQKDEIYpifFQj3yQiLk3eeHVQqcjiaAP&tbUserName=shandowsoftware&tbPassword=<PASSWORD>..&chkRemember=on&btnLogin=%E7%99%BB++%E5%BD%95&txtReturnUrl=http://home.cnblogs.com/";
            
            //string jsonText="{\"content\":\"来自[windows phone]客户端\",\"publicFlag\":1}";
            string jsonText = "txbContent=[来自windows phone客户端]" + flashMemoryValue + "&ingSubmit=%E6%8F%90%E4%BA%A4";
            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(jsonText);
            // Write to the request stream.
            postStream.Write(byteArray, 0, byteArray.Length);
            postStream.Close();
            // Start the asynchronous operation to get the response
            request.BeginGetResponse(new AsyncCallback(GetResponseCallbackqq), request);
        }



        private void GetResponseCallbackqq(IAsyncResult asynchronousResult)
        {
            Stream streamResponse = null;
            string responseString = null;
            try
            {
                HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                streamResponse = response.GetResponseStream();

                //cookieCollection = response.Cookies;

                using (StreamReader streamRead = new StreamReader(streamResponse))
                {
                    responseString = streamRead.ReadToEnd();
                }
            }
            catch { }
            finally
            {
                if (streamResponse != null)
                {
                    streamResponse.Close();
                }
            }

            if (responseString != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    string result = responseString;
                    //textBlockResult.Text = "";

                    //textBlockResult.Text = result;
                });
            }
            else
            {
                Dispatcher.BeginInvoke(() =>
                {
                    
                    //textBlockResult.Text = "";

                    //textBlockResult.Text = "error";
                });
            }

        }



    }
}