mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 01:56:31 +00:00
fix bugs with UI for gps denied
This commit is contained in:
@@ -52,7 +52,6 @@ public partial class Annotator
|
||||
|
||||
private readonly TimeSpan _thresholdBefore = TimeSpan.FromMilliseconds(50);
|
||||
private readonly TimeSpan _thresholdAfter = TimeSpan.FromMilliseconds(150);
|
||||
private readonly IGpsMatcherService _gpsMatcherService;
|
||||
private static readonly Guid SaveConfigTaskId = Guid.NewGuid();
|
||||
|
||||
public ObservableCollection<MediaFileInfo> AllMediaFiles { get; set; } = new();
|
||||
@@ -88,7 +87,6 @@ public partial class Annotator
|
||||
_dbFactory = dbFactory;
|
||||
_inferenceService = inferenceService;
|
||||
_inferenceClient = inferenceClient;
|
||||
_gpsMatcherService = gpsMatcherService;
|
||||
|
||||
Loaded += OnLoaded;
|
||||
Closed += OnFormClosed;
|
||||
@@ -101,7 +99,7 @@ public partial class Annotator
|
||||
{
|
||||
_appConfig.DirectoriesConfig.VideosDirectory = TbFolder.Text;
|
||||
await ReloadFiles();
|
||||
await SaveUserSettings();
|
||||
SaveUserSettings();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -132,7 +130,7 @@ public partial class Annotator
|
||||
_inferenceClient.Send(RemoteCommand.Create(CommandType.AIAvailabilityCheck));
|
||||
|
||||
Editor.GetTimeFunc = () => TimeSpan.FromMilliseconds(_mediaPlayer.Time);
|
||||
MapMatcherComponent.Init(_appConfig, _gpsMatcherService);
|
||||
MapMatcherComponent.Init(_appConfig, gpsMatcherService);
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
@@ -217,9 +215,9 @@ public partial class Annotator
|
||||
Volume.ValueChanged += (_, newValue) =>
|
||||
_mediator.Publish(new VolumeChangedEvent((int)newValue));
|
||||
|
||||
SizeChanged += async (_, _) => await SaveUserSettings();
|
||||
LocationChanged += async (_, _) => await SaveUserSettings();
|
||||
StateChanged += async (_, _) => await SaveUserSettings();
|
||||
SizeChanged += (_, _) => SaveUserSettings();
|
||||
LocationChanged += (_, _) => SaveUserSettings();
|
||||
StateChanged += (_, _) => SaveUserSettings();
|
||||
|
||||
DgAnnotations.MouseDoubleClick += (sender, args) =>
|
||||
{
|
||||
@@ -269,10 +267,10 @@ public partial class Annotator
|
||||
|
||||
ShowAnnotations(res.Annotation, showImage: true);
|
||||
}
|
||||
private Task SaveUserSettings()
|
||||
private void SaveUserSettings()
|
||||
{
|
||||
if (_suspendLayout)
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
|
||||
_appConfig.UIConfig.LeftPanelWidth = MainGrid.ColumnDefinitions.FirstOrDefault()!.Width.Value;
|
||||
_appConfig.UIConfig.RightPanelWidth = MainGrid.ColumnDefinitions.LastOrDefault()!.Width.Value;
|
||||
@@ -282,7 +280,6 @@ public partial class Annotator
|
||||
_configUpdater.Save(_appConfig);
|
||||
return Task.CompletedTask;
|
||||
}, SaveConfigTaskId, TimeSpan.FromSeconds(5));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void ShowTimeAnnotations(TimeSpan time)
|
||||
@@ -508,7 +505,7 @@ public partial class Annotator
|
||||
_helpWindow.Activate();
|
||||
}
|
||||
|
||||
private void Thumb_OnDragCompleted(object sender, DragCompletedEventArgs e) => _ = SaveUserSettings();
|
||||
private void Thumb_OnDragCompleted(object sender, DragCompletedEventArgs e) => SaveUserSettings();
|
||||
|
||||
private void LvFilesContextOpening(object sender, ContextMenuEventArgs e)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Azaion.Annotator.Controls;
|
||||
using Azaion.Annotator.DTO;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.Database;
|
||||
@@ -11,6 +14,8 @@ using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using GMap.NET;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using LibVLCSharp.Shared;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -38,7 +43,9 @@ public class AnnotatorEventHandler(
|
||||
INotificationHandler<AnnotatorControlEvent>,
|
||||
INotificationHandler<VolumeChangedEvent>,
|
||||
INotificationHandler<AnnotationsDeletedEvent>,
|
||||
INotificationHandler<AnnotationAddedEvent>
|
||||
INotificationHandler<AnnotationAddedEvent>,
|
||||
INotificationHandler<SetStatusTextEvent>,
|
||||
INotificationHandler<GPSMatcherResultEvent>
|
||||
{
|
||||
private const int STEP = 20;
|
||||
private const int LARGE_STEP = 5000;
|
||||
@@ -363,4 +370,35 @@ public class AnnotatorEventHandler(
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(SetStatusTextEvent e, CancellationToken cancellationToken)
|
||||
{
|
||||
mainWindow.Dispatcher.Invoke(() =>
|
||||
{
|
||||
mainWindow.StatusHelp.Text = e.Text;
|
||||
if (e.Color.HasValue)
|
||||
mainWindow.StatusHelp.Foreground = new SolidColorBrush(e.Color.Value);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(GPSMatcherResultEvent e, CancellationToken cancellationToken)
|
||||
{
|
||||
mainWindow.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var mapMatcher = mainWindow.MapMatcherComponent;
|
||||
var marker = new GMapMarker(new PointLatLng(e.Latitude, e.Longitude));
|
||||
var ann = mapMatcher.Annotations[e.Index];
|
||||
marker.Shape = new CircleVisual(marker, Brushes.Blue)
|
||||
{
|
||||
Text = e.Image
|
||||
};
|
||||
mapMatcher.SatelliteMap.Markers.Add(marker);
|
||||
ann.Lat = e.Latitude;
|
||||
ann.Lon = e.Longitude;
|
||||
mapMatcher.SatelliteMap.Position = new PointLatLng(e.Latitude, e.Longitude);
|
||||
mapMatcher.SatelliteMap.ZoomAndCenterMarkers(null);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
using Azaion.Common.Services;
|
||||
using GMap.NET;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using MediatR;
|
||||
|
||||
namespace Azaion.Annotator.Controls;
|
||||
|
||||
public class MapMatcherEventHandler(MapMatcher mapMatcher) : INotificationHandler<GPSMatcherResultEvent>
|
||||
{
|
||||
public Task Handle(GPSMatcherResultEvent result, CancellationToken cancellationToken)
|
||||
{
|
||||
mapMatcher.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var marker = new GMapMarker(new PointLatLng(result.Latitude, result.Longitude));
|
||||
var ann = mapMatcher.Annotations[result.Index];
|
||||
marker.Shape = new CircleVisual(marker, System.Windows.Media.Brushes.Blue)
|
||||
{
|
||||
Text = result.Image
|
||||
};
|
||||
mapMatcher.SatelliteMap.Markers.Add(marker);
|
||||
ann.Lat = result.Latitude;
|
||||
ann.Lon = result.Longitude;
|
||||
mapMatcher.SatelliteMap.Position = new PointLatLng(result.Latitude, result.Longitude);
|
||||
mapMatcher.SatelliteMap.ZoomAndCenterMarkers(null);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user