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 | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage')
4 files changed, 21 insertions, 115 deletions
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 <see cref="StorageModule"/>. /// </summary> /// <seealso cref="Tango.PPC.Common.PPCModuleBase" /> - [PPCModule(5)] + [PPCModule(3)] public class StorageModule : PPCModuleBase { /// <summary> 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)); 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 @@ <UserControl.InputBindings> <KeyBinding Key="Return" Command="{Binding SaveCommand}"></KeyBinding> </UserControl.InputBindings> - + <Grid> <Grid Background="{StaticResource TangoMidBackgroundBrush}"> <Grid.RowDefinitions> @@ -32,89 +32,31 @@ </Border> <Grid Margin="10" Grid.Row="1"> <DockPanel> - <Grid DockPanel.Dock="Top"> - <Grid.Style> - <Style TargetType="Grid"> - <Setter Property="Visibility" Value="Collapsed"></Setter> - <Style.Triggers> - <MultiDataTrigger> - <MultiDataTrigger.Conditions> - <Condition Binding="{Binding Request.Intent}" Value="LoadFiles" /> - <Condition Binding="{Binding ElementName=explorer,Path=IsMultiSelecting}" Value="True" /> - </MultiDataTrigger.Conditions> - <Setter Property="Visibility" Value="Visible"></Setter> - </MultiDataTrigger> - </Style.Triggers> - </Style> - </Grid.Style> - <Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" Padding="20"> - <StackPanel> - <DockPanel Margin="0 0 0 0"> - <touch:TouchButton Command="{Binding OpenCommand}" Margin="20 0 0 0" Height="55" Width="200" Style="{StaticResource TangoHollowButton}" CornerRadius="25" DockPanel.Dock="Right"> - <touch:TouchButton.Content> - OPEN - </touch:TouchButton.Content> - </touch:TouchButton> - <Grid> - <TextBlock VerticalAlignment="Center" Foreground="{StaticResource TangoGrayTextBrush}"> - <Run Text="{Binding SelectedItems.Count,Mode=OneWay}"></Run> - <Run>files selected</Run> - </TextBlock> - </Grid> - </DockPanel> - </StackPanel> - </Border> - </Grid> - - <Grid DockPanel.Dock="Top"> - <Grid.Style> - <Style TargetType="Grid"> - <Setter Property="Visibility" Value="Collapsed"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Request.Intent}" Value="SaveFile"> - <Setter Property="Visibility" Value="Visible"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Request.Intent}" Value="SaveFiles"> - <Setter Property="Visibility" Value="Visible"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </Grid.Style> + + <Grid DockPanel.Dock="Top" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile}"> <Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" Padding="20"> <StackPanel> <TextBlock Text="{Binding Request.Title}" FontSize="{StaticResource TangoHeaderFontSize}"></TextBlock> <DockPanel Margin="0 10 0 0"> - <touch:TouchButton Command="{Binding SaveCommand}" Margin="20 0 0 0" Height="55" Width="200" Style="{StaticResource TangoHollowButton}" CornerRadius="25" DockPanel.Dock="Right"> + <touch:TouchButton Command="{Binding SaveCommand}" Margin="20 0 0 0" Height="50" Width="200" Style="{StaticResource TangoHollowButton}" CornerRadius="0" DockPanel.Dock="Right"> <touch:TouchButton.Content> SAVE </touch:TouchButton.Content> </touch:TouchButton> - <Grid> - <touch:TouchTextBox x:Name="txtFileName" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile}" KeyboardAction="Go" FocusSelectionMode="SelectAll" VerticalAlignment="Bottom" Text="{Binding FileName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> - <TextBlock VerticalAlignment="Center" Foreground="{StaticResource TangoGrayTextBrush}" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFiles}">Select destination folder</TextBlock> - </Grid> + <touch:TouchTextBox x:Name="txtFileName" KeyboardAction="Go" FocusSelectionMode="SelectAll" VerticalAlignment="Bottom" Text="{Binding FileName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> </DockPanel> </StackPanel> </Border> </Grid> - <explorer:ExplorerControl x:Name="explorer" CurrentPath="{Binding CurrentPath,Mode=TwoWay}" SelectedItems="{Binding SelectedItems}" FileSelectedCommand="{Binding FileSelectedCommand}" Filter="{Binding Request.Filter}" Visibility="{Binding DisplayItems,Converter={StaticResource BooleanToVisibilityConverter}}"> + <explorer:ExplorerControl x:Name="explorer" CurrentPath="{Binding CurrentPath,Mode=TwoWay}" FileSelectedCommand="{Binding FileSelectedCommand}" Filter="{Binding Request.Filter}"> <explorer:ExplorerControl.Style> <Style TargetType="explorer:ExplorerControl" BasedOn="{StaticResource {x:Type explorer:ExplorerControl}}"> <Setter Property="EnableFileSelection" Value="True"></Setter> - <Setter Property="EnableMultiSelect" Value="False"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding Request.Intent}" Value="SaveFile"> <Setter Property="EnableFileSelection" Value="False"></Setter> </DataTrigger> - <DataTrigger Binding="{Binding Request.Intent}" Value="LoadFiles"> - <Setter Property="EnableFileSelection" Value="True"></Setter> - <Setter Property="EnableMultiSelect" Value="True"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Request.Intent}" Value="LoadFile"> - <Setter Property="EnableFileSelection" Value="True"></Setter> - <Setter Property="EnableMultiSelect" Value="False"></Setter> - </DataTrigger> </Style.Triggers> </Style> </explorer:ExplorerControl.Style> |
