|
@@ -18,19 +18,28 @@ namespace SAGA.DotNetUtils.WPF.Converter
|
|
/// <summary>
|
|
/// <summary>
|
|
/// StringToImageConverter
|
|
/// StringToImageConverter
|
|
/// </summary>
|
|
/// </summary>
|
|
- public class StringToImageConverter:IValueConverter
|
|
|
|
|
|
+ public class StringToImageConverter : IValueConverter
|
|
{
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
{
|
|
BitmapImage img = new BitmapImage();
|
|
BitmapImage img = new BitmapImage();
|
|
if (value == null) return img;
|
|
if (value == null) return img;
|
|
//若要原始文件的站点,可以调用 Application 类的 GetRemoteStream 方法,同时传递标识原始文件的所需站点的 pack URI。 GetRemoteStream 将返回一个 StreamResourceInfo 对象,该对象将原始文件的该站点作为 Stream 公开,并描述其内容类型。
|
|
//若要原始文件的站点,可以调用 Application 类的 GetRemoteStream 方法,同时传递标识原始文件的所需站点的 pack URI。 GetRemoteStream 将返回一个 StreamResourceInfo 对象,该对象将原始文件的该站点作为 Stream 公开,并描述其内容类型。
|
|
- var uri = new Uri(value.ToString().Replace("%20", " "), UriKind.Relative);
|
|
|
|
- StreamResourceInfo info = Application.GetRemoteStream(uri);
|
|
|
|
- img.BeginInit();
|
|
|
|
- //img.UriSource = new Uri(value.ToString(), UriKind.Relative);
|
|
|
|
- img.StreamSource = info.Stream;
|
|
|
|
- img.EndInit();
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ var uri = new Uri(value.ToString().Replace("%20", " "), UriKind.Relative);
|
|
|
|
+ StreamResourceInfo info = Application.GetRemoteStream(uri);
|
|
|
|
+ img.BeginInit();
|
|
|
|
+ //img.UriSource = new Uri(value.ToString(), UriKind.Relative);
|
|
|
|
+ img.StreamSource = info.Stream;
|
|
|
|
+ img.EndInit();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine(e);
|
|
|
|
+ img = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
return img;
|
|
return img;
|
|
}
|
|
}
|
|
|
|
|