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!");
}
}

Converter的更多相关文章

  1. 解决springmvc报No converter found for return value of type: class java.util.ArrayList问题

    一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...

  2. spring类型自动转换——@InitBinder和Converter

    spring有2种类型转换器,一种是propertyEditor,一种是Converter.虽然都是类型转换,但是还是有细微差别. 所以这里以一个例子的形式来分析一下这2种类型转换的使用场景和差别. ...

  3. 破解Java to C# Converter

    起因 最近在对接一个第三方平台.该平台只提供了Java版本的SDK,C#版本的还处于敬请期待状态.由于C#可以复用绝大部分代码,便考虑找一个Java到C#的转换器,在试用了几个软件之后,发现还是Jav ...

  4. wpf converter converterparameter 绑定多参数

    1. converterparameter不是依赖属性,所以不能用binding. 2. 可以把converter 的接口 IValueConverter改为 IMultiValueConverter ...

  5. 新版Retrofit 2可运行例子(解决Could not locate ResponseBody converter for问题)

    Retrofit这东西我就不多做解释了,反正最近应用很广,基本都快和OkHttp一起成为安卓的事实网络访问标准框架了. 这么好的一个东西,官网文档实在是不算太好,说的不太清晰.按官网的经常会有“Cou ...

  6. Converter转换器使用

    package com.xu.javabean; import java.lang.reflect.InvocationTargetException; import java.util.Date; ...

  7. Ultra Video Splitter & Converter

    1. Video Splitter http://www.aone-soft.com/splitter.htm Ultra Video Splitter 是一款视频分割工具.可将一个巨大的AVI/Di ...

  8. Windows Server 2008 Workstation Converter优化设置

    http://www.win2008workstation.com/windows-server-2008-workstation-converter/ If you don’t want to co ...

  9. 电量显示Binding Converter MVVM

    用一个ProcessBar显示电量,低于20%时候,ForeGround为红色,否则为绿色, 页面使用了MVVM绑定到了ViewModel, ProcessBar XAML为 <Progress ...

  10. 自定义类型转换器converter

    作用:目前将日期转换成string,将string转换成我想要的类型   0509课件里讲 一.数据类型转换在web应用程序中,数据存在两个方向上的转换:1.当提交表单时  表单数据以字符串的形式提交 ...

随机推荐

  1. html5+js压缩图片上传

    最近在折腾移动站的开发,涉及到了一个手机里面上传图片.于是经过N久的折腾,找到一个插件,用法如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...

  2. Java基本数据类型之间赋值与运算归纳

    前言:面对“byte b1=3;byteb2=7;byte b=b1+b2;”报错,而“int i1=3;int i2=7;int i=i1+i2;”不报错,进行了深入探究,从而引申出java基本类型 ...

  3. https://github.com/zhangxianyi/Source-Insight-Plugin

    https://github.com/zhangxianyi/Source-Insight-Plugin

  4. COCOS学习笔记--单点触控

    这篇博客来总结下cocos单点触控的相关内容: 我们在Layer类的源代码中能够看到.Layer类提供了一下4个与屏幕单点触控相关的回调方法: onTouchBegan().onTouchMoved( ...

  5. HDU 5044 Tree(树链剖分)

    HDU 5044 Tree field=problem&key=2014+ACM%2FICPC+Asia+Regional+Shanghai+Online&source=1&s ...

  6. Color the ball(杭电1556)

    Color the ball Time Limit : 9000/3000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  7. 【codeforces 546A】Soldier and Bananas

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【严肃脸】使用caffe实现色情图片的识别

    前言 前几天看到了雅虎开源了一个色情图片的识别模型新闻,上Github一看,是基于caffe的.试了试,模型效果很赞.Github地址:https://github.com/yahoo/open_ns ...

  9. Arcgis api for javascript学习笔记(3.2X版本)-Map图层叠加以及基本操作

    1. 不设置默认底图,第一个图层作为底图,然后叠加另外一个图层 先添加图层1,第一个图层1作为默认底图,然后在图层1上叠加图层2,并设置图层2的透明度为50%. <!DOCTYPE html&g ...

  10. 强烈推荐node包colors

    库链接:colors 在你的 node.js 控制台中获取颜色