add two converters
This commit is contained in:
1 parent
37386753f7
commit
bd07d1b7e3
4 files changed
+71
No files matched your search
@@ -106,6 +106,8 @@
|
||||
<Compile Include="Data\Gif\GifPropertyItem.cs" />
|
||||
<Compile Include="Data\Gif\GifPropertyItemInternal.cs" />
|
||||
<Compile Include="Data\Gif\GPStream.cs" />
|
||||
<Compile Include="Tools\Converter\Boolean2StrConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Int2StrConverter.cs" />
|
||||
<Compile Include="Tools\Helper\ColorHelper.cs" />
|
||||
<Compile Include="Tools\GifImageAnimator.cs" />
|
||||
<Compile Include="Data\GrowlInfo.cs" />
|
||||
|
||||
@@ -13,5 +13,7 @@
|
||||
<converter:TreeViewItemMarginConverter x:Key="TreeViewItemMarginConverter"/>
|
||||
<converter:Color2HexStrConverter x:Key="Color2HexStrConverter"/>
|
||||
<converter:Object2BooleanConverter x:Key="Object2BooleanConverter"/>
|
||||
<converter:Boolean2StrConverter x:Key="Boolean2StrConverter"/>
|
||||
<converter:Int2StrConverter x:Key="Int2StrConverter"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Boolean2StrConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
if (parameter is string str)
|
||||
{
|
||||
var arr = str.Split(';');
|
||||
if (arr.Length > 1)
|
||||
{
|
||||
return boolValue ? arr[1] : arr[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Int2StrConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int intValue)
|
||||
{
|
||||
if (parameter is string str)
|
||||
{
|
||||
var arr = str.Split(';');
|
||||
if (arr.Length > intValue)
|
||||
{
|
||||
return arr[intValue];
|
||||
}
|
||||
|
||||
return intValue;
|
||||
}
|
||||
|
||||
return intValue;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user