45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace Haftmittel
|
|
{
|
|
/// <summary>
|
|
/// true na jasnozielony, false na pomarańczowy
|
|
/// </summary>
|
|
[ValueConversion(typeof(double), typeof(bool))]
|
|
public class ClassKonwerterNaProcenty: IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is bool b)
|
|
{
|
|
if (b)
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return 0.2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 0.2;
|
|
}
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is double d)
|
|
{
|
|
return d == 1;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|