62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Avalonia.Data.Converters;
|
|
|
|
namespace StarsAssistant.Views.Helpers;
|
|
|
|
public static class PlanetStyleConverters
|
|
{
|
|
/// <summary>
|
|
/// Check, if the planet pop percentage is in the warning range
|
|
/// </summary>
|
|
public static FuncValueConverter<int?, bool> PopulationPercentWarning { get; }
|
|
= new((value) =>
|
|
{
|
|
return value switch
|
|
{
|
|
null => false,
|
|
> 0 and < 25 or > 33 and <= 50 => true,
|
|
_ => false
|
|
};
|
|
});
|
|
|
|
/// <summary>
|
|
/// Check, if the planet pop percentage is in a bad range (overpop)
|
|
/// </summary>
|
|
public static FuncValueConverter<int?, bool> PopulationPercentBad { get; }
|
|
= new((value) =>
|
|
{
|
|
return value switch
|
|
{
|
|
null => false,
|
|
> 100 => true,
|
|
_ => false
|
|
};
|
|
});
|
|
|
|
/// <summary>
|
|
/// Check, if the planet pop percentage is in a good range (growth-wise)
|
|
/// </summary>
|
|
public static FuncValueConverter<int?, bool> PopulationPercentGood { get; }
|
|
= new((value) =>
|
|
{
|
|
return value switch
|
|
{
|
|
null => false,
|
|
>= 25 and <= 33 => true,
|
|
_ => false
|
|
};
|
|
});
|
|
|
|
/// <summary>
|
|
/// Check, if the planet pop percentage is not relevant (100%)
|
|
/// </summary>
|
|
public static FuncValueConverter<int?, bool> PopulationPercentInactive { get; }
|
|
= new((value) =>
|
|
{
|
|
return value switch
|
|
{
|
|
null => false,
|
|
> 99 and <= 100 => true,
|
|
_ => false
|
|
};
|
|
});
|
|
} |