diff --git a/AutoCat/App.axaml b/AutoCat/App.axaml
index 227d3f2..7f80729 100644
--- a/AutoCat/App.axaml
+++ b/AutoCat/App.axaml
@@ -10,7 +10,12 @@
- avares://Assets/Fonts/RoadNumbers2.0.otf
+
+
+
+
+ avares://Assets/Fonts/RoadNumbers2.0.otf
+
\ No newline at end of file
diff --git a/AutoCat/Extensions/DateConverter.cs b/AutoCat/Extensions/DateConverter.cs
new file mode 100644
index 0000000..94dac22
--- /dev/null
+++ b/AutoCat/Extensions/DateConverter.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Globalization;
+using Avalonia.Data.Converters;
+
+namespace AutoCat.Extensions;
+
+public class DateConverter: IValueConverter
+{
+ private static readonly DateTime Epoch = new(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
+
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (value is not double timestamp)
+ return null;
+
+ if (timestamp == 0)
+ return null;
+
+ var dateTime = Epoch.AddMilliseconds(timestamp).ToLocalTime();
+ return dateTime.ToString("g");
+ }
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/AutoCat/Extensions/MathExtension.cs b/AutoCat/Extensions/MathExtension.cs
new file mode 100644
index 0000000..3d10f5b
--- /dev/null
+++ b/AutoCat/Extensions/MathExtension.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Globalization;
+using Avalonia.Data;
+using Avalonia.Data.Converters;
+using Avalonia.Markup.Xaml;
+using Avalonia.Markup.Xaml.MarkupExtensions;
+
+namespace AutoCat.Extensions;
+
+public class MathExtension: 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 => e*Mult + Add)
+ };
+
+ return binding.ProvideValue(serviceProvider);
+ }
+}
\ No newline at end of file
diff --git a/AutoCat/Pages/HistoryListPage.axaml b/AutoCat/Pages/HistoryListPage.axaml
index 913852c..098ec52 100644
--- a/AutoCat/Pages/HistoryListPage.axaml
+++ b/AutoCat/Pages/HistoryListPage.axaml
@@ -6,6 +6,7 @@
xmlns:vm="using:AutoCat.ViewModels"
xmlns:mocks="using:AutoCat.Mocks"
xmlns:views="using:AutoCat.Views"
+ xmlns:ext="using:AutoCat.Extensions"
mc:Ignorable="d" d:DesignWidth="350" d:DesignHeight="550"
x:Class="AutoCat.Pages.HistoryListPage"
x:DataType="vm:HistoryListViewModel"
@@ -13,17 +14,35 @@
DataContext="{utils:ViewModelProvider vm:HistoryListViewModel}"
Design.DataContext="mocks:HistoryListViewModelMock">
+
+
+
+
-
+
-
+
-
-
+
+
diff --git a/AutoCat/Pages/HistoryPage.axaml b/AutoCat/Pages/HistoryPage.axaml
index c732f7a..0ff9a7f 100644
--- a/AutoCat/Pages/HistoryPage.axaml
+++ b/AutoCat/Pages/HistoryPage.axaml
@@ -5,7 +5,7 @@
xmlns:pages="clr-namespace:AutoCat.Pages"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AutoCat.Pages.HistoryPage">
-
+
diff --git a/AutoCat/Resources/Colors.axaml b/AutoCat/Resources/Colors.axaml
new file mode 100644
index 0000000..d1190c7
--- /dev/null
+++ b/AutoCat/Resources/Colors.axaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AutoCat/Views/PlateView.axaml b/AutoCat/Views/PlateView.axaml
index 899acb2..38f1d6c 100644
--- a/AutoCat/Views/PlateView.axaml
+++ b/AutoCat/Views/PlateView.axaml
@@ -2,31 +2,52 @@
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"
- mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="150"
+ xmlns:ext="clr-namespace:AutoCat.Extensions"
+ xmlns:views="clr-namespace:AutoCat.Views"
+ mc:Ignorable="d" d:DesignWidth="520" d:DesignHeight="112"
x:Class="AutoCat.Views.PlateView"
+ x:Name="PlateViewControl"
SizeChanged="UserControl_SizeChanged">
-
+
-
+
-
-
-
-
+
+
+
+
diff --git a/AutoCat/Views/PlateView.axaml.cs b/AutoCat/Views/PlateView.axaml.cs
index 75e0731..44b3483 100644
--- a/AutoCat/Views/PlateView.axaml.cs
+++ b/AutoCat/Views/PlateView.axaml.cs
@@ -25,7 +25,7 @@ public partial class PlateView : UserControl
#endregion
- private const double AspectRatio = 112.0 / 520.0;
+ public const double AspectRatio = 112.0 / 520.0;
static PlateView()
{
@@ -47,25 +47,11 @@ public partial class PlateView : UserControl
RegionBox.Text = number.Region();
}
- protected override Size MeasureOverride(Size availableSize)
- {
- var newAspect = availableSize.Height / availableSize.Width;
-
- return newAspect >= AspectRatio
- ? new Size(availableSize.Width, availableSize.Width * AspectRatio)
- : new Size(availableSize.Height / AspectRatio, availableSize.Height);
- }
-
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
{
- NumberBox.Margin = new Thickness(0, -e.NewSize.Height * 0.35, 0, 0);
- RegionBox.FontSize = e.NewSize.Height * 0.65;
- RegionBox.Margin = new Thickness(0, -RegionBox.FontSize * 0.3, 0, 0);
- FlagGrid.Width = FlagGrid.Height * 1.5;
-
- if (CountryRow.Height > 0)
+ if (Bounds.Height > 0)
{
- CountryName.FontSize = CountryRow.Height;
+ Console.WriteLine($"=== new height: {Bounds.Height}");
}
}
}
\ No newline at end of file