Fixing vehicle cell. Adding some info to report page.
This commit is contained in:
parent
6259d182e4
commit
e5afc6dbdc
@ -3,4 +3,7 @@
|
||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||
<Assembly Path="/Users/selim/.nuget/packages/avalonia/11.0.0/ref/net6.0/Avalonia.Markup.dll" />
|
||||
<Assembly Path="/Users/selim/Documents/dev/AutoCatAvalonia/AutoCat/bin/Debug/net7.0/Avalonia.Base.dll" />
|
||||
</AssemblyExplorer></s:String></wpf:ResourceDictionary>
|
||||
</AssemblyExplorer></s:String>
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=ec0d04c1_002D7b57_002D460c_002Da7f0_002Db7883783f338/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from 2-0" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||
<ProjectFile>9FB32BFB-805B-49F2-B5A2-E1F5A0C06A62/d:Views/f:PlateView.axaml/z:2-0</ProjectFile>
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
||||
@ -14,7 +14,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Resources/Colors.axaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<FontFamily x:Key="RoadNumbersFont">avares://Assets/Fonts/RoadNumbers2.0.otf</FontFamily>
|
||||
<FontFamily x:Key="RoadNumbersFont">avares://AutoCat/Assets/Fonts#RoadNumbers</FontFamily>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
|
||||
@ -18,13 +18,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.6" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.6" />
|
||||
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.2.1" />
|
||||
<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.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.6" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.6" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.4" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="2.0.5" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.1.5.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
|
||||
27
AutoCat/Extensions/ThicknessExtension.cs
Normal file
27
AutoCat/Extensions/ThicknessExtension.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -3,10 +3,37 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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"
|
||||
x:Class="AutoCat.Pages.ReportPage"
|
||||
x:DataType="pages:ReportPage"
|
||||
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>
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
<ext:DateConverter x:Key="DateConverter"/>
|
||||
|
||||
<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="*">
|
||||
<TextBlock Text="{Binding Brand.Name.Original}"/>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="* Auto" RowDefinitions="*,*">
|
||||
<Grid ColumnDefinitions="150 *" RowDefinitions="*,*">
|
||||
<views:PlateView Grid.RowSpan="2" Number="{Binding Number}"/>
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
@ -20,6 +20,7 @@
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource SecondaryText}"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{Binding UpdatedDate, Converter={StaticResource DateConverter}}"/>
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
@ -28,6 +29,7 @@
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource TertiaryText}"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{Binding AddedDate, Converter={StaticResource DateConverter}}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="AutoCat.Views.MasterDetailView"
|
||||
x:DataType="views:MasterDetailView"
|
||||
x:CompileBindings="True">
|
||||
x:CompileBindings="True"
|
||||
Name="MasterDetail">
|
||||
|
||||
<Grid ColumnDefinitions="300, Auto, *">
|
||||
<ListBox ItemsSource="{Binding ItemsSource}"
|
||||
ItemTemplate="{Binding ItemTemplate}"
|
||||
ItemTemplate="{Binding ElementName=MasterDetail, Path=ItemTemplate}"
|
||||
Name="VehiclesList"/>
|
||||
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
|
||||
<!--
|
||||
|
||||
@ -10,45 +10,52 @@
|
||||
SizeChanged="UserControl_SizeChanged">
|
||||
|
||||
<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>
|
||||
<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"
|
||||
Text="A163AA"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
Foreground="#ccc"
|
||||
FontSize="{ext:Math Path=#PlateViewControl.Bounds.Height, Mult=0.6}"/>
|
||||
ClipToBounds="False"
|
||||
FontFamily="{StaticResource RoadNumbersFont}"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle Grid.Column="1" RadiusX="4" RadiusY="4" VerticalAlignment="Stretch" Fill="#333" Margin="0,2,2,2"/>
|
||||
<Grid Grid.Column="1" Margin="0,2,2,2" RowDefinitions="65*,35*">
|
||||
<Rectangle Grid.Column="1"
|
||||
Name="RegionRect"
|
||||
VerticalAlignment="Stretch"
|
||||
Fill="#333"/>
|
||||
<Grid Grid.Column="1" Name="RegionGrid" RowDefinitions="65*,35*">
|
||||
<TextBlock Grid.Row="0"
|
||||
x:Name="RegionBox"
|
||||
Text="161"
|
||||
ClipToBounds="False"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="#ccc"
|
||||
FontSize="{ext:Math Path=#PlateViewControl.Bounds.Height, Mult=0.35}"/>
|
||||
<Grid Grid.Row="1" Margin="3,1" x:Name="CountryRow" ColumnDefinitions="Auto,*">
|
||||
FontFamily="{StaticResource RoadNumbersFont}"/>
|
||||
<StackPanel Grid.Row="1" x:Name="CountryRow"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock Grid.Column="0"
|
||||
x:Name="CountryName"
|
||||
Text="RUS"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="#ccc"
|
||||
FontSize="{ext:Math Path=#PlateViewControl.Bounds.Height, Mult=0.2}"/>
|
||||
<!--
|
||||
<Grid Grid.Column="2" x:Name="FlagGrid" Margin="1" RowDefinitions="*,*,*">
|
||||
Foreground="#ccc"/>
|
||||
<Grid Grid.Column="2" x:Name="FlagGrid" RowDefinitions="*,*,*">
|
||||
<Rectangle Grid.Row="0" Fill="White"/>
|
||||
<Rectangle Grid.Row="1" Fill="Blue"/>
|
||||
<Rectangle Grid.Row="2" Fill="Red"/>
|
||||
</Grid>
|
||||
-->
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@ -3,6 +3,7 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace AutoCat.Views;
|
||||
|
||||
@ -49,9 +50,33 @@ public partial class PlateView : UserControl
|
||||
|
||||
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (Bounds.Height > 0)
|
||||
{
|
||||
//Console.WriteLine($"=== new height: {Bounds.Height}");
|
||||
}
|
||||
if(Bounds.Height <= 0)
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
16
AutoCat/Views/ReportTextItem.axaml
Normal file
16
AutoCat/Views/ReportTextItem.axaml
Normal 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>
|
||||
62
AutoCat/Views/ReportTextItem.axaml.cs
Normal file
62
AutoCat/Views/ReportTextItem.axaml.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,8 +8,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user