aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-25 17:52:49 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-25 17:52:49 +0200
commit9277bbd2fa070c69b83904f8fe5628fab2b947b8 (patch)
tree3099f9ce92f04c28517eb13938e913a1e376b3fe /Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage
parentf779e2b6f0bb1dedc7644c64651b59e31ce62c00 (diff)
downloadTango-9277bbd2fa070c69b83904f8fe5628fab2b947b8.tar.gz
Tango-9277bbd2fa070c69b83904f8fe5628fab2b947b8.zip
Working on job export import to storage.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationIntent.cs14
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs26
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs35
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml26
5 files changed, 95 insertions, 8 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
new file mode 100644
index 000000000..2c2a7f10d
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationIntent.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Storage.Models
+{
+ public enum StorageNavigationIntent
+ {
+ LoadFile,
+ SaveFile
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs
new file mode 100644
index 000000000..32a546f4f
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.PPC.Storage.Models
+{
+ public class StorageNavigationRequest
+ {
+ /// <summary>
+ /// Gets or sets the request intent.
+ /// </summary>
+ public StorageNavigationIntent Intent { get; set; }
+
+ /// <summary>
+ /// Gets or sets the file display filter (e.g .tup|.job|.ccp).
+ /// </summary>
+ public String Filter { get; set; }
+
+ /// <summary>
+ /// Gets or sets the default file name when saving a file.
+ /// </summary>
+ public String DefaultFileName { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj
index b6a2c885b..83f23e6b9 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj
@@ -50,6 +50,8 @@
<Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
+ <Compile Include="Models\StorageNavigationIntent.cs" />
+ <Compile Include="Models\StorageNavigationRequest.cs" />
<Compile Include="StorageModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
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 e62ebc932..05316d1f6 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
@@ -7,6 +7,7 @@ using Tango.Core.Commands;
using Tango.Explorer;
using Tango.PPC.Common;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.Storage.Models;
using Tango.PPC.Storage.TaskBarItems;
using Tango.PPC.Storage.ViewContracts;
@@ -16,7 +17,7 @@ namespace Tango.PPC.Storage.ViewModels
/// Represents the main view VM and entry point for <see cref="Storage.StorageModule"/>.
/// </summary>
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
- public class MainViewVM : PPCViewModel<IMainView>, INavigationResultProvider<ExplorerFileItem, String>
+ public class MainViewVM : PPCViewModel<IMainView>, INavigationResultProvider<ExplorerFileItem, StorageNavigationRequest>
{
private bool _allow_exit;
private ExplorerFileItem _selectedItem;
@@ -28,14 +29,22 @@ namespace Tango.PPC.Storage.ViewModels
set { _currentPath = value; RaisePropertyChangedAuto(); }
}
- public RelayCommand CloseCommand { get; set; }
+ private StorageNavigationRequest _request;
+ public StorageNavigationRequest Request
+ {
+ get { return _request; }
+ set { _request = value; RaisePropertyChangedAuto(); }
+ }
public RelayCommand<ExplorerFileItem> FileSelectedCommand { get; set; }
+ public RelayCommand SaveCommand { get; set; }
+
public MainViewVM()
{
- CloseCommand = new RelayCommand(Close);
FileSelectedCommand = new RelayCommand<ExplorerFileItem>(OnFileSelected);
+ SaveCommand = new RelayCommand(OnSaveCommand);
+ Request = new StorageNavigationRequest();
}
public override void OnApplicationStarted()
@@ -61,6 +70,7 @@ namespace Tango.PPC.Storage.ViewModels
if (StorageProvider.IsConnected && StorageProvider.Drive != null)
{
+ CurrentPath = null;
CurrentPath = StorageProvider.Drive.RootDirectory.FullName;
}
else
@@ -71,9 +81,10 @@ namespace Tango.PPC.Storage.ViewModels
}
}
- private async void Close()
+ public override void OnNavigatedFrom()
{
- await NavigationManager.NavigateBack();
+ base.OnNavigatedFrom();
+ Request = new StorageNavigationRequest();
}
/// <summary>
@@ -114,6 +125,7 @@ namespace Tango.PPC.Storage.ViewModels
{
if (_allow_exit || CurrentPath == StorageProvider.Drive.RootDirectory.FullName)
{
+ Request = null;
return Task.FromResult(true);
}
else
@@ -127,7 +139,7 @@ namespace Tango.PPC.Storage.ViewModels
{
_allow_exit = true;
await NavigationManager.NavigateBack();
- await NotificationProvider.ShowInfo($"File Selected: {fileItem.Name}");
+ StorageProvider.SubmitFileSelection(fileItem);
}
public ExplorerFileItem GetNavigationResult()
@@ -135,9 +147,18 @@ namespace Tango.PPC.Storage.ViewModels
return _selectedItem;
}
- public void OnNavigationObjectReceived(string extension)
+ public void OnNavigationObjectReceived(StorageNavigationRequest request)
{
+ Request = request;
+ }
+ private void OnSaveCommand()
+ {
+ _selectedItem = new ExplorerFileItem()
+ {
+ Path = CurrentPath + "\\" + Request.DefaultFileName,
+ };
+ 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 2fea4ce20..d7817fe6f 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
@@ -6,13 +6,37 @@
xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
xmlns:explorer="clr-namespace:Tango.Explorer;assembly=Tango.Explorer"
xmlns:vm="clr-namespace:Tango.PPC.Storage.ViewModels"
+ xmlns:models="clr-namespace:Tango.PPC.Storage.Models"
xmlns:global="clr-namespace:Tango.PPC.Storage"
xmlns:local="clr-namespace:Tango.PPC.Storage.Views"
mc:Ignorable="d"
d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}" Background="{StaticResource TangoPrimaryBackgroundBrush}">
<Grid>
<Grid Margin="10">
- <explorer:ExplorerControl x:Name="explorer" CurrentPath="{Binding CurrentPath,Mode=TwoWay}" FileSelectedCommand="{Binding FileSelectedCommand}" />
+ <DockPanel>
+
+ <Grid DockPanel.Dock="Top" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile,TargetNullValue=Visibility.Collapsed,FallbackValue=Visibility.Collapsed}">
+ <Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" Padding="20">
+ <DockPanel>
+ <touch:TouchButton Command="{Binding SaveCommand}" Margin="20 0 0 0" Height="50" Width="200" Style="{StaticResource TangoHollowButton}" CornerRadius="0" DockPanel.Dock="Right">SAVE</touch:TouchButton>
+ <touch:TouchTextBox VerticalAlignment="Bottom" Text="{Binding Request.DefaultFileName}" />
+ </DockPanel>
+ </Border>
+ </Grid>
+
+ <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>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Request.Intent}" Value="SaveFile">
+ <Setter Property="EnableFileSelection" Value="False"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </explorer:ExplorerControl.Style>
+ </explorer:ExplorerControl>
+ </DockPanel>
</Grid>
</Grid>
</UserControl>