diff --git a/AutoCat.sln.DotSettings.user b/AutoCat.sln.DotSettings.user index e702cc0..15b0e4e 100644 --- a/AutoCat.sln.DotSettings.user +++ b/AutoCat.sln.DotSettings.user @@ -3,4 +3,7 @@ <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> \ No newline at end of file +</AssemblyExplorer> + <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> \ No newline at end of file diff --git a/AutoCat/App.axaml b/AutoCat/App.axaml index 7f80729..76b15f6 100644 --- a/AutoCat/App.axaml +++ b/AutoCat/App.axaml @@ -14,7 +14,7 @@ - avares://Assets/Fonts/RoadNumbers2.0.otf + avares://AutoCat/Assets/Fonts#RoadNumbers diff --git a/AutoCat/AutoCat.csproj b/AutoCat/AutoCat.csproj index 4ca424c..4654fdc 100644 --- a/AutoCat/AutoCat.csproj +++ b/AutoCat/AutoCat.csproj @@ -18,13 +18,14 @@ - - + + + - - - - + + + + diff --git a/AutoCat/Extensions/ThicknessExtension.cs b/AutoCat/Extensions/ThicknessExtension.cs new file mode 100644 index 0000000..8ae888c --- /dev/null +++ b/AutoCat/Extensions/ThicknessExtension.cs @@ -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(e => new Thickness( e*Mult + Add)) + }; + + return binding.ProvideValue(serviceProvider); + } +} \ No newline at end of file diff --git a/AutoCat/Pages/ReportPage.axaml b/AutoCat/Pages/ReportPage.axaml index 2dee510..b67bbf0 100644 --- a/AutoCat/Pages/ReportPage.axaml +++ b/AutoCat/Pages/ReportPage.axaml @@ -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"> - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AutoCat/Templates/VehicleCell.axaml b/AutoCat/Templates/VehicleCell.axaml index 00477b0..46feebc 100644 --- a/AutoCat/Templates/VehicleCell.axaml +++ b/AutoCat/Templates/VehicleCell.axaml @@ -7,11 +7,11 @@ - + - + diff --git a/AutoCat/Views/MasterDetailView.axaml b/AutoCat/Views/MasterDetailView.axaml index e1d117f..fcd2685 100644 --- a/AutoCat/Views/MasterDetailView.axaml +++ b/AutoCat/Views/MasterDetailView.axaml @@ -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"> - + diff --git a/AutoCat/Views/PlateView.axaml.cs b/AutoCat/Views/PlateView.axaml.cs index dd9690f..084552d 100644 --- a/AutoCat/Views/PlateView.axaml.cs +++ b/AutoCat/Views/PlateView.axaml.cs @@ -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; } } \ No newline at end of file diff --git a/AutoCat/Views/ReportTextItem.axaml b/AutoCat/Views/ReportTextItem.axaml new file mode 100644 index 0000000..cf93e78 --- /dev/null +++ b/AutoCat/Views/ReportTextItem.axaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/AutoCat/Views/ReportTextItem.axaml.cs b/AutoCat/Views/ReportTextItem.axaml.cs new file mode 100644 index 0000000..754275c --- /dev/null +++ b/AutoCat/Views/ReportTextItem.axaml.cs @@ -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 LabelProperty = + AvaloniaProperty.Register(nameof(Label)); + + public static readonly StyledProperty ValueProperty = + AvaloniaProperty.Register(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((v, e) => v.ValueChanged(e)); + ValueProperty.Changed.AddClassHandler((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; + } + } + +} \ No newline at end of file diff --git a/AutoCatCore/AutoCatCore.csproj b/AutoCatCore/AutoCatCore.csproj index 4af0c0f..b8bf6d7 100644 --- a/AutoCatCore/AutoCatCore.csproj +++ b/AutoCatCore/AutoCatCore.csproj @@ -8,8 +8,8 @@ - - + +