Converter


    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,布布扣,bubuko.com

时间: 2024-08-15 01:10:57

Converter的相关文章

Dozer 自定义Converter -- LocalDateTime to Date

Spring boot项目,使用dozer将Jpa Entity中的LocalDateTime属性转到DTO中对应的LocalDateTime属性中报错 java.lang.NoSuchMethodException: java.time.LocalDateTime.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[na:1.8.0_51] at java.lang.Class.getDeclaredConstruct

PDF编辑工具——PDF Desktop Converter 4 Professional

管理和操作PDF的工具.PDF Desktop Converter 4 Professional可以生成,转换,提取,组合,分割合并PDF.新增加的OCR功能可以将扫描后的文件转变成可以检索和编辑的PDF.以上这些功能只需要一个软件就可以全部实现. 软件特点 1. 快速,准确,简单的生成PDF. * Add-in按钮 -从Microsoft应用程序立即生成PDF -无需Microsoft应用程序,可以立即将PDF转换成Word,Excel. * 采用密码对PDF文件中的敏感信息进行控制,限制浏览

VMware Converter Standalone 6.1.1 P2V迁移Linux一例

VMware vCenter Converter Standalone是P2V的重要工具,可以迁移Windows,Linux等操作系统,但是经常会出现一些细节问题造成无法成功,本文通过VMware vCenter Converter standalone6.1.1工具成功迁移DELL R310老旧服务器(Centos5.8 x64)到ESXi6.0U2虚拟化平台上,现通过虚拟机模拟与记录过程与处理方式. 一.注意事项: (1)必须要有root权限,可以SSH登录.   (2)网络没有问题,转换的

精品软件 推荐 电子书转换器 EPUB to PDF Converter

EPUB to PDF Converter 是一个简单易用的电子书转换器,可以将 EPUB 格式的文档一键转换为适用于各类阅读设备的 PDF 文件. Epubor ePUB2PDF Converter 软件内置了适用于很多阅读设备的转换配置,包括 Amazon (Kindle).Apple (iPad/iPhone).Nook.Kobo.Sony eReader 等,也可以自定义输出设备,设置 PDF 文档的页面尺寸.页面宽度.页面高度.页边距等参数. Epubor ePUB2PDF Conve

170616、解决 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList

报错截图: 原因:搭建项目的时候,springmvc默认是没有对象转换成json的转换器的,需要手动添加jackson依赖. 解决步骤: 1.添加jackson依赖到pom.xml <!-- jaskson --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>

java:struts框架5(Converter,validation,Tags)

1.Converter: struts.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> &

Converter转换器使用

1 package com.xu.javabean; 2 3 import java.lang.reflect.InvocationTargetException; 4 import java.util.Date; 5 import java.text.ParseException; 6 import java.text.SimpleDateFormat; 7 8 import org.apache.commons.beanutils.BeanUtils; 9 import org.apache

Android攻略--单位转化器UC--Units Converter(学习笔记)

1创建工程 注意这个名称的命名: 3. UC结构及相关代码 UC.java 用于执行单位换算的Activity // UC.java package com.apress.uc; import android.app.Activity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.w

vmware converter P2V linux要点

1.目标物理机ssh allow all,默认22端口: 2.Options Advanced: Reconfigure destination vm 关闭 3.Helper VM network configuration 必须填写可通IP地址(重要) 4.修复grub ># fdisk -l #查看第几块硬盘上的第几分区挂载到了/boot上,对应到下面的root (hd0,0)这里. ># chroot /mnt/sysimage/ ># grub ># root (hd0,0

AutoDWG.DWG.PDF.Converter.2016.v4.92 1CD

2015.10.14最新软件表 AVL CRUISE M 2015.0 Win32_64 1DVD  Nemetschek.SCIA.Engineer.2015.v15.1.106 1DVD  pyaoaoaosoft109.1  Type3 CAA V5 Based v5.5A for CATIA V5R19-R24 Win64 6CD  Chemstations.CHEMCAD.Suite.v6.5.7.8139 1CD  Optitex.v15.0.198.0.Win32 1DVD  Au