first full rendering sample of pop% cap with styling

This commit is contained in:
2025-03-16 12:45:09 +01:00
parent 2c9ff99502
commit 7bb34a4b51
6 changed files with 112 additions and 42 deletions

View 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
};
});
}