Converter
2024-08-31 22:08:59
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!");
}
}
最新文章
- stringstream的基本用法
- PHPCMS V9多站点[站群功能]动态设置与静态设置子站内容URL
- linux 脚本命令匹配并获取下一行数据
- Hibernate中延迟加载和缓存
- 实验一(不知道怎么上传.docx格式)
- CI框架3.0关于session的设置改动及存数据库的使用方法
- 4. 对list进行sort
- [JavaScript] JS中对Base64的解析
- 基于matlab的GUI界面开发软件
- poj 1015 Jury Compromise_dp
- 图论+dp poj 1112 Team Them Up!
- 深入解析Java垃圾回收机制
- codeforces 1151 A
- 改写pipeline
- 【Django】django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
- Python 线程同步变量,同步条件,列队
- LR报错Error -27780: [GENERAL_MSG_CAT_SSL_ERROR]connect to host ";XXX.XXX.com"; failed解决方法
- 跨年操作--new Date()
- Mybatis逆向工程——(十四)
- 【Unity】2.9 光源(Lights)
热门文章
- Opencv在视频中静态、动态方式绘制矩形框ROI
- css 翻牌 翻转 3d翻转 特效
- Android 动态改变高度以及计算长度的EditText
- Use Word 2010's Navigation Pane to quickly reorganize documents
- 【9107】Hanoi双塔问题(NOIP2007)
- 1046: 找不到类型,或者它不是编译时常数: PieSeries
- 【t083】买票
- HTML5物理游戏开发 - 越野山地自行车(三)粉碎自行车
- wpf datagrid 的单元格内容超出列宽度
- Oracle12c导入scott测试用户(转)