diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs | 60 |
1 files changed, 13 insertions, 47 deletions
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<ExplorerFileItem> FileSelectedCommand { get; set; } - public ObservableCollection<ExplorerFileItem> SelectedItems { get; set; } - public RelayCommand SaveCommand { get; set; } - public RelayCommand OpenCommand { get; set; } - public MainViewVM() { - SelectedItems = new ObservableCollection<ExplorerFileItem>(); FileSelectedCommand = new RelayCommand<ExplorerFileItem>(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(); } /// <summary> @@ -175,6 +158,7 @@ namespace Tango.PPC.Storage.ViewModels { if (_allow_exit || CurrentPath == StorageProvider.Drive.RootDirectory.FullName) { + Request = null; return Task.FromResult(true); } else @@ -186,17 +170,9 @@ namespace Tango.PPC.Storage.ViewModels private async void OnFileSelected(ExplorerFileItem fileItem) { - _selectedItem = fileItem; - _allow_exit = true; - await NavigationManager.NavigateBack(); - StorageProvider.SubmitFileSelection(new List<ExplorerFileItem>() { 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)); |
