コード例 #1
0
 private void SetPreAndNextResources(PicturesCollModel source)
 {
     image01.Source        = new BitmapImage(source.Previous.ImageUri);
     image02.Source        = new BitmapImage(source.Next.ImageUri);
     image01Text.Text      = source.Previous.Title;
     image02Text.Text      = source.Next.Title;
     previousButton.Click += (sender, clickpre) => {
         MainPage.Current.NavigateToBase?.Invoke(
             sender,
             new NavigateParameter {
             PathUri = source.Previous.PathUri
         },
             MainPage.InnerResources.GetFrameInstance(NavigateType.PicutreContent),
             MainPage.InnerResources.GetPageType(NavigateType.PicutreContent));
     };
     nextButton.Click += (sender, clickpre) => {
         MainPage.Current.NavigateToBase?.Invoke(
             sender,
             new NavigateParameter {
             PathUri = source.Next.PathUri
         },
             MainPage.InnerResources.GetFrameInstance(NavigateType.PicutreContent),
             MainPage.InnerResources.GetPageType(NavigateType.PicutreContent));
     };
 }
コード例 #2
0
 private async System.Threading.Tasks.Task SetPicturesResources(PicturesCollModel source)
 {
     foreach (var item in source.PictureItems)
     {
         var grid  = new Grid();
         var uri   = DataProcess.FetchPictureSingleFromHtml((await WebProcess.GetHtmlResources(item.PathUri.ToString(), true)).ToString()).ImageUri;
         var image = new Image {
             Source  = new BitmapImage(uri),
             Margin  = new Thickness(10, 5, 10, 5),
             Stretch = Stretch.UniformToFill,
         };
         grid.Children.Add(image);
         var button = new Button {
             HorizontalAlignment = HorizontalAlignment.Stretch,
             VerticalAlignment   = VerticalAlignment.Stretch,
             Background          = new SolidColorBrush(Colors.Transparent),
             Style = Application.Current.Resources["MainPageButtonBackHamburgerStyle"] as Style,
         };
         button.Click += (sender, clickArgs) => { MainPage.ShowImageInScreen(uri); };
         grid.Children.Add(button);
         ContentStack.Children.Add(grid);
     }
 }
コード例 #3
0
ファイル: DataProcess.cs プロジェクト: miao17game/ENRZ.UWP
        public static PicturesCollModel FetchPictureCollectionFromHtml(string htmlResources)
        {
            var addHost       = "http://pic.enrz.com";
            var pageResources = new HtmlDocument();

            pageResources.LoadHtml(htmlResources);
            HtmlNode rootnode = pageResources.DocumentNode;

            try {
                string XPathString  = "//div[@class='detail_rel']";
                var    navi_Li_Coll = rootnode.SelectSingleNode(XPathString).SelectNodes("div");
                var    model        = new PicturesCollModel();
                model.PictureItems = new List <BarItemModel>();
                foreach (var div in navi_Li_Coll)
                {
                    try {
                        switch (div.Attributes["id"].Value)
                        {
                        case "hover1": try {
                                model.Previous = new SimpleImgModel {
                                    Title    = div.SelectSingleNode("a").Attributes["title"].Value,
                                    PathUri  = new Uri(addHost + div.SelectSingleNode("a").Attributes["href"].Value),
                                    ImageUri = new Uri(div.SelectSingleNode("a").SelectSingleNode("img").Attributes["src"].Value)
                                };
                        } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); }
                            break;

                        case "hover2": try {
                                var UlCollection = div
                                                   .SelectSingleNode("//div[@class='detail_thumb_cm']")
                                                   .SelectNodes("ul");
                                foreach (var ul in UlCollection)
                                {
                                    foreach (var li in ul.SelectNodes("li"))
                                    {
                                        model.PictureItems.Add(new BarItemModel {
                                            PathUri = new Uri(addHost + li.SelectSingleNode("a").Attributes["href"].Value),
                                        });
                                    }
                                }
                        } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); }
                            break;

                        case "hover3": try {
                                model.Next = new SimpleImgModel {
                                    Title    = div.SelectSingleNode("a").Attributes["title"].Value,
                                    PathUri  = new Uri(addHost + div.SelectSingleNode("a").Attributes["href"].Value),
                                    ImageUri = new Uri(div.SelectSingleNode("a").SelectSingleNode("img").Attributes["src"].Value)
                                };
                        } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); }
                            break;

                        default: break;
                        }
                    } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); }
                }
                model.MoreCollection = new List <SimpleImgModel>();
                try {
                    var moreCollection = rootnode
                                         .SelectSingleNode("//div[@class='detail_m fn-clear mt20']")
                                         .SelectSingleNode("div[@class='detail_recom']")
                                         .SelectSingleNode("ul")
                                         .SelectNodes("li");
                    foreach (var li in moreCollection)
                    {
                        var noteA = li.SelectSingleNode("a");
                        model.MoreCollection.Add(new SimpleImgModel {
                            Title    = noteA.Attributes["title"].Value,
                            PathUri  = new Uri(noteA.Attributes["href"].Value),
                            ImageUri = new Uri(noteA.SelectSingleNode("img").Attributes["src"].Value),
                        });
                    }
                } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); }
                try {
                    var moreCollection2 = rootnode
                                          .SelectSingleNode("//div[@class='detail_m fn-clear mt20']")
                                          .SelectSingleNode("div[@class='detail_u']")
                                          .SelectSingleNode("ul")
                                          .SelectNodes("li");
                    foreach (var li in moreCollection2)
                    {
                        var noteA = li.SelectSingleNode("a");
                        model.MoreCollection.Add(new SimpleImgModel {
                            Title    = noteA.Attributes["title"].Value,
                            PathUri  = new Uri(noteA.Attributes["href"].Value),
                            ImageUri = new Uri(noteA.SelectSingleNode("img").Attributes["src"].Value),
                        });
                    }
                } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); }
                return(model);
            } catch {
                return(new PicturesCollModel());
            }
        }