From 4a41df0b200191ce96a13fb80412e51d46f08cb4 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 27 Oct 2019 14:07:14 +0200 Subject: Fixed a bug with PPC storage invalid file na chars. --- .../Tango.PPC.Storage/ViewModels/MainViewVM.cs | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage') 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 23d471138..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 @@ -21,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 @@ -49,7 +50,17 @@ namespace Tango.PPC.Storage.ViewModels public String FileName { get { return _fileName; } - set { _fileName = value; RaisePropertyChangedAuto(); SaveCommand.RaiseCanExecuteChanged(); } + set + { + if (_fileName != value) + { + _fileName = value; + OnFileNameChanged(); + } + + RaisePropertyChangedAuto(); + SaveCommand.RaiseCanExecuteChanged(); + } } public RelayCommand FileSelectedCommand { get; set; } @@ -182,5 +193,21 @@ namespace Tango.PPC.Storage.ViewModels }; NavigationManager.NavigateBack(); } + + private void OnFileNameChanged() + { + String text = FileName; + + if (text != null) + { + foreach (var c in _invalidChars) + { + text = text.Replace(c.ToString(), ""); + } + + _fileName = text; + RaisePropertyChanged(nameof(FileName)); + } + } } } -- cgit v1.3.1