first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ClassicAssist.UI.Misc.ValueConverters
|
||||
{
|
||||
public class EnumMatchToBooleanConverter : IValueConverter
|
||||
{
|
||||
public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
|
||||
{
|
||||
if ( value == null || parameter == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string checkValue = value.ToString();
|
||||
string targetValue = parameter.ToString();
|
||||
return checkValue.Equals( targetValue, StringComparison.InvariantCultureIgnoreCase );
|
||||
}
|
||||
|
||||
public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
|
||||
{
|
||||
if ( value == null || parameter == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bool useValue = (bool) value;
|
||||
string targetValue = parameter.ToString();
|
||||
|
||||
if ( useValue )
|
||||
{
|
||||
return Enum.Parse( targetType, targetValue );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user