From 39448cdfa0bb1639da83a308513dbacb6aebed8a Mon Sep 17 00:00:00 2001 From: gosha20777 Date: Fri, 3 Apr 2020 01:49:21 +0300 Subject: [PATCH 1/3] feat: draw window --- src/ViewModels/MainWindowViewModel.cs | 51 +++---------------------- src/ViewModels/SaveAsWindowViewModel.cs | 7 ++++ src/Views/MainWindow.xaml | 7 ++-- src/Views/SaveAsWindow.xaml | 34 +++++++++++++++++ src/Views/SaveAsWindow.xaml.cs | 16 ++++++++ 5 files changed, 65 insertions(+), 50 deletions(-) create mode 100644 src/ViewModels/SaveAsWindowViewModel.cs create mode 100644 src/Views/SaveAsWindow.xaml create mode 100644 src/Views/SaveAsWindow.xaml.cs 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/SaveAsWindowViewModel.cs b/src/ViewModels/SaveAsWindowViewModel.cs new file mode 100644 index 0000000..2ba31cf --- /dev/null +++ b/src/ViewModels/SaveAsWindowViewModel.cs @@ -0,0 +1,7 @@ +namespace LacmusApp.ViewModels +{ + public class SaveAsWindowViewModel + { + + } +} \ No newline at end of file diff --git a/src/Views/MainWindow.xaml b/src/Views/MainWindow.xaml index c0a1591..7609513 100644 --- a/src/Views/MainWindow.xaml +++ b/src/Views/MainWindow.xaml @@ -28,10 +28,9 @@ - - - - + + + diff --git a/src/Views/SaveAsWindow.xaml b/src/Views/SaveAsWindow.xaml new file mode 100644 index 0000000..5b0318f --- /dev/null +++ b/src/Views/SaveAsWindow.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + +