From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Tango.PPC.Storage/ViewModels/MainViewVM.cs | 60 +++++----------------- 1 file changed, 13 insertions(+), 47 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels') 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)); -- cgit v1.3.1