From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Models/StorageNavigationIntent.cs | 4 +- .../PPC/Modules/Tango.PPC.Storage/StorageModule.cs | 2 +- .../Tango.PPC.Storage/ViewModels/MainViewVM.cs | 60 ++++--------------- .../Modules/Tango.PPC.Storage/Views/MainView.xaml | 70 ++-------------------- 4 files changed, 21 insertions(+), 115 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationIntent.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationIntent.cs index 3ec14cc6f..2c2a7f10d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationIntent.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationIntent.cs @@ -9,8 +9,6 @@ namespace Tango.PPC.Storage.Models public enum StorageNavigationIntent { LoadFile, - LoadFiles, - SaveFile, - SaveFiles + SaveFile } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/StorageModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/StorageModule.cs index 8bbeb4fe2..b3553e666 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/StorageModule.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/StorageModule.cs @@ -15,7 +15,7 @@ namespace Tango.PPC.Storage /// Represents a PPC . /// /// - [PPCModule(5)] + [PPCModule(3)] public class StorageModule : PPCModuleBase { /// diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs index 9b22fcdb5..4a756e7ea 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,6 +21,7 @@ namespace Tango.PPC.Storage.ViewModels { private bool _allow_exit; private ExplorerFileItem _selectedItem; + private static char[] _invalidChars = System.IO.Path.GetInvalidFileNameChars(); private String _currentPath; public String CurrentPath @@ -63,28 +63,15 @@ namespace Tango.PPC.Storage.ViewModels } } - private bool _displayItems; - public bool DisplayItems - { - get { return _displayItems; } - set { _displayItems = value; RaisePropertyChangedAuto(); } - } - public RelayCommand FileSelectedCommand { get; set; } - public ObservableCollection SelectedItems { get; set; } - public RelayCommand SaveCommand { get; set; } - public RelayCommand OpenCommand { get; set; } - public MainViewVM() { - SelectedItems = new ObservableCollection(); FileSelectedCommand = new RelayCommand(OnFileSelected); - SaveCommand = new RelayCommand(OnSaveCommand, (x) => !String.IsNullOrWhiteSpace(FileName) || Request.Intent == StorageNavigationIntent.SaveFiles); - Request = new StorageNavigationRequest() { Intent = StorageNavigationIntent.LoadFiles }; - OpenCommand = new RelayCommand(OnOpenCommand, () => Request.Intent == StorageNavigationIntent.LoadFiles); + SaveCommand = new RelayCommand(OnSaveCommand, (x) => !String.IsNullOrWhiteSpace(FileName)); + Request = new StorageNavigationRequest(); } public override void OnApplicationStarted() @@ -117,8 +104,6 @@ namespace Tango.PPC.Storage.ViewModels { View.EditFileName(); } - - DisplayItems = true; } else { @@ -131,9 +116,7 @@ namespace Tango.PPC.Storage.ViewModels public override void OnNavigatedFrom() { base.OnNavigatedFrom(); - DisplayItems = false; - Request = null; - Request = new StorageNavigationRequest() { Intent = StorageNavigationIntent.LoadFiles }; + Request = new StorageNavigationRequest(); } /// @@ -175,6 +158,7 @@ namespace Tango.PPC.Storage.ViewModels { if (_allow_exit || CurrentPath == StorageProvider.Drive.RootDirectory.FullName) { + Request = null; return Task.FromResult(true); } else @@ -185,18 +169,10 @@ namespace Tango.PPC.Storage.ViewModels } private async void OnFileSelected(ExplorerFileItem fileItem) - { - _selectedItem = fileItem; - _allow_exit = true; - await NavigationManager.NavigateBack(); - StorageProvider.SubmitFileSelection(new List() { fileItem }); - } - - private async void OnOpenCommand() { _allow_exit = true; await NavigationManager.NavigateBack(); - StorageProvider.SubmitFileSelection(SelectedItems.ToList()); + StorageProvider.SubmitFileSelection(fileItem); } public ExplorerFileItem GetNavigationResult() @@ -211,23 +187,10 @@ namespace Tango.PPC.Storage.ViewModels private void OnSaveCommand() { - _allow_exit = true; - - if (Request.Intent == StorageNavigationIntent.SaveFile) - { - _selectedItem = new ExplorerFileItem() - { - Path = CurrentPath + "\\" + FileName, - }; - } - else if (Request.Intent == StorageNavigationIntent.SaveFiles) + _selectedItem = new ExplorerFileItem() { - _selectedItem = new ExplorerFileItem() - { - Path = CurrentPath, - }; - } - + Path = CurrentPath + "\\" + FileName, + }; NavigationManager.NavigateBack(); } @@ -237,7 +200,10 @@ namespace Tango.PPC.Storage.ViewModels if (text != null) { - text = text.ToValidFileName(); + foreach (var c in _invalidChars) + { + text = text.Replace(c.ToString(), ""); + } _fileName = text; RaisePropertyChanged(nameof(FileName)); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml index c57735a7b..74307c9ce 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml @@ -16,7 +16,7 @@ - + @@ -32,89 +32,31 @@ - - - - - - - - - - OPEN - - - - - - files selected - - - - - - - - - - - + + - + SAVE - - - Select destination folder - + - + -- cgit v1.3.1