private void callback(string htmlStr) { if (htmlStr.Equals("NO")) { MessageBoxResult result = MessageBox.Show("检测到当前没有网络,请联上网络重启程序", "提醒", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { ((MainPage)this.Parent).Exit(); } } string heropart = htmlhelp.GetUniqTag(htmlStr, "div", "class=\"BG_Block\""); List <string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", ""); foreach (var item in allheros) { i++; Hero hero = new Hero(item); string gif = hero.Src; int start = gif.LastIndexOf('/'); int length = gif.Length - start; string name = gif.Substring(start + 1); string name1 = " /Heros/" + name.Substring(0, name.Length - 4) + ".png"; Image image = new Image(); image.Width = 60; image.Height = 60; image.Margin = new Thickness(5, 5, 5, 5); image.Source = new BitmapImage() { UriSource = new Uri(name1, UriKind.Relative) }; System.Windows.Interactivity.EventTrigger ev = new System.Windows.Interactivity.EventTrigger("Tap"); NavigateToPageAction action = new NavigateToPageAction(); ev.Actions.Add(action); Interaction.GetTriggers(image).Add(ev); if (i <= 38) { heroPanel1.Children.Add(image); } if (i > 38 && i <= 72) { heroPanel2.Children.Add(image); } if (i > 72) { heroPanel3.Children.Add(image); } HeroTable heroItem = new HeroTable() { AvatarUri = name1, Name = hero.Alt, Link = hero.Href }; db.heroTable.InsertOnSubmit(heroItem); db.SubmitChanges(); action.TargetPage = "/Views/SingleHero.xaml?id=" + heroItem.Id; } waiting.WaitingEnd(); }
private void callback(string htmlStr) { // ItemsClass items = new ItemsClass(htmlStr); if (htmlStr.Equals("NO")) { MessageBoxResult result = MessageBox.Show("检测到当前没有网络,请联上网络重启程序", "提醒", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { ((MainPage)this.Parent).Exit(); } } string str = htmlhelp.GetUniqTag(htmlStr, "div", "Class=\"BG_Block\""); List <string> contents = htmlhelp.GetImgTagFromHtml1(str); int i = 0; foreach (string s in contents) { i++; ItemsTable item = new ItemsTable(); string gif = GetContent(s, "src"); int start = gif.LastIndexOf('/'); int length = gif.Length - start; string name = gif.Substring(start + 1); string name1 = " /Items/" + name.Substring(0, name.Length - 4) + ".png"; item.AvatarUri = name1; Regex regex = new Regex("[0-9]{2,6}"); Match match = regex.Match(GetContent(s, "onmouseover")); if (match.Success) { item.DetailId = match.Value; } //AnimatedImage imgGif = new AnimatedImage(); //imgGif.Width = 50; //imgGif.Height = 50; //ImageTools.ExtendedImage image = new ImageTools.ExtendedImage(); //image.UriSource = new Uri(item.AvatarUri); //imgGif.Source = image; Image image = new Image(); //image.DoubleTap += new EventHandler<GestureEventArgs>(image_DoubleTap); //image.Hold+=new EventHandler<GestureEventArgs>(imgGif_Hold); image.Tap += new EventHandler <GestureEventArgs>(image_Tap); image.Tag = item.DetailId; image.Width = 60; image.Height = 60; image.Margin = new Thickness(3, 3, 3, 3); image.Source = new BitmapImage() { UriSource = new Uri(name1, UriKind.Relative) }; if (i <= 8) { wp_Items1.Children.Add(image); } if (i > 8 && i <= 19) { wp_Items2.Children.Add(image); } if (i > 19 && i <= 31) { wp_Items3.Children.Add(image); } if (i > 31 && i <= 43) { wp_Items4.Children.Add(image); } if (i > 43 && i <= 55) { wp_Items5.Children.Add(image); } if (i > 55 && i <= 63) { wp_Items6.Children.Add(image); } if (i > 63 && i <= 74) { wp_Items7.Children.Add(image); } if (i > 74 && i <= 85) { wp_Items8.Children.Add(image); } if (i > 85 && i <= 97) { wp_Items9.Children.Add(image); } if (i > 97 && i <= 109) { wp_Items10.Children.Add(image); } if (i > 109 && i <= 121) { wp_Items11.Children.Add(image); } if (i > 121 && i <= 133) { wp_Items12.Children.Add(image); } if (i > 133) { wp_Items13.Children.Add(image); } db.itemsTable.InsertOnSubmit(item); } db.SubmitChanges(); }