/// <summary> /// 下载图片进度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void bitmapImage_DownloadProgress(object sender, DownloadProgressEventArgs e) { if (e.Progress == 100) { BitmapImage bitmapImage = sender as BitmapImage; int height = bitmapImage.PixelHeight; int width = bitmapImage.PixelWidth; //当下载的图片有效时 if (height > 0 && width > 0) { if (width > bitmapImage.PixelHeight) { CurImage.Width = (width < CurImage.MaxWidth) ? width : CurImage.MaxWidth; } else { CurImage.Height = (height < CurImage.MaxHeight) ? height : CurImage.MaxHeight; } CurImageFadeIn.Begin(); } else //不存在或路径无效时 { CurImage.Source = new BitmapImage(new Uri("/Images/NoPhoto.png", UriKind.RelativeOrAbsolute)); CurImage.Width = 380; CurImage.Height = 250; } LoadingBar.Visibility = System.Windows.Visibility.Collapsed; } else { //LoadInfo.Content = "正在加载数据" + e.Progress + "..."; LoadingBar.Value = e.Progress; LoadingBar.Visibility = System.Windows.Visibility.Visible; } }
/// <summary> /// 下载图片进度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void bitmapImage_DownloadProgress(object sender, DownloadProgressEventArgs e) { if (e.Progress == 100) { BitmapImage bitmapImage = sender as BitmapImage; int height = bitmapImage.PixelHeight; int width = bitmapImage.PixelWidth; //当下载的图片有效时 if (height > 0 && width > 0) { if (width > bitmapImage.PixelHeight) { CurImage.Width = (width < CurImage.MaxWidth) ? width : CurImage.MaxWidth; } else { CurImage.Height = (height < CurImage.MaxHeight) ? height : CurImage.MaxHeight; } //SetPositionInfo(height, width); LoadInfo.Visibility = System.Windows.Visibility.Collapsed; CurImageFadeIn.Begin(); } else //不存在或路径无效时 { //CurImage.Source = new BitmapImage(new Uri("/Images/NoPhoto.jpg", UriKind.RelativeOrAbsolute)); //CurImage.Width = 142; //CurImage.Height = 119; LoadInfo.Content = "图片信息无效!"; } } else { LoadInfo.Content = "正在加载数据" + e.Progress + "..."; } }