2025-10-31 12:50:24 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
2025-10-31 13:53:17 +01:00
|
|
|
using System.Windows.Data;
|
2025-10-31 12:50:24 +01:00
|
|
|
|
|
|
|
|
namespace Haftmittel
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// true na jasnozielony, false na pomarańczowy
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ValueConversion(typeof(double), typeof(bool))]
|
|
|
|
|
public class ClassKonwerterNaProcenty: IValueConverter
|
|
|
|
|
{
|
2025-10-31 13:53:17 +01:00
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
2025-10-31 12:50:24 +01:00
|
|
|
{
|
2025-10-31 15:05:50 +01:00
|
|
|
if (value is bool b)
|
2025-10-31 12:50:24 +01:00
|
|
|
{
|
2025-10-31 15:05:50 +01:00
|
|
|
if (b)
|
2025-10-31 12:50:24 +01:00
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0.2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0.2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-31 13:53:17 +01:00
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
2025-10-31 12:50:24 +01:00
|
|
|
{
|
2025-10-31 15:05:50 +01:00
|
|
|
if (value is double d)
|
2025-10-31 12:50:24 +01:00
|
|
|
{
|
2025-10-31 15:05:50 +01:00
|
|
|
return d == 1;
|
2025-10-31 12:50:24 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|