first full rendering sample of pop% cap with styling
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:StarsAssistant.ViewModels"
|
||||
xmlns:helpers="using:StarsAssistant.Views.Helpers"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="200"
|
||||
x:Class="StarsAssistant.Views.BuColView"
|
||||
x:DataType="vm:BuColViewModel">
|
||||
@ -16,15 +17,9 @@
|
||||
RowHeight="24" FontSize="12"
|
||||
BorderThickness="1" BorderBrush="Gray"
|
||||
>
|
||||
|
||||
|
||||
|
||||
<DataGrid.Columns>
|
||||
|
||||
|
||||
|
||||
|
||||
<DataGridTextColumn Header="Planet" Binding="{Binding Name}" CellStyleClasses="cool"/>
|
||||
<DataGridTextColumn Header="Planet" Binding="{Binding Name}" />
|
||||
<!-- Class -->
|
||||
<!-- Info -->
|
||||
<DataGridTextColumn Header="Pop" Binding="{Binding Population}" />
|
||||
@ -32,7 +27,27 @@
|
||||
<DataGridTextColumn Header="Growth" Binding="{Binding PopulationGrowth}" />
|
||||
<DataGridTextColumn Header="Pop T1" Binding="{Binding EnRoutePopulation}" />
|
||||
<DataGridTextColumn Header="Pop T%" Binding="{Binding PopulationTargetPercent}" IsReadOnly="false"/>
|
||||
<DataGridTextColumn Header="Pop %" Binding="{Binding CapacityPercent }" />
|
||||
<DataGridTextColumn Header="Pop %1" Binding="{Binding CapacityPercent }" />
|
||||
|
||||
<DataGridTemplateColumn Header="Pop %2" SortMemberPath="CapacityPercent">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Border
|
||||
Classes.Good="{Binding CapacityPercent,
|
||||
Converter={x:Static helpers:PlanetStyleConverters.PopulationPercentGood}}"
|
||||
Classes.Warning="{Binding CapacityPercent,
|
||||
Converter={x:Static helpers:PlanetStyleConverters.PopulationPercentWarning}}"
|
||||
Classes.Bad="{Binding CapacityPercent,
|
||||
Converter={x:Static helpers:PlanetStyleConverters.PopulationPercentBad}}"
|
||||
Classes.Inactive="{Binding CapacityPercent,
|
||||
Converter={x:Static helpers:PlanetStyleConverters.PopulationPercentInactive}}"
|
||||
>
|
||||
<TextBlock Text="{Binding CapacityPercent, StringFormat='{}{0} %'}"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Terra Delta assumed -->
|
||||
<DataGridTextColumn Header="Value" Binding="{Binding Value}" />
|
||||
|
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