Files
GotecHaftmittel/APQP/ClassKonwerterNaProcenty.cs
T

45 lines
1.0 KiB
C#
Raw Normal View History

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
{
if (value is bool)
{
if ((bool)value)
{
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
{
if (value is double)
{
return ((double)value == 1);
}
else
{
return false;
}
}
}
}