first full rendering sample of pop% cap with styling
This commit is contained in:
62
Stars Assistant/Views/Helpers/PlanetStyleConverters.cs
Normal file
62
Stars Assistant/Views/Helpers/PlanetStyleConverters.cs
Normal file
@ -0,0 +1,62 @@
|
||||
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
|
||||
};
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user