diff --git a/src/LacmusApp.csproj b/src/LacmusApp.csproj index 974ac78..47aea04 100644 --- a/src/LacmusApp.csproj +++ b/src/LacmusApp.csproj @@ -3,8 +3,8 @@ Exe netcoreapp3.1 Lacmus Foundation - 0.3.3.3 - 0.3.3.3 + 0.3.3.4 + 0.3.3.4 diff --git a/src/Services/VM/PhotoVMReader.cs b/src/Services/VM/PhotoVMReader.cs index 82805bb..28950e5 100644 --- a/src/Services/VM/PhotoVMReader.cs +++ b/src/Services/VM/PhotoVMReader.cs @@ -157,6 +157,12 @@ public async Task ReadAllFromDirByAnnotation(PhotoLoadType loa var photo = await photoLoader.Load(photoPath, loadType); var photoViewModel = new PhotoViewModel(id, photo, annotation); photoViewModel.BoundBoxes = photoViewModel.GetBoundingBoxes(); + + if (photoViewModel.BoundBoxes.Any()) + { + photoViewModel.Photo.Attribute = Attribute.WithObject; + photoViewModel.IsHasObject = true; + } photoList.Add(photoViewModel); id++; count++; diff --git a/src/ViewModels/AboutViewModel.cs b/src/ViewModels/AboutViewModel.cs index 2d8b9c2..fc487f9 100644 --- a/src/ViewModels/AboutViewModel.cs +++ b/src/ViewModels/AboutViewModel.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices; using Avalonia.Controls; using ReactiveUI; +using ReactiveUI.Fody.Helpers; using Serilog; namespace LacmusApp.ViewModels @@ -16,6 +17,8 @@ public AboutViewModel(Window window) OpenGithubCommand = ReactiveCommand.Create(OpenGithub); OpenSiteCommand = ReactiveCommand.Create(OpenSite); } + + [Reactive] public string TextVersion { get; set; } = GetVersion() + "."; public ReactiveCommand OpenLicenseCommand { get; set; } public ReactiveCommand OpenGithubCommand { get; set; } public ReactiveCommand OpenSiteCommand { get; set; } @@ -57,5 +60,13 @@ private void OpenUrl(string url) Log.Error(e,$"Unable to ope url {url}."); } } + + private static string GetVersion() + { + var revision = ""; + if (typeof(Program).Assembly.GetName().Version.Revision != 0) + revision = $"preview-{typeof(Program).Assembly.GetName().Version.Revision}"; + return $"{typeof(Program).Assembly.GetName().Version.Major}.{typeof(Program).Assembly.GetName().Version.Minor}.{typeof(Program).Assembly.GetName().Version.Build}.{revision}"; + } } } \ No newline at end of file diff --git a/src/ViewModels/MainWindowViewModel.cs b/src/ViewModels/MainWindowViewModel.cs index 1fd19ec..bec12f7 100644 --- a/src/ViewModels/MainWindowViewModel.cs +++ b/src/ViewModels/MainWindowViewModel.cs @@ -135,8 +135,7 @@ private void SetupCommand(IObservable canExecute, IObservable canSwi LastPageCommand = ReactiveCommand.Create(ShowLastPage); ImportAllCommand = ReactiveCommand.Create(ImportFromXml, canExecute); - SaveAllImagesWithObjectsCommand = ReactiveCommand.Create(SaveAllImagesWithObjects, canExecute); - SaveFavoritesImagesCommand = ReactiveCommand.Create(SaveFavoritesImages, canExecute); + SaveAsCommand = ReactiveCommand.Create(SaveAs, canExecute); ShowGeoDataCommand = ReactiveCommand.Create(ShowGeoData, canExecute); AddToFavoritesCommand = ReactiveCommand.Create(AddToFavorites, canExecute); HelpCommand = ReactiveCommand.Create(Help); @@ -181,13 +180,11 @@ [Reactive] public int TotalPages public ReactiveCommand ImportAllCommand { get; set; } public ReactiveCommand LoadModelCommand { get; set; } public ReactiveCommand UpdateModelCommand { get; set; } - public ReactiveCommand SaveAllImagesWithObjectsCommand { get; set; } - public ReactiveCommand SaveFavoritesImagesCommand { get; set; } + public ReactiveCommand SaveAsCommand { get; set; } public ReactiveCommand FirstPageCommand { get; set; } public ReactiveCommand PreviousPageCommand { get; set; } public ReactiveCommand NextPageCommand { get; set; } public ReactiveCommand LastPageCommand { get; set; } - public ReactiveCommand ShowAllMetadataCommand { get; set; } public ReactiveCommand ShowGeoDataCommand { get; set; } public ReactiveCommand AddToFavoritesCommand { get; set; } public ReactiveCommand HelpCommand { get; set; } @@ -508,48 +505,10 @@ private async void SaveAll() _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, ""); } - private async void SaveAllImagesWithObjects() + private async void SaveAs() { - try - { - if (!_photos.Items.Any()) - { - Log.Warning("There are no photos to save."); - return; - } - _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, ""); - var writer = new PhotoVMWriter(_window); - await writer.WriteMany(_photos.Items.Where(x => x.Photo.Attribute == Attribute.WithObject)); - _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, "Success | saved"); - Log.Information($"Saved {_photos.Items.Count()} photos."); - } - catch (Exception ex) - { - Log.Error(ex, "Unable to save photos."); - } - _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, ""); - } - - private async void SaveFavoritesImages() - { - try - { - if (!_photos.Items.Any()) - { - Log.Warning("There are no photos to save."); - return; - } - _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, ""); - var writer = new PhotoVMWriter(_window); - await writer.WriteMany(_photos.Items.Where(x => x.Photo.Attribute == Attribute.Favorite)); - _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, "Success | saved"); - Log.Information($"Saved {_photos.Items.Count()} photos."); - } - catch (Exception ex) - { - Log.Error(ex, "Unable to save photos."); - } - _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, ""); + SaveAsWindow window = new SaveAsWindow(); + window.Show(); } public void OpenWizard() diff --git a/src/ViewModels/MetadataViewModel.cs b/src/ViewModels/MetadataViewModel.cs index 5d0ac02..18e9d49 100644 --- a/src/ViewModels/MetadataViewModel.cs +++ b/src/ViewModels/MetadataViewModel.cs @@ -58,17 +58,28 @@ public MetadataViewModel(Window window, IReadOnlyList metadata) OpenYandexCommand = ReactiveCommand.Create(OpenYandex, this.IsValid()); OpenGoogleCommand = ReactiveCommand.Create(OpenGoogle, this.IsValid()); + OpenOSMCommand = ReactiveCommand.Create(OpenOSM, this.IsValid()); } public ReactiveCommand OpenYandexCommand { get; set; } public ReactiveCommand OpenGoogleCommand { get; set; } + public ReactiveCommand OpenOSMCommand { get; set; } public void OpenYandex() { - OpenUrl($"https://yandex.ru/maps/?ll={Longitude.Replace(',', '.')}%2C{Latitude.Replace(',', '.')}&z=15"); + OpenUrl($"https://yandex.ru/maps/?ll={Longitude.Replace(',', '.')}%2C{Latitude.Replace(',', '.')}&z=15"+ + $"&mode=whatshere&whatshere%5Bpoint%5D={Longitude.Replace(',', '.')}%2C{Latitude.Replace(',', '.')}&whatshere%5Bzoom%5D=15"); } public void OpenGoogle() { - OpenUrl($"https://www.google.ru/maps/@{Latitude.Replace(',', '.')},{Longitude.Replace(',', '.')},15z"); + //https://www.google.com/maps/place/"&[Latitude]&"+"&[Longitude]&"/@"&[Latitude]&","&[Longitude]&",15z + OpenUrl($"https://www.google.ru/maps/place/{Latitude.Replace(',', '.')}+{Longitude.Replace(',', '.')}"+ + $"/@{Latitude.Replace(',', '.')},{Longitude.Replace(',', '.')},15z"); + } + + public void OpenOSM() + { + OpenUrl($"https://www.openstreetmap.org/?mlat={Latitude.Replace(',', '.')}&mlon={Longitude.Replace(',', '.')}"+ + $"#map=15/{Latitude.Replace(',', '.')}/{Longitude.Replace(',', '.')}"); } private string TranslateGeoTag(string tag) diff --git a/src/ViewModels/SaveAsWindowViewModel.cs b/src/ViewModels/SaveAsWindowViewModel.cs new file mode 100644 index 0000000..3488328 --- /dev/null +++ b/src/ViewModels/SaveAsWindowViewModel.cs @@ -0,0 +1,33 @@ +using System.IO; +using System.Reactive; +using Avalonia.Controls; +using DynamicData; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; +using ReactiveUI.Validation.Extensions; +using ReactiveUI.Validation.Helpers; + +namespace LacmusApp.ViewModels +{ + public class SaveAsWindowViewModel : ReactiveValidationObject + { + private readonly SourceList _photos; + public SaveAsWindowViewModel(Window window, SourceList photos) + { + _photos = photos; + this.ValidationRule( + viewModel => viewModel.OutputPath, + Directory.Exists, + path => $"Incorrect path {path}"); + + SaveCommand = ReactiveCommand.Create(OpenLicense); + } + [Reactive] public string OutputPath { get; set; } + public ReactiveCommand SaveCommand { get; set; } + + public void OpenLicense() + { + + } + } +} \ No newline at end of file diff --git a/src/ViewModels/SecondWizardViewModel.cs b/src/ViewModels/SecondWizardViewModel.cs index e72b261..b5e3f61 100644 --- a/src/ViewModels/SecondWizardViewModel.cs +++ b/src/ViewModels/SecondWizardViewModel.cs @@ -35,7 +35,7 @@ private async void Save() var dig = new OpenFolderDialog() { //TODO: Multi language support - Title = "CSelect folder to save" + Title = "Select folder to save" }; var dirPath = await dig.ShowAsync(new Window()); OutputPath = dirPath; diff --git a/src/Views/AboutWindow.xaml b/src/Views/AboutWindow.xaml index afdd477..f1a0d96 100644 --- a/src/Views/AboutWindow.xaml +++ b/src/Views/AboutWindow.xaml @@ -23,7 +23,7 @@ - + diff --git a/src/Views/MainWindow.xaml b/src/Views/MainWindow.xaml index c0a1591..fae55a5 100644 --- a/src/Views/MainWindow.xaml +++ b/src/Views/MainWindow.xaml @@ -28,10 +28,9 @@ - - - - + + + diff --git a/src/Views/MetadataWindow.xaml b/src/Views/MetadataWindow.xaml index f90a262..96a17c9 100644 --- a/src/Views/MetadataWindow.xaml +++ b/src/Views/MetadataWindow.xaml @@ -49,6 +49,8 @@ + +