diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-25 14:13:28 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-25 14:13:28 +0300 |
| commit | a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a (patch) | |
| tree | 1e0b202b176a05d0921c91e67a43221479525d6c /Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage | |
| parent | 4571fffeccd4b037553fdeb0ddaff8005de67f23 (diff) | |
| download | Tango-a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a.tar.gz Tango-a7d1b350a7e6789942bd755f4a8dd48fb15a1a0a.zip | |
Batch import/export jobs.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage')
3 files changed, 98 insertions, 14 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 2c2a7f10d..3ec14cc6f 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,6 +9,8 @@ namespace Tango.PPC.Storage.Models public enum StorageNavigationIntent { LoadFile, - SaveFile + LoadFiles, + SaveFile, + SaveFiles } } 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 8c166379e..b9d59334c 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,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -70,16 +71,21 @@ namespace Tango.PPC.Storage.ViewModels 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 = new StorageNavigationRequest(); + 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); } public override void OnApplicationStarted() @@ -128,7 +134,7 @@ namespace Tango.PPC.Storage.ViewModels base.OnNavigatedFrom(); DisplayItems = false; Request = null; - Request = new StorageNavigationRequest(); + Request = new StorageNavigationRequest() { Intent = StorageNavigationIntent.LoadFiles }; } /// <summary> @@ -184,7 +190,14 @@ namespace Tango.PPC.Storage.ViewModels _selectedItem = fileItem; _allow_exit = true; await NavigationManager.NavigateBack(); - StorageProvider.SubmitFileSelection(fileItem); + StorageProvider.SubmitFileSelection(new List<ExplorerFileItem>() { fileItem }); + } + + private async void OnOpenCommand() + { + _allow_exit = true; + await NavigationManager.NavigateBack(); + StorageProvider.SubmitFileSelection(SelectedItems.ToList()); } public ExplorerFileItem GetNavigationResult() @@ -200,10 +213,22 @@ namespace Tango.PPC.Storage.ViewModels private void OnSaveCommand() { _allow_exit = true; - _selectedItem = new ExplorerFileItem() + + if (Request.Intent == StorageNavigationIntent.SaveFile) + { + _selectedItem = new ExplorerFileItem() + { + Path = CurrentPath + "\\" + FileName, + }; + } + else if (Request.Intent == StorageNavigationIntent.SaveFiles) { - Path = CurrentPath + "\\" + FileName, - }; + _selectedItem = new ExplorerFileItem() + { + Path = CurrentPath, + }; + } + NavigationManager.NavigateBack(); } 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 25538a525..e8d402d89 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,8 +32,54 @@ </Border> <Grid Margin="10" Grid.Row="1"> <DockPanel> - - <Grid DockPanel.Dock="Top" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile}"> + <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> <Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" Padding="20"> <StackPanel> <TextBlock Text="{Binding Request.Title}" FontSize="{StaticResource TangoHeaderFontSize}"></TextBlock> @@ -43,20 +89,31 @@ SAVE </touch:TouchButton.Content> </touch:TouchButton> - <touch:TouchTextBox x:Name="txtFileName" KeyboardAction="Go" FocusSelectionMode="SelectAll" VerticalAlignment="Bottom" Text="{Binding FileName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> + <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> </DockPanel> </StackPanel> </Border> </Grid> - <explorer:ExplorerControl x:Name="explorer" CurrentPath="{Binding CurrentPath,Mode=TwoWay}" FileSelectedCommand="{Binding FileSelectedCommand}" Filter="{Binding Request.Filter}" Visibility="{Binding DisplayItems,Converter={StaticResource BooleanToVisibilityConverter}}"> + <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.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="False"></Setter> + </DataTrigger> </Style.Triggers> </Style> </explorer:ExplorerControl.Style> |
