diff --git a/Azaion.Annotator/Azaion.Annotator.csproj b/Azaion.Annotator/Azaion.Annotator.csproj index 4ccc008..38968a5 100644 --- a/Azaion.Annotator/Azaion.Annotator.csproj +++ b/Azaion.Annotator/Azaion.Annotator.csproj @@ -26,6 +26,8 @@ + + diff --git a/Azaion.Annotator/Controls/CircleVisual.cs b/Azaion.Annotator/Controls/CircleVisual.cs index 9362bec..b7ff86e 100644 --- a/Azaion.Annotator/Controls/CircleVisual.cs +++ b/Azaion.Annotator/Controls/CircleVisual.cs @@ -13,6 +13,7 @@ namespace Azaion.Annotator.Controls public CircleVisual(GMapMarker m, Brush background) { + ShadowEffect = new DropShadowEffect(); Marker = m; Marker.ZIndex = 100; @@ -161,14 +162,11 @@ namespace Azaion.Annotator.Controls public double? Angle { - get - { - return _angle; - } + get => _angle; set { - if (!Angle.HasValue || !value.HasValue || - Angle.HasValue && value.HasValue && Math.Abs(_angle.Value - value.Value) > 11) + if (!_angle.HasValue || !value.HasValue || + Angle.HasValue && Math.Abs(_angle.Value - value.Value) > 11) { _angle = value; IsChanged = true; @@ -211,31 +209,28 @@ namespace Azaion.Annotator.Controls public virtual Visual Child { - get - { - return _child; - } + get => _child; set { - if (_child != value) + if (_child == value) + return; + + if (_child != null) { - if (_child != null) - { - RemoveLogicalChild(_child); - RemoveVisualChild(_child); - } - - if (value != null) - { - AddVisualChild(value); - AddLogicalChild(value); - } - - // cache the new child - _child = value; - - InvalidateVisual(); + RemoveLogicalChild(_child); + RemoveVisualChild(_child); } + + if (value != null) + { + AddVisualChild(value); + AddLogicalChild(value); + } + + // cache the new child + _child = value; + + InvalidateVisual(); } } @@ -259,36 +254,34 @@ namespace Azaion.Annotator.Controls var square = new DrawingVisualFx(); - using (var dc = square.RenderOpen()) + using var dc = square.RenderOpen(); + dc.DrawEllipse(null, + Stroke, + new Point(Width / 2, Height / 2), + Width / 2 + Stroke.Thickness / 2, + Height / 2 + Stroke.Thickness / 2); + + if (Angle.HasValue) { - dc.DrawEllipse(null, - Stroke, - new Point(Width / 2, Height / 2), - Width / 2 + Stroke.Thickness / 2, - Height / 2 + Stroke.Thickness / 2); - - if (Angle.HasValue) + dc.PushTransform(new RotateTransform(Angle.Value, Width / 2, Height / 2)); { - dc.PushTransform(new RotateTransform(Angle.Value, Width / 2, Height / 2)); - { - var polySeg = new PolyLineSegment(new[] - { - new Point(Width * 0.2, Height * 0.3), new Point(Width * 0.8, Height * 0.3) - }, - true); - var pathFig = new PathFigure(new Point(Width * 0.5, -Height * 0.22), - new PathSegment[] {polySeg}, - true); - var pathGeo = new PathGeometry(new[] {pathFig}); - dc.DrawGeometry(Brushes.AliceBlue, StrokeArrow, pathGeo); - } - dc.Pop(); + var polySeg = new PolyLineSegment(new[] + { + new Point(Width * 0.2, Height * 0.3), new Point(Width * 0.8, Height * 0.3) + }, + true); + var pathFig = new PathFigure(new Point(Width * 0.5, -Height * 0.22), + new PathSegment[] {polySeg}, + true); + var pathGeo = new PathGeometry(new[] {pathFig}); + dc.DrawGeometry(Brushes.AliceBlue, StrokeArrow, pathGeo); } - - dc.DrawEllipse(Background, null, new Point(Width / 2, Height / 2), Width / 2, Height / 2); - dc.DrawText(_fText, new Point(Width / 2 - _fText.Width / 2, Height / 2 - _fText.Height / 2)); + dc.Pop(); } + dc.DrawEllipse(Background, null, new Point(Width / 2, Height / 2), Width / 2, Height / 2); + dc.DrawText(_fText, new Point(Width / 2 - _fText.Width / 2, Height / 2 - _fText.Height / 2)); + return square; } diff --git a/Azaion.Annotator/Controls/MapMatcher.xaml.cs b/Azaion.Annotator/Controls/MapMatcher.xaml.cs index a2677f1..20c6600 100644 --- a/Azaion.Annotator/Controls/MapMatcher.xaml.cs +++ b/Azaion.Annotator/Controls/MapMatcher.xaml.cs @@ -21,11 +21,11 @@ namespace Azaion.Annotator.Controls; public partial class MapMatcher : UserControl { - private AppConfig _appConfig; - List _allMediaFiles; - private Dictionary _annotations; - private string _currentDir; - private IGpsMatcherService _gpsMatcherService; + private AppConfig _appConfig = null!; + List _allMediaFiles = new(); + private Dictionary _annotations = new(); + private string _currentDir = null!; + private IGpsMatcherService _gpsMatcherService = null!; public MapMatcher() { diff --git a/Azaion.Common/Azaion.Common.csproj b/Azaion.Common/Azaion.Common.csproj index 373e4b8..96f371b 100644 --- a/Azaion.Common/Azaion.Common.csproj +++ b/Azaion.Common/Azaion.Common.csproj @@ -19,6 +19,8 @@ + + diff --git a/Azaion.Common/DTO/Config/MapConfig.cs b/Azaion.Common/DTO/Config/MapConfig.cs index 923316e..1ada0a5 100644 --- a/Azaion.Common/DTO/Config/MapConfig.cs +++ b/Azaion.Common/DTO/Config/MapConfig.cs @@ -2,6 +2,6 @@ public class MapConfig { - public string Service { get; set; } - public string ApiKey { get; set; } + public string Service { get; set; } = null!; + public string ApiKey { get; set; } = null!; } \ No newline at end of file diff --git a/Azaion.Common/DTO/GpsMatchResult.cs b/Azaion.Common/DTO/GpsMatchResult.cs index c5601fb..53f75fc 100644 --- a/Azaion.Common/DTO/GpsMatchResult.cs +++ b/Azaion.Common/DTO/GpsMatchResult.cs @@ -5,12 +5,12 @@ using System.IO; public class GpsMatchResult { public int Index { get; set; } - public string Image { get; set; } + public string Image { get; set; } = null!; public double Latitude { get; set; } public double Longitude { get; set; } - public int Keypoints { get; set; } - public int Rotation { get; set; } - public string MatchType { get; set; } + public int KeyPoints { get; set; } + public int Rotation { get; set; } + public string MatchType { get; set; } = null!; public static List ReadFromCsv(string csvFilePath) { @@ -35,7 +35,7 @@ public class GpsMatchResult Image = GetFilename(values[0]), Latitude = double.Parse(values[1]), Longitude = double.Parse(values[2]), - Keypoints = int.Parse(values[3]), + KeyPoints = int.Parse(values[3]), Rotation = int.Parse(values[4]), MatchType = values[5] }); diff --git a/Azaion.Suite/App.xaml.cs b/Azaion.Suite/App.xaml.cs index d77f4a3..b86517e 100644 --- a/Azaion.Suite/App.xaml.cs +++ b/Azaion.Suite/App.xaml.cs @@ -33,7 +33,7 @@ public partial class App private IMediator _mediator = null!; private FormState _formState = null!; - private InferenceExternalClient _inferenceClient = null!; + private IInferenceClient _inferenceClient = null!; private IResourceLoader _resourceLoader = null!; private IAuthProvider _authProvider = null!; @@ -81,7 +81,7 @@ public partial class App { new ConfigUpdater().CheckConfig(); var secureAppConfig = ReadSecureAppConfig(); - _inferenceClient = new InferenceExternalClient(new OptionsWrapper(secureAppConfig.InferenceClientConfig)); + _inferenceClient = new InferenceClient(new OptionsWrapper(secureAppConfig.InferenceClientConfig)); _resourceLoader = new ResourceLoader(_inferenceClient); _authProvider = new AuthProvider(_inferenceClient); @@ -168,8 +168,8 @@ public partial class App services.ConfigureSection(context.Configuration); services.ConfigureSection(context.Configuration); - services.AddKeyedSingleton(SecurityConstants.EXTERNAL_INFERENCE_PATH, _inferenceClient); - services.AddKeyedSingleton(SecurityConstants.EXTERNAL_GPS_DENIED_PATH); + services.AddSingleton(_inferenceClient); + services.AddSingleton(); services.AddSingleton(_resourceLoader); services.AddSingleton(_authProvider); services.AddSingleton(); diff --git a/Azaion.Suite/Azaion.Suite.csproj b/Azaion.Suite/Azaion.Suite.csproj index e4fea8c..d3e1689 100644 --- a/Azaion.Suite/Azaion.Suite.csproj +++ b/Azaion.Suite/Azaion.Suite.csproj @@ -27,6 +27,7 @@ + diff --git a/Azaion.Suite/MainSuite.xaml.cs b/Azaion.Suite/MainSuite.xaml.cs index 345b591..c3854c1 100644 --- a/Azaion.Suite/MainSuite.xaml.cs +++ b/Azaion.Suite/MainSuite.xaml.cs @@ -26,7 +26,8 @@ public partial class MainSuite private readonly IDbFactory _dbFactory; private readonly Dictionary _openedWindows = new(); private readonly IResourceLoader _resourceLoader; - private readonly IEnumerable _externalClients; + private readonly IInferenceClient _inferenceClient; + private readonly IGpsMatcherClient _gpsMatcherClient; private static readonly Guid SaveConfigTaskId = Guid.NewGuid(); public MainSuite(IOptions appConfig, @@ -36,8 +37,8 @@ public partial class MainSuite IGalleryService galleryService, IDbFactory dbFactory, IResourceLoader resourceLoader, - [FromKeyedServices(SecurityConstants.EXTERNAL_INFERENCE_PATH)] IExternalClient inferenceClient, - [FromKeyedServices(SecurityConstants.EXTERNAL_GPS_DENIED_PATH)] IExternalClient gpsClient) + IInferenceClient inferenceClient, + IGpsMatcherClient gpsMatcherClient) { _configUpdater = configUpdater; _modules = modules; @@ -45,7 +46,9 @@ public partial class MainSuite _galleryService = galleryService; _dbFactory = dbFactory; _resourceLoader = resourceLoader; - _externalClients = [inferenceClient, gpsClient]; + _inferenceClient = inferenceClient; + _gpsMatcherClient = gpsMatcherClient; + _appConfig = appConfig.Value; InitializeComponent(); Loaded += OnLoaded; @@ -120,8 +123,9 @@ public partial class MainSuite if (_openedWindows.Any()) return; - foreach (var client in _externalClients) - client.Stop(); + _inferenceClient.Stop(); + _gpsMatcherClient.Stop(); + Close(); }; window.Show();