public class ImgPathConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return null;
string CommadnFolderPath = System.Environment.CurrentDirectory;
string FilePath = System.IO.Path.Combine(CommadnFolderPath, @"Picture\Server\GroupPage\");
string ImagePath;
switch((SyncModel.PlatformType)value)
{
case SyncModel.PlatformType.DoNetClient :
ImagePath = FilePath + "server_pc.png";
break;
case SyncModel.PlatformType.DoNetClientAIO:
ImagePath = FilePath + "server_aio.png";
break;
case SyncModel.PlatformType.DoNetClientNB:
ImagePath = FilePath + "server_nb.png";
break;
case SyncModel.PlatformType.DoNetClientTable:
ImagePath = FilePath + "server_tablet.png";
break;
case SyncModel.PlatformType.DoNetClientMSIAIO:
ImagePath = FilePath + "server_aio_msi.png";
break;
case SyncModel.PlatformType.DoNetClientMSINB:
ImagePath = FilePath + "server_nb_msi.png";
break;
case SyncModel.PlatformType.DoNetClientMSITable:
ImagePath = FilePath + "server_tablet_msi.png";
break;
default :
ImagePath = FilePath + "server_pc.png";
break;
} Uri uri = new Uri(ImagePath, UriKind.Absolute); //Uri uri = new Uri((value as string),UriKind.Relative);
ImageBrush imgBru = new ImageBrush(); BitmapImage bImg = new BitmapImage();
bImg.BeginInit();
bImg.CacheOption = BitmapCacheOption.OnLoad;
bImg.UriSource = uri;
bImg.EndInit(); imgBru.ImageSource = bImg;
imgBru.Stretch = Stretch.Fill;
bImg.Freeze();
return imgBru;
// return (isVisible ? Visibility.Visible : Visibility.Hidden);
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
return value;
// throw new InvalidOperationException("Not yet support this function!");
}
}
    public class BoolVisibleConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isVisible;
if (value == null || !(value is bool))
{
isVisible = false;
}
else
{
isVisible = (bool)value;
}
return (isVisible ? Visibility.Visible : Visibility.Hidden);
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
throw new InvalidOperationException("Not yet support this function!");
}
}
    public class DateTimeToStringConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DateTime d = (DateTime)value;
if (DateTime.Equals(d, DateTime.MinValue))
return string.Empty;
else
return d;
}
public object ConvertBack(object value, Type targetType, object parameter,CultureInfo culture)
{
throw new InvalidOperationException("Not yet support this function!");
}
}

最新文章

  1. stringstream的基本用法
  2. PHPCMS V9多站点[站群功能]动态设置与静态设置子站内容URL
  3. linux 脚本命令匹配并获取下一行数据
  4. Hibernate中延迟加载和缓存
  5. 实验一(不知道怎么上传.docx格式)
  6. CI框架3.0关于session的设置改动及存数据库的使用方法
  7. 4. 对list进行sort
  8. [JavaScript] JS中对Base64的解析
  9. 基于matlab的GUI界面开发软件
  10. poj 1015 Jury Compromise_dp
  11. 图论+dp poj 1112 Team Them Up!
  12. 深入解析Java垃圾回收机制
  13. codeforces 1151 A
  14. 改写pipeline
  15. 【Django】django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
  16. Python 线程同步变量,同步条件,列队
  17. LR报错Error -27780: [GENERAL_MSG_CAT_SSL_ERROR]connect to host "XXX.XXX.com" failed解决方法
  18. 跨年操作--new Date()
  19. Mybatis逆向工程——(十四)
  20. 【Unity】2.9 光源(Lights)

热门文章

  1. Opencv在视频中静态、动态方式绘制矩形框ROI
  2. css 翻牌 翻转 3d翻转 特效
  3. Android 动态改变高度以及计算长度的EditText
  4. Use Word 2010's Navigation Pane to quickly reorganize documents
  5. 【9107】Hanoi双塔问题(NOIP2007)
  6. 1046: 找不到类型,或者它不是编译时常数: PieSeries
  7. 【t083】买票
  8. HTML5物理游戏开发 - 越野山地自行车(三)粉碎自行车
  9. wpf datagrid 的单元格内容超出列宽度
  10. Oracle12c导入scott测试用户(转)