private void NewsListView_ItemClick(object sender, ItemClickEventArgs e)
 {
     NewsList newsItem = new NewsList(((NewsList)e.ClickedItem).ID, ((NewsList)e.ClickedItem).Articleid, ((NewsList)e.ClickedItem).Title, ((NewsList)e.ClickedItem).Head, ((NewsList)e.ClickedItem).Date, ((NewsList)e.ClickedItem).Read, ((NewsList)e.ClickedItem).Content == null ? "加载中..." : ((NewsList)e.ClickedItem).Content, ((NewsList)e.ClickedItem).Content_all == null ? "加载中..." : ((NewsList)e.ClickedItem).Content_all);
     Frame.Navigate(typeof(NewsContentPage), newsItem);
 }
        private async void initNewsList(string type, int page = 0)
        {
            int[] temp = pagestatus;

            switch (type)
            {
                case "jwzx":
                    JWListFailedStackPanel.Visibility = Visibility.Collapsed;
                    JWListProgressStackPanel.Visibility = Visibility.Visible;
                    break;
                case "xwgg":
                    XWListFailedStackPanel.Visibility = Visibility.Collapsed;
                    XWListProgressStackPanel.Visibility = Visibility.Visible;
                    break;
                case "cyxw ":
                    CYListFailedStackPanel.Visibility = Visibility.Collapsed;
                    CYListProgressStackPanel.Visibility = Visibility.Visible;
                    break;
                case "xsjz ":
                    XSListFailedStackPanel.Visibility = Visibility.Collapsed;
                    XSListProgressStackPanel.Visibility = Visibility.Visible;
                    break;
            }

            List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>();
            paramList.Add(new KeyValuePair<string, string>("type", type));
            paramList.Add(new KeyValuePair<string, string>("page", page.ToString()));
            string news = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/home/news/searchtitle", paramList);
            Debug.WriteLine("news->" + news);

            switch (type)
            {
                case "jwzx":
                    JWListProgressStackPanel.Visibility = Visibility.Collapsed;
                    break;
                case "xwgg":
                    XWListProgressStackPanel.Visibility = Visibility.Collapsed;
                    break;
                case "cyxw ":
                    CYListProgressStackPanel.Visibility = Visibility.Collapsed;
                    break;
                case "xsjz ":
                    XSListProgressStackPanel.Visibility = Visibility.Collapsed;
                    break;
            }

            if (news != "")
            {
                JObject obj = JObject.Parse(news);
                if (Int32.Parse(obj["state"].ToString()) == 200)
                {
                    JArray NewsListArray = Utils.ReadJso(news);
                    //JWListView.ItemsSource = JWList;

                    for (int i = 0; i < NewsListArray.Count; i++)
                    {
                        int failednum = 0;
                        NewsList Newsitem = new NewsList();
                        Newsitem.GetListAttribute((JObject)NewsListArray[i]);
                        if (Newsitem.Title != "")
                        {

                            //请求正文
                            List<KeyValuePair<String, String>> contentparamList = new List<KeyValuePair<String, String>>();
                            contentparamList.Add(new KeyValuePair<string, string>("type", type));
                            contentparamList.Add(new KeyValuePair<string, string>("articleid", Newsitem.Articleid));
                            string newsContent = await NetWork.getHttpWebRequest("cyxbsMobile/index.php/home/news/searchcontent", contentparamList);
                            //Debug.WriteLine("newsContent->" + newsContent);
                            if (temp[NewsPivot.SelectedIndex] != pagestatus[NewsPivot.SelectedIndex])
                            {
                                Debug.WriteLine("newsContent->在此退出");
                                return;
                            }
                            if (newsContent != "")
                            {
                                JObject newsContentobj = JObject.Parse(newsContent);
                                if (Int32.Parse(newsContentobj["state"].ToString()) == 200)
                                {
                                    string content = (JObject.Parse(newsContentobj["data"].ToString()))["content"].ToString();
                                    string content_all = content;
                                    Debug.WriteLine("content->" + content);
                                    try
                                    {
                                        while (content.IndexOf("<") != -1)
                                        {
                                            content = content.Remove(content.IndexOf("<"), content.IndexOf(">") - content.IndexOf("<") + 1);
                                        }
                                    }
                                    catch (Exception) { }

                                    //content.Replace("&nbsp;", "");

                                    //while (content.StartsWith("\r") || content.StartsWith("\n") || content.StartsWith("\t") || content.StartsWith(" ") || content.StartsWith("&nbsp;"))
                                    //    content = content.Substring(1);
                                    //while (content.StartsWith("&nbsp;"))
                                    //    content = content.Substring(6);
                                    content = content.Replace("\r", "");
                                    content = content.Replace("\t", "");
                                    content = content.Replace("\n", "");
                                    content = content.Replace("&nbsp;", "");
                                    content = content.Replace(" ", "");
                                    content = content.Replace("(见附件)", "见附件");
                                    content = content.Replace("MicrosoftInternetExplorer4", "");
                                    content = content.Replace("Normal07.8磅02falsefalsefalse", "");

                                    //while (content.StartsWith("\r\n "))
                                    //    content = content.Substring(3);
                                    //while (content.StartsWith("\r\n"))
                                    //    content = content.Substring(2);
                                    //while (content.StartsWith("\n\t"))
                                    //    content = content.Substring(2);
                                    //while (content.StartsWith("\n"))
                                    //    content = content.Substring(1);
                                    //while (content.StartsWith("\r"))
                                    //    content = content.Substring(1);
                                    //while (content.StartsWith("\t"))
                                    //    content = content.Substring(1);
                                    //while (content.StartsWith("\\"))
                                    //    content = content.Substring(1);
                                    //content.Replace('\r', '\a');
                                    //content.Replace('\n', '\a');
                                    //content.Replace(" ", "");
                                    Debug.WriteLine("content->" + content);
                                    switch (type)
                                    {
                                        case "jwzx":
                                            JWList.Add(new NewsList { Title = Newsitem.Title, Date = Newsitem.Date, Read = Newsitem.Read, Content = content, Content_all = newsContent, ID = Newsitem.ID });
                                            break;
                                        case "xwgg":
                                            XWList.Add(new NewsList { Title = Newsitem.Title, Date = Newsitem.Date, Read = Newsitem.Read, Content = content, Content_all = newsContent, ID = Newsitem.ID });
                                            break;
                                        case "cyxw ":
                                            CYList.Add(new NewsList { Title = Newsitem.Title, Date = Newsitem.Date, Read = Newsitem.Read, Content = content, Content_all = newsContent, ID = Newsitem.ID });
                                            break;
                                        case "xsjz ":
                                            XSList.Add(new NewsList { Title = Newsitem.Title, Date = Newsitem.Date, Read = Newsitem.Read, Content = content, Content_all = newsContent, ID = Newsitem.ID });
                                            break;
                                    }
                                }
                            }

                        }
                    }
                    //JWListView.ItemsSource = JWList;
                    switch (type)
                    {
                        case "jwzx":
                            continueJWGrid.Visibility = Visibility.Visible;
                            break;
                        case "xwgg":
                            continueXWGrid.Visibility = Visibility.Visible;
                            break;
                        case "cyxw ":
                            continueCYGrid.Visibility = Visibility.Visible;
                            break;
                        case "xsjz ":
                            continueXSGrid.Visibility = Visibility.Visible;
                            break;
                    }
                }
                else
                {
                    switch (type)
                    {
                        case "jwzx":
                            JWListFailedStackPanel.Visibility = Visibility.Visible;
                            continueJWGrid.Visibility = Visibility.Collapsed;
                            break;
                        case "xwgg":
                            XWListFailedStackPanel.Visibility = Visibility.Visible;
                            continueXWGrid.Visibility = Visibility.Collapsed;
                            break;
                        case "cyxw ":
                            CYListFailedStackPanel.Visibility = Visibility.Visible;
                            continueCYGrid.Visibility = Visibility.Collapsed;
                            break;
                        case "xsjz ":
                            XSListFailedStackPanel.Visibility = Visibility.Visible;
                            continueXSGrid.Visibility = Visibility.Collapsed;
                            break;
                    }
                }
            }
            else
            {
                switch (type)
                {
                    case "jwzx":
                        JWListFailedStackPanel.Visibility = Visibility.Visible;
                        continueJWGrid.Visibility = Visibility.Collapsed;
                        break;
                    case "xwgg":
                        XWListFailedStackPanel.Visibility = Visibility.Visible;
                        continueXWGrid.Visibility = Visibility.Collapsed;
                        break;
                    case "cyxw ":
                        CYListFailedStackPanel.Visibility = Visibility.Visible;
                        continueCYGrid.Visibility = Visibility.Collapsed;
                        break;
                    case "xsjz ":
                        XSListFailedStackPanel.Visibility = Visibility.Visible;
                        continueXSGrid.Visibility = Visibility.Collapsed;
                        break;
                }
            }
        }
        private void NewsListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            NewsList newsItem = new NewsList(((NewsList)e.ClickedItem).ID, ((NewsList)e.ClickedItem).Articleid, ((NewsList)e.ClickedItem).Title, ((NewsList)e.ClickedItem).Head, ((NewsList)e.ClickedItem).Date, ((NewsList)e.ClickedItem).Read, ((NewsList)e.ClickedItem).Content == null ? "加载中..." : ((NewsList)e.ClickedItem).Content, ((NewsList)e.ClickedItem).Content_all == null ? "加载中..." : ((NewsList)e.ClickedItem).Content_all);

            Debug.WriteLine("NewsListgrid.Width" + NewsListgrid.Width);
            if (NewsListgrid.Width == 400)
            {
                //JWBackAppBarButton.Visibility = Visibility.Collapsed;
                SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested;
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                NewsRefreshAppBarButton.Visibility = Visibility.Visible;
            }
            else
            {
                //JWBackAppBarButton.Visibility = Visibility.Visible;
                SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                NewsRefreshAppBarButton.Visibility = Visibility.Collapsed;
            }
            NewsFrame.Visibility = Visibility.Visible;
            if (((NewsList)e.ClickedItem).Content_all != "")
            {
                JObject newsContentobj = JObject.Parse(((NewsList)e.ClickedItem).Content_all);
                if (Int32.Parse(newsContentobj["state"].ToString()) == 200)
                {
                    JArray AnnexListArray = Utils.ReadJso(newsContentobj["data"].ToString(), "annex");
                    if (AnnexListArray != null)
                    {
                        ObservableCollection<NewsContentList.Annex> annexList = new ObservableCollection<NewsContentList.Annex>();
                        for (int i = 0; i < AnnexListArray.Count; i++)
                        {
                            NewsContentList.Annex annex = new NewsContentList.Annex();
                            annex.GetAttribute((JObject)AnnexListArray[i]);
                            if (annex.name != "")
                            {
                                Uri Anneximg;
                                if (annex.name.IndexOf(".zip") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_zip.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".rar") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_rar.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".pdf") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_pdf.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".doc") != -1 || annex.name.IndexOf(".docx") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_doc.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".xls") != -1 || annex.name.IndexOf(".xlsx") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_xls.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".ppt") != -1 || annex.name.IndexOf(".pptx") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_ppt.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".jpg") != -1 || annex.name.IndexOf(".png") != -1 || annex.name.IndexOf(".gif") != -1 || annex.name.IndexOf(".bmp") != -1 || annex.name.IndexOf(".jpeg") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_image.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".mp4") != -1 || annex.name.IndexOf(".rmvb") != -1 || annex.name.IndexOf(".avi") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_video.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".mp3") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_music.png", UriKind.Absolute);
                                }
                                else if (annex.name.IndexOf(".apk") != -1)
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_apk.png", UriKind.Absolute);
                                }
                                else
                                {
                                    Anneximg = new Uri("ms-appx:///Assets/Annex_img/Annex_other.png", UriKind.Absolute);
                                }

                                annexList.Add(new NewsContentList.Annex { name = annex.name, address = annex.address, Anneximg = Anneximg });
                                DownloadAppBarButton.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                DownloadAppBarButton.Visibility = Visibility.Collapsed;
                                break;
                            }
                        }
                        AnnexListView.ItemsSource = annexList;
                    }
                    else
                        DownloadAppBarButton.Visibility = Visibility.Collapsed;
                }
            }
            this.NewsFrame.Navigate(typeof(NewsContentPage), newsItem);
        }