mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:56:30 +00:00
better view for class distribution
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
@@ -14,7 +11,6 @@ using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using GMap.NET;
|
||||
using GMap.NET.MapProviders;
|
||||
using GMap.NET.WindowsPresentation;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
|
||||
namespace Azaion.Annotator.Controls;
|
||||
@@ -23,7 +19,7 @@ public partial class MapMatcher : UserControl
|
||||
{
|
||||
private AppConfig _appConfig = null!;
|
||||
List<MediaFileInfo> _allMediaFiles = new();
|
||||
private Dictionary<int, Annotation> _annotations = new();
|
||||
public Dictionary<int, Annotation> Annotations = new();
|
||||
private string _currentDir = null!;
|
||||
private IGpsMatcherService _gpsMatcherService = null!;
|
||||
|
||||
@@ -47,7 +43,7 @@ public partial class MapMatcher : UserControl
|
||||
private async Task OpenGpsLocation(int gpsFilesIndex)
|
||||
{
|
||||
//var media = GpsFiles.Items[gpsFilesIndex] as MediaFileInfo;
|
||||
var ann = _annotations.GetValueOrDefault(gpsFilesIndex);
|
||||
var ann = Annotations.GetValueOrDefault(gpsFilesIndex);
|
||||
if (ann == null)
|
||||
return;
|
||||
|
||||
@@ -101,7 +97,7 @@ public partial class MapMatcher : UserControl
|
||||
_allMediaFiles = mediaFiles;
|
||||
GpsFiles.ItemsSource = new ObservableCollection<MediaFileInfo>(_allMediaFiles);
|
||||
|
||||
_annotations = mediaFiles.Select((x, i) => (i, new Annotation
|
||||
Annotations = mediaFiles.Select((x, i) => (i, new Annotation
|
||||
{
|
||||
Name = x.Name,
|
||||
OriginalMediaName = x.Name
|
||||
@@ -110,42 +106,7 @@ public partial class MapMatcher : UserControl
|
||||
var initialLat = double.Parse(TbLat.Text);
|
||||
var initialLon = double.Parse(TbLon.Text);
|
||||
|
||||
await _gpsMatcherService.RunGpsMatching(dir.FullName, initialLat, initialLon, async res => await SetMarker(res));
|
||||
}
|
||||
|
||||
private Task SetMarker(GpsMatchResult result)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
var marker = new GMapMarker(new PointLatLng(result.Latitude, result.Longitude));
|
||||
var ann = _annotations[result.Index];
|
||||
marker.Shape = new CircleVisual(marker, System.Windows.Media.Brushes.Blue)
|
||||
{
|
||||
Text = ann.Name
|
||||
};
|
||||
SatelliteMap.Markers.Add(marker);
|
||||
ann.Lat = result.Latitude;
|
||||
ann.Lon = result.Longitude;
|
||||
SatelliteMap.Position = new PointLatLng(result.Latitude, result.Longitude);
|
||||
SatelliteMap.ZoomAndCenterMarkers(null);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task SetFromCsv(List<MediaFileInfo> mediaFiles)
|
||||
{
|
||||
|
||||
var csvResults = GpsMatchResult.ReadFromCsv(Constants.CSV_PATH);
|
||||
var csvDict = csvResults
|
||||
.Where(x => x.MatchType == "stitched")
|
||||
.ToDictionary(x => x.Index);
|
||||
foreach (var ann in _annotations)
|
||||
{
|
||||
var csvRes = csvDict.GetValueOrDefault(ann.Key);
|
||||
if (csvRes == null)
|
||||
continue;
|
||||
await SetMarker(csvRes);
|
||||
}
|
||||
await _gpsMatcherService.RunGpsMatching(dir.FullName, initialLat, initialLon);
|
||||
}
|
||||
|
||||
private async void TestGps(object sender, RoutedEventArgs e)
|
||||
@@ -155,6 +116,6 @@ public partial class MapMatcher : UserControl
|
||||
|
||||
var initialLat = double.Parse(TbLat.Text);
|
||||
var initialLon = double.Parse(TbLon.Text);
|
||||
await _gpsMatcherService.RunGpsMatching(TbGpsMapFolder.Text, initialLat, initialLon, async res => await SetMarker(res));
|
||||
await _gpsMatcherService.RunGpsMatching(TbGpsMapFolder.Text, initialLat, initialLon);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user