Fixing vehicle cell. Adding some info to report page.

This commit is contained in:
Selim Mustafaev 2024-04-28 23:23:25 +03:00
parent 6259d182e4
commit e5afc6dbdc
12 changed files with 204 additions and 33 deletions

View File

@ -3,4 +3,7 @@
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt; <s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;
&lt;Assembly Path="/Users/selim/.nuget/packages/avalonia/11.0.0/ref/net6.0/Avalonia.Markup.dll" /&gt; &lt;Assembly Path="/Users/selim/.nuget/packages/avalonia/11.0.0/ref/net6.0/Avalonia.Markup.dll" /&gt;
&lt;Assembly Path="/Users/selim/Documents/dev/AutoCatAvalonia/AutoCat/bin/Debug/net7.0/Avalonia.Base.dll" /&gt; &lt;Assembly Path="/Users/selim/Documents/dev/AutoCatAvalonia/AutoCat/bin/Debug/net7.0/Avalonia.Base.dll" /&gt;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary> &lt;/AssemblyExplorer&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=ec0d04c1_002D7b57_002D460c_002Da7f0_002Db7883783f338/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from 2-0" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;ProjectFile&gt;9FB32BFB-805B-49F2-B5A2-E1F5A0C06A62/d:Views/f:PlateView.axaml/z:2-0&lt;/ProjectFile&gt;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>

View File

@ -14,7 +14,7 @@
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="Resources/Colors.axaml"/> <ResourceInclude Source="Resources/Colors.axaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<FontFamily x:Key="RoadNumbersFont">avares://Assets/Fonts/RoadNumbers2.0.otf</FontFamily> <FontFamily x:Key="RoadNumbersFont">avares://AutoCat/Assets/Fonts#RoadNumbers</FontFamily>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@ -18,13 +18,14 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.6" /> <PackageReference Include="AsyncImageLoader.Avalonia" Version="3.2.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.6" /> <PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.6" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.6" /> <PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" /> <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.4" /> <PackageReference Include="FluentAvaloniaUI" Version="2.0.5" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.5.1" /> <PackageReference Include="MessageBox.Avalonia" Version="3.1.5.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />

View File

@ -0,0 +1,27 @@
using System;
using Avalonia;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.MarkupExtensions;
namespace AutoCat.Extensions;
public class ThicknessExtension: MarkupExtension
{
public string Path { get; set; }
public double Mult { get; set; } = 1;
public double Add { get; set; } = 0;
public override object ProvideValue(IServiceProvider serviceProvider)
{
var binding = new ReflectionBindingExtension(Path)
{
Mode = BindingMode.OneWay,
Converter = new FuncValueConverter<double, object>(e => new Thickness( e*Mult + Add))
};
return binding.ProvideValue(serviceProvider);
}
}

View File

@ -3,10 +3,37 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:AutoCat.Pages" xmlns:pages="clr-namespace:AutoCat.Pages"
xmlns:views="clr-namespace:AutoCat.Views"
xmlns:imageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AutoCat.Pages.ReportPage" x:Class="AutoCat.Pages.ReportPage"
x:DataType="pages:ReportPage" x:DataType="pages:ReportPage"
x:CompileBindings="True"> x:CompileBindings="True">
<TextBlock Text="{Binding Vehicle.Number}"/> <Grid Margin="16" ColumnDefinitions="* 16 *" RowDefinitions="Auto 16 Auto">
<StackPanel Grid.Row="0" Grid.ColumnSpan="3" Orientation="Horizontal" Spacing="16">
<Image Height="36" imageLoader:ImageLoader.Source="{Binding Vehicle.Brand.Logo}"/>
<TextBlock VerticalAlignment="Center" FontSize="20" Text="{Binding Vehicle.Brand.Name.Original}"/>
</StackPanel>
<Expander Grid.Row="2" Grid.Column="0" Header="General" IsExpanded="True">
<StackPanel Orientation="Vertical" Spacing="16">
<views:ReportTextItem Label="Year" Value="{Binding Vehicle.Year}"/>
<views:ReportTextItem Label="Color" Value="{Binding Vehicle.Color}"/>
<views:ReportTextItem Label="Category" Value="{Binding Vehicle.Category}"/>
<views:ReportTextItem Label="Steering wheel position" Value="{Binding Vehicle.IsRightWheel}"/>
<views:ReportTextItem Label="Is Japanese" Value="{Binding Vehicle.IsJapanese}"/>
</StackPanel>
</Expander>
<Expander Grid.Row="2" Grid.Column="2" Header="Identifiers" IsExpanded="True">
<StackPanel Orientation="Vertical" Spacing="16">
<views:ReportTextItem Label="Plate number" Value="{Binding Vehicle.Number}"/>
<views:ReportTextItem Label="VIN" Value="{Binding Vehicle.Vin1}"/>
<views:ReportTextItem Label="STS" Value="{Binding Vehicle.Sts}"/>
<views:ReportTextItem Label="PTS" Value="{Binding Vehicle.Pts}"/>
</StackPanel>
</Expander>
</Grid>
</UserControl> </UserControl>

View File

@ -7,11 +7,11 @@
<ext:DateConverter x:Key="DateConverter"/> <ext:DateConverter x:Key="DateConverter"/>
<DataTemplate DataType="{x:Type models:Vehicle}" x:Key="VehicleCell"> <DataTemplate DataType="{x:Type models:Vehicle}" x:Key="VehicleCell">
<StackPanel Orientation="Vertical" Margin="0,4"> <StackPanel Orientation="Vertical" Spacing="8" Margin="0,8">
<Grid ColumnDefinitions="*"> <Grid ColumnDefinitions="*">
<TextBlock Text="{Binding Brand.Name.Original}"/> <TextBlock Text="{Binding Brand.Name.Original}"/>
</Grid> </Grid>
<Grid ColumnDefinitions="* Auto" RowDefinitions="*,*"> <Grid ColumnDefinitions="150 *" RowDefinitions="*,*">
<views:PlateView Grid.RowSpan="2" Number="{Binding Number}"/> <views:PlateView Grid.RowSpan="2" Number="{Binding Number}"/>
<TextBlock <TextBlock
Grid.Column="1" Grid.Column="1"
@ -20,6 +20,7 @@
FontSize="11" FontSize="11"
Foreground="{DynamicResource SecondaryText}" Foreground="{DynamicResource SecondaryText}"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Text="{Binding UpdatedDate, Converter={StaticResource DateConverter}}"/> Text="{Binding UpdatedDate, Converter={StaticResource DateConverter}}"/>
<TextBlock <TextBlock
Grid.Column="1" Grid.Column="1"
@ -28,6 +29,7 @@
FontSize="11" FontSize="11"
Foreground="{DynamicResource TertiaryText}" Foreground="{DynamicResource TertiaryText}"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Text="{Binding AddedDate, Converter={StaticResource DateConverter}}"/> Text="{Binding AddedDate, Converter={StaticResource DateConverter}}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>

View File

@ -7,11 +7,12 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AutoCat.Views.MasterDetailView" x:Class="AutoCat.Views.MasterDetailView"
x:DataType="views:MasterDetailView" x:DataType="views:MasterDetailView"
x:CompileBindings="True"> x:CompileBindings="True"
Name="MasterDetail">
<Grid ColumnDefinitions="300, Auto, *"> <Grid ColumnDefinitions="300, Auto, *">
<ListBox ItemsSource="{Binding ItemsSource}" <ListBox ItemsSource="{Binding ItemsSource}"
ItemTemplate="{Binding ItemTemplate}" ItemTemplate="{Binding ElementName=MasterDetail, Path=ItemTemplate}"
Name="VehiclesList"/> Name="VehiclesList"/>
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/> <GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
<!-- <!--

View File

@ -10,45 +10,52 @@
SizeChanged="UserControl_SizeChanged"> SizeChanged="UserControl_SizeChanged">
<Grid Height="{ext:Math Path=#PlateViewControl.Bounds.Width, Mult={x:Static views:PlateView.AspectRatio}}"> <Grid Height="{ext:Math Path=#PlateViewControl.Bounds.Width, Mult={x:Static views:PlateView.AspectRatio}}">
<Rectangle RadiusX="6" RadiusY="6" Fill="#ccc"/> <Rectangle Name="MainRect" Fill="#ccc"/>
<Grid ColumnDefinitions="73*,27*"> <Grid ColumnDefinitions="73*,27*">
<Grid> <Grid>
<Rectangle Grid.Column="0" RadiusX="4" RadiusY="4" VerticalAlignment="Stretch" Fill="#333" Margin="2"/> <Rectangle Grid.Column="0"
Name="NumberRect"
VerticalAlignment="Stretch"
Fill="#333"/>
<TextBlock x:Name="NumberBox" <TextBlock x:Name="NumberBox"
Text="A163AA" Text="A163AA"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
TextAlignment="Center"
Foreground="#ccc" Foreground="#ccc"
FontSize="{ext:Math Path=#PlateViewControl.Bounds.Height, Mult=0.6}"/> ClipToBounds="False"
FontFamily="{StaticResource RoadNumbersFont}"/>
</Grid> </Grid>
<Rectangle Grid.Column="1" RadiusX="4" RadiusY="4" VerticalAlignment="Stretch" Fill="#333" Margin="0,2,2,2"/> <Rectangle Grid.Column="1"
<Grid Grid.Column="1" Margin="0,2,2,2" RowDefinitions="65*,35*"> Name="RegionRect"
VerticalAlignment="Stretch"
Fill="#333"/>
<Grid Grid.Column="1" Name="RegionGrid" RowDefinitions="65*,35*">
<TextBlock Grid.Row="0" <TextBlock Grid.Row="0"
x:Name="RegionBox" x:Name="RegionBox"
Text="161" Text="161"
ClipToBounds="False"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Foreground="#ccc" Foreground="#ccc"
FontSize="{ext:Math Path=#PlateViewControl.Bounds.Height, Mult=0.35}"/> FontFamily="{StaticResource RoadNumbersFont}"/>
<Grid Grid.Row="1" Margin="3,1" x:Name="CountryRow" ColumnDefinitions="Auto,*"> <StackPanel Grid.Row="1" x:Name="CountryRow"
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Grid.Column="0" <TextBlock Grid.Column="0"
x:Name="CountryName" x:Name="CountryName"
Text="RUS" Text="RUS"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Foreground="#ccc" Foreground="#ccc"/>
FontSize="{ext:Math Path=#PlateViewControl.Bounds.Height, Mult=0.2}"/> <Grid Grid.Column="2" x:Name="FlagGrid" RowDefinitions="*,*,*">
<!--
<Grid Grid.Column="2" x:Name="FlagGrid" Margin="1" RowDefinitions="*,*,*">
<Rectangle Grid.Row="0" Fill="White"/> <Rectangle Grid.Row="0" Fill="White"/>
<Rectangle Grid.Row="1" Fill="Blue"/> <Rectangle Grid.Row="1" Fill="Blue"/>
<Rectangle Grid.Row="2" Fill="Red"/> <Rectangle Grid.Row="2" Fill="Red"/>
</Grid> </Grid>
--> </StackPanel>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>

View File

@ -3,6 +3,7 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using SkiaSharp;
namespace AutoCat.Views; namespace AutoCat.Views;
@ -49,9 +50,33 @@ public partial class PlateView : UserControl
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{ {
if (Bounds.Height > 0) if(Bounds.Height <= 0)
{ return;
//Console.WriteLine($"=== new height: {Bounds.Height}");
} var frameWidth = Bounds.Height * 0.05;
var outerRadius = Bounds.Height * 0.15;
var innerRadius = outerRadius - frameWidth;
MainRect.RadiusX = outerRadius;
MainRect.RadiusY = outerRadius;
NumberRect.Margin = new Thickness(frameWidth, frameWidth, frameWidth / 2, frameWidth);
NumberRect.RadiusX = innerRadius;
NumberRect.RadiusY = innerRadius;
RegionRect.Margin = new Thickness(frameWidth / 2, frameWidth, frameWidth, frameWidth);
RegionRect.RadiusX = innerRadius;
RegionRect.RadiusY = innerRadius;
RegionGrid.Margin = new Thickness(frameWidth, frameWidth * 2, frameWidth * 2, frameWidth * 2);
NumberBox.Margin = new Thickness(0, outerRadius, 0, 0);
NumberBox.FontSize = Bounds.Height;
RegionBox.FontSize = Bounds.Height * 0.72;
RegionBox.Margin = new Thickness(0, Bounds.Height * 0.12, 0, 0);
CountryName.FontSize = Bounds.Height * 0.23;
CountryRow.Spacing = Bounds.Height * 0.06;
FlagGrid.Width = Bounds.Height * 0.35;
FlagGrid.Height = Bounds.Height * 0.2;
} }
} }

View File

@ -0,0 +1,16 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:AutoCat.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AutoCat.Views.ReportTextItem"
x:DataType="views:ReportTextItem"
x:CompileBindings="True">
<Grid ColumnDefinitions="* Auto">
<TextBlock Grid.Column="0" Name="LabelBlock"/>
<TextBlock Grid.Column="1" Name="ValueBlock" Foreground="{DynamicResource SecondaryText}"/>
</Grid>
</UserControl>

View File

@ -0,0 +1,62 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace AutoCat.Views;
public partial class ReportTextItem : UserControl
{
#region Dependency properties
public static readonly StyledProperty<string> LabelProperty =
AvaloniaProperty.Register<ReportTextItem, string>(nameof(Label));
public static readonly StyledProperty<string> ValueProperty =
AvaloniaProperty.Register<ReportTextItem, string>(nameof(Value));
#endregion
#region Properties
public string Label
{
get => GetValue(LabelProperty);
set => SetValue(LabelProperty, value);
}
public string Value
{
get => GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
#endregion
static ReportTextItem()
{
LabelProperty.Changed.AddClassHandler<ReportTextItem>((v, e) => v.ValueChanged(e));
ValueProperty.Changed.AddClassHandler<ReportTextItem>((v, e) => v.ValueChanged(e));
}
public ReportTextItem()
{
InitializeComponent();
}
private void ValueChanged(AvaloniaPropertyChangedEventArgs e)
{
if (e.NewValue is not string newValue)
return;
if (e.Property == LabelProperty)
{
LabelBlock.Text = newValue;
}
if (e.Property == ValueProperty)
{
ValueBlock.Text = newValue;
}
}
}

View File

@ -8,8 +8,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>