void dispatcherTimer_Tick0(object sender, object e) { if (MM4 != null) { Task.Factory.StartNew(async() => { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Items0.Clear(); for (int i = 0; i < 7; i++) { Item item = new Item(); item.Link = MM4[i].Value; if (MM[i].Value != string.Empty) { item.Img = new BitmapImage(new Uri(MM[i].Value)); } item.First = MM2[i].Value; item.Last = "发布日期:" + MM3[i].Value; Items0.Add(item); } DM0.Begin(); }); }); dispatcherTimer0.Stop(); } }
private async void we_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)//web控件的载入事件,点击内容都会触发这个事件 { zhuangtai2 = true; if (zhuangtai == true) { if (args.Uri != null) { if (args.Uri.AbsoluteUri.Contains("img1.") == true)//判断打开的是不是图片 { args.Cancel = true; 返回.Visibility = Visibility.Visible; 位.Visibility = Visibility.Visible; 保存.Visibility = Visibility.Visible; TPG.Visibility = Visibility.Visible; 刷新.Visibility = Visibility.Collapsed; 一页.Visibility = Visibility.Collapsed; 一页.Visibility = Visibility.Collapsed; 评论.Visibility = Visibility.Collapsed; DM0.Begin(); try { if (lsuri != args.Uri.AbsoluteUri) { TPS.Source = null; inStream = null; HttpClient webClient = new HttpClient(); inStream = await webClient.GetBufferAsync(new Uri(args.Uri.AbsoluteUri.Substring(args.Uri.AbsoluteUri.LastIndexOf("http")))); } else { lsuri = args.Uri.AbsoluteUri; } if (inStream.Length < 900000)//判断图片的大小 { CT.ScaleX = CT.ScaleY = 1; CT.TranslateX = CT.TranslateY = 0; zb = 0; zb2 = 0; zb3 = 1; BitmapImage img = new BitmapImage(); await img.SetSourceAsync(inStream.AsStream().AsRandomAccessStream()); img.ImageOpened += new RoutedEventHandler(bi_ImageOpened); img.ImageFailed += new ExceptionRoutedEventHandler(bi_ImageFailed); img.CreateOptions = BitmapCreateOptions.IgnoreImageCache; TPS.Source = img; img = null; PB.Visibility = Visibility.Collapsed; } else { TPT.Text = "抱歉!由于WindowsPhone内存限制,不能在一般应用里预览 超高清的大图,但你仍然可以保存到图库,去图库->保存的图片里查看!"; TPT.Visibility = Visibility.Visible; PB.Visibility = Visibility.Collapsed; } } catch (Exception e) { PB.Visibility = Visibility.Collapsed; TPT.Visibility = Visibility.Visible; TPT.Text = "图片载入错误:" + e.Message + " 请与作者联系!"; } istpdk = true; } else if (args.Uri.AbsoluteUri.Contains("acg.gamersky") == true)//判断打开的是超链接 { args.Cancel = true; if (args.Uri.AbsoluteUri.Contains("pic/mm") || args.Uri.AbsoluteUri.Contains("pic/xz") || args.Uri.AbsoluteUri.Contains("pic/cosplay")) { Frame.Navigate(typeof(TPPage)); Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1); } else if (args.Uri.AbsoluteUri.Contains("donghua")) { args.Cancel = true; WB(args.Uri.AbsoluteUri); } else { Frame.Navigate(typeof(NewsPage), @"http://wap.gamersky.com/news/Content-" + args.Uri.AbsoluteUri.Substring(args.Uri.AbsoluteUri.LastIndexOf(@"/") + 1, args.Uri.AbsoluteUri.LastIndexOf(@".") - 1 - args.Uri.AbsoluteUri.LastIndexOf(@"/")) + ".html"); } } else//其他 { args.Cancel = true; WB(args.Uri.AbsoluteUri); } } } }