diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-21 16:24:37 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-21 16:24:37 +0200 |
| commit | a9c3aaed4d5c007f138bfc16f05aecdee73f1268 (patch) | |
| tree | bc41f31dec6a0f96e4c6e16372f8884053c7c17f /Software | |
| parent | 9ee373ebf7518c96fdf685da792568680dd7f135 (diff) | |
| download | Tango-a9c3aaed4d5c007f138bfc16f05aecdee73f1268.tar.gz Tango-a9c3aaed4d5c007f138bfc16f05aecdee73f1268.zip | |
Working on PPC Storage Provider !!!
Diffstat (limited to 'Software')
18 files changed, 403 insertions, 12 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 775d76141..7a6f9c9b5 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 2907879e7..d6d01a0ab 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf diff --git a/Software/Graphics/Mobile/flash-drive.png b/Software/Graphics/Mobile/flash-drive.png Binary files differnew file mode 100644 index 000000000..252e42e38 --- /dev/null +++ b/Software/Graphics/Mobile/flash-drive.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs index ef8f1c2ad..c86cf148b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/NavigationView.cs @@ -17,6 +17,7 @@ namespace Tango.PPC.Common.Navigation MachineSetupView, MachineUpdateView, ExternalBridgeView, + StorageView, HomeModule, ShutdownView, } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index fdcaa9830..3393689d1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -13,6 +13,7 @@ using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Printing; +using Tango.PPC.Common.Storage; using Tango.Settings; using Tango.SharedUI; using static Tango.SharedUI.Controls.NavigationControl; @@ -81,6 +82,12 @@ namespace Tango.PPC.Common [TangoInject] public IConnectivityProvider ConnectivityProvider { get; set; } + /// <summary> + /// Gets or sets the storage provider. + /// </summary> + [TangoInject] + public IStorageProvider StorageProvider { get; set; } + private PPCSettings _settings; /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Storage/DefaultStorageProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Storage/DefaultStorageProvider.cs new file mode 100644 index 000000000..5714f5dfb --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Storage/DefaultStorageProvider.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.DI; +using Tango.PPC.Common.Application; +using Tango.PPC.Common.Threading; + +namespace Tango.PPC.Common.Storage +{ + /// <summary> + /// Represents the default <see cref="IStorageProvider"/>. + /// </summary> + /// <seealso cref="Tango.Core.ExtendedObject" /> + /// <seealso cref="Tango.PPC.Common.Storage.IStorageProvider" /> + public class DefaultStorageProvider : ExtendedObject, IStorageProvider + { + private Thread _scanThread; + + /// <summary> + /// Occurs when a new storage drive has been inserted. + /// </summary> + public event EventHandler<DriveInfo> StorageConnected; + + /// <summary> + /// Occurs when a storage drive has been removed. + /// </summary> + public event EventHandler<DriveInfo> StorageDisconnected; + + private bool _isConnected; + /// <summary> + /// Gets a value indicating whether a storage drive is currently inserted. + /// </summary> + public bool IsConnected + { + get { return _isConnected; } + set { _isConnected = value; RaisePropertyChangedAuto(); } + } + + private DriveInfo _drive; + /// <summary> + /// Gets the inserted storage drive information. + /// </summary> + public DriveInfo Drive + { + get { return _drive; } + set { _drive = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="DefaultStorageProvider"/> class. + /// </summary> + public DefaultStorageProvider(IPPCApplicationManager applicationManager) + { + var drives = DriveInfo.GetDrives().Where(x => x.DriveType == DriveType.Removable).ToList(); + + if (drives.Count > 0) + { + IsConnected = true; + Drive = drives.FirstOrDefault(); + } + + applicationManager.ApplicationReady += ApplicationManager_ApplicationReady; + } + + /// <summary> + /// Handles the ApplicationReady event of the ApplicationManager. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> + private void ApplicationManager_ApplicationReady(object sender, EventArgs e) + { + Initialize(); + } + + private void Initialize() + { + _scanThread = new Thread(ScanThreadMethod); + _scanThread.IsBackground = true; + _scanThread.Start(); + } + + private void ScanThreadMethod() + { + while (true) + { + var drives = DriveInfo.GetDrives().Where(x => x.DriveType == DriveType.Removable).ToList(); + + if (IsConnected && !drives.Exists(x => x.RootDirectory.FullName == Drive.RootDirectory.FullName)) + { + StorageDisconnected?.Invoke(this, Drive); + Drive = null; + IsConnected = false; + } + + if (!IsConnected && drives.Count > 0) + { + Drive = drives.FirstOrDefault(); + IsConnected = true; + StorageConnected?.Invoke(this, Drive); + } + + Thread.Sleep(5000); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Storage/IStorageProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Storage/IStorageProvider.cs new file mode 100644 index 000000000..164cdfe0a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Storage/IStorageProvider.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Storage +{ + /// <summary> + /// Represents a storage provider responsible of notifying about flash drives connection/disconnection. + /// </summary> + public interface IStorageProvider + { + /// <summary> + /// Occurs when a new storage drive has been inserted. + /// </summary> + event EventHandler<DriveInfo> StorageConnected; + + /// <summary> + /// Occurs when a storage drive has been removed. + /// </summary> + event EventHandler<DriveInfo> StorageDisconnected; + + /// <summary> + /// Gets a value indicating whether a storage drive is currently inserted. + /// </summary> + bool IsConnected { get; } + + /// <summary> + /// Gets the inserted storage drive information. + /// </summary> + DriveInfo Drive { get; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index fbb0a048b..eb90bfd77 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -153,6 +153,8 @@ <Compile Include="PPCModuleAttribute.cs" /> <Compile Include="PPCModuleBase.cs" /> <Compile Include="Printing\IPrintingManager.cs" /> + <Compile Include="Storage\DefaultStorageProvider.cs" /> + <Compile Include="Storage\IStorageProvider.cs" /> <Compile Include="Threading\IDispatcherProvider.cs" /> <Compile Include="Update\IPPCUpdateService.cs" /> <Compile Include="Update\LatestVersionRequest.cs" /> @@ -314,7 +316,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/flash-drive.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/flash-drive.png Binary files differnew file mode 100644 index 000000000..252e42e38 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/flash-drive.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 5e5d5aac2..466ff0587 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -135,6 +135,7 @@ <Compile Include="ViewModels\MachineSetupViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\MachineUpdateViewVM.cs" /> + <Compile Include="ViewModels\StorageViewVM.cs" /> <Compile Include="ViewsContracts\ILayoutView.cs" /> <Compile Include="ViewsContracts\IMachineSetupView.cs" /> <Compile Include="ViewsContracts\IMachineUpdateView.cs" /> @@ -159,6 +160,9 @@ <Compile Include="Views\MachineUpdateView.xaml.cs"> <DependentUpon>MachineUpdateView.xaml</DependentUpon> </Compile> + <Compile Include="Views\StorageView.xaml.cs"> + <DependentUpon>StorageView.xaml</DependentUpon> + </Compile> <Page Include="Connectivity\WiFiAuthenticationView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -215,6 +219,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\StorageView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> </ItemGroup> <ItemGroup> <Compile Include="Properties\AssemblyInfo.cs"> @@ -263,6 +271,10 @@ <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project> <Name>Tango.DragAndDrop</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Explorer\Tango.Explorer.csproj"> + <Project>{4399af76-db52-4cfb-8020-6f85bdb29fd5}</Project> + <Name>Tango.Explorer</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> @@ -365,6 +377,7 @@ <Link>Tango.ColorLib.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Resource Include="Images\flash-drive.png" /> <Resource Include="Images\right-arrow-64.png" /> <Resource Include="Images\machine-update.png" /> <Resource Include="Images\home.png" /> @@ -432,7 +445,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\vcruntime140d.dll" "$(TargetDir)"</ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 57fae7791..47f4409f5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -16,6 +16,7 @@ using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Printing; +using Tango.PPC.Common.Storage; using Tango.PPC.Common.Threading; using Tango.PPC.UI.Authentication; using Tango.PPC.UI.Connectivity; @@ -59,6 +60,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IMachineUpdateManager>(); TangoIOC.Default.Unregister<IPrintingManager>(); TangoIOC.Default.Unregister<IConnectivityProvider>(); + TangoIOC.Default.Unregister<IStorageProvider>(); TangoIOC.Default.Register<IDispatcherProvider, DefaultDispatcherProvider>(new DefaultDispatcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register<INotificationProvider, DefaultNotificationProvider>(); @@ -75,6 +77,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<IMachineUpdateManager, MachineUpdateManager>(); TangoIOC.Default.Register<IPrintingManager, DefaultPrintingManager>(); TangoIOC.Default.Register<IConnectivityProvider, DefaultConnectivityProvider>(); + TangoIOC.Default.Register<IStorageProvider, DefaultStorageProvider>(); //TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); @@ -85,6 +88,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<ExternalBridgeViewVM>(); TangoIOC.Default.Register<MachineSetupViewVM>(); TangoIOC.Default.Register<MachineUpdateViewVM>(); + TangoIOC.Default.Register<StorageViewVM>(); TangoIOC.Default.GetInstance<IPPCApplicationManager>().ContentRendered += (_, __) => @@ -158,5 +162,13 @@ namespace Tango.PPC.UI return TangoIOC.Default.GetInstance<MachineUpdateViewVM>(); } } + + public static StorageViewVM StorageViewVM + { + get + { + return TangoIOC.Default.GetInstance<StorageViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 7ac7db47d..76eda9ac0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -89,6 +89,11 @@ namespace Tango.PPC.UI.ViewModels /// Gets or sets the update command. /// </summary> public RelayCommand UpdateCommand { get; set; } + + /// <summary> + /// Gets or sets the storage command. + /// </summary> + public RelayCommand StorageCommand { get; set; } #endregion #region Constructors @@ -109,6 +114,13 @@ namespace Tango.PPC.UI.ViewModels { NavigationManager.NavigateTo(NavigationView.MachineUpdateView); TangoIOC.Default.GetInstance<MachineUpdateViewVM>().CheckForUpdates(); + IsMenuOpened = false; + }); + + StorageCommand = new RelayCommand(() => + { + NavigationManager.NavigateTo(NavigationView.StorageView); + IsMenuOpened = false; }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/StorageViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/StorageViewVM.cs new file mode 100644 index 000000000..5b5167393 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/StorageViewVM.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Explorer; +using Tango.PPC.Common; + +namespace Tango.PPC.UI.ViewModels +{ + public class StorageViewVM : PPCViewModel + { + private String _currentPath; + public String CurrentPath + { + get { return _currentPath; } + set { _currentPath = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand CloseCommand { get; set; } + + public RelayCommand<ExplorerFileItem> FileSelectedCommand { get; set; } + + public StorageViewVM() + { + CloseCommand = new RelayCommand(Close); + FileSelectedCommand = new RelayCommand<ExplorerFileItem>(OnFileSelected); + } + + public override void OnApplicationStarted() + { + + } + + public override void OnApplicationReady() + { + base.OnApplicationReady(); + + StorageProvider.StorageConnected += StorageProvider_StorageConnected; + StorageProvider.StorageDisconnected += StorageProvider_StorageDisconnected; + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (StorageProvider.Drive != null) + { + CurrentPath = StorageProvider.Drive.RootDirectory.FullName; + } + } + + private async void Close() + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView); + } + + /// <summary> + /// Handles the storage connected event. + /// </summary> + /// <param name="sender">The sender.</param> + /// <param name="e">The drive info.</param> + private void StorageProvider_StorageConnected(object sender, System.IO.DriveInfo e) + { + InvokeUI(async () => + { + if (await NotificationProvider.ShowQuestion("Disk Inserted. Do you want to browse?")) + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.StorageView); + } + }); + } + + /// <summary> + /// Handles the storage disconnected event. + /// </summary> + /// <param name="sender">The sender.</param> + /// <param name="e">The drive info.</param> + private void StorageProvider_StorageDisconnected(object sender, System.IO.DriveInfo e) + { + InvokeUI(async () => + { + if (IsVisible) + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView); + } + }); + } + + private async void OnFileSelected(ExplorerFileItem fileItem) + { + await NavigationManager.NavigateTo(Common.Navigation.NavigationView.LayoutView); + await NotificationProvider.ShowInfo($"File Selected: {fileItem.Name}"); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 2db5f12b6..44a66d7f0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -62,12 +62,24 @@ </ItemsControl> <StackPanel Margin="0 5 0 0"> - <touch:TouchButton Style="{StaticResource TangoFlatButton}" Padding="30" Foreground="{StaticResource TangoDarkForegroundBrush}" Command="{Binding UpdateCommand}" FontSize="{StaticResource TangoHeaderFontSize}"> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> - <Image Source="/Images/right-arrow-64.png" VerticalAlignment="Center" Width="48" Height="48"></Image> - <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Update</TextBlock> - </StackPanel> - </touch:TouchButton> + + <Border BorderBrush="{StaticResource TangoDividerBrush}" BorderThickness="0 1 0 0" Visibility="{Binding StorageProvider.IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}"> + <touch:TouchButton Style="{StaticResource TangoFlatButton}" Padding="30" Foreground="{StaticResource TangoDarkForegroundBrush}" Command="{Binding StorageCommand}" FontSize="{StaticResource TangoHeaderFontSize}"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <Image Source="/Images/flash-drive.png" VerticalAlignment="Center" Width="48" Height="48"></Image> + <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Storage</TextBlock> + </StackPanel> + </touch:TouchButton> + </Border> + + <Border BorderBrush="{StaticResource TangoDividerBrush}" BorderThickness="0 1 0 0"> + <touch:TouchButton Style="{StaticResource TangoFlatButton}" Padding="30" Foreground="{StaticResource TangoDarkForegroundBrush}" Command="{Binding UpdateCommand}" FontSize="{StaticResource TangoHeaderFontSize}"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <Image Source="/Images/right-arrow-64.png" VerticalAlignment="Center" Width="48" Height="48"></Image> + <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Update</TextBlock> + </StackPanel> + </touch:TouchButton> + </Border> </StackPanel> </StackPanel> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index 4c3d38811..690022e64 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -57,6 +57,18 @@ </Style> </touch:TouchIcon.Style> </touch:TouchIcon> + <touch:TouchIcon Width="20" Height="20" VerticalAlignment="Center" Margin="10 0 0 0" Icon="HddSolid"> + <touch:TouchIcon.Style> + <Style TargetType="touch:TouchIcon" BasedOn="{StaticResource {x:Type touch:TouchIcon}}"> + <Setter Property="Foreground" Value="{StaticResource TangoGrayBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding StorageProvider.IsConnected}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource TangoSuccessBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchIcon.Style> + </touch:TouchIcon> <Grid></Grid> </DockPanel> </Border> @@ -69,6 +81,7 @@ <local:ExternalBridgeView></local:ExternalBridgeView> <local:MachineSetupView></local:MachineSetupView> <local:MachineUpdateView></local:MachineUpdateView> + <local:StorageView></local:StorageView> </controls:NavigationControl> </touch:TouchPanel> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/StorageView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/StorageView.xaml new file mode 100644 index 000000000..aa7bdcf7d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/StorageView.xaml @@ -0,0 +1,33 @@ +<UserControl x:Class="Tango.PPC.UI.Views.StorageView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:global="clr-namespace:Tango.PPC.UI" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" + xmlns:local="clr-namespace:Tango.PPC.UI.Views" + xmlns:explorer="clr-namespace:Tango.Explorer;assembly=Tango.Explorer" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:StorageViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.StorageViewVM}" Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <DockPanel> + + <Border DockPanel.Dock="Top" Background="{StaticResource TangoMidBackgroundBrush}" BorderBrush="{StaticResource TangoDividerBrush}" BorderThickness="0 0 0 1"> + <Border.Effect> + <DropShadowEffect BlurRadius="15" Color="{StaticResource TangoDropShadowColor}" /> + </Border.Effect> + <DockPanel Margin="10" Height="80" LastChildFill="False"> + <touch:TouchIconButton Style="{StaticResource TangoRoundTouchIconButton}" Padding="20" Margin="5" Icon="ArrowLeftBold" Command="{Binding ElementName=explorer,Path=BackCommand}"> + + </touch:TouchIconButton> + + <touch:TouchIconButton Icon="Close" Style="{StaticResource TangoRoundTouchIconButton}" Padding="20" Margin="5" DockPanel.Dock="Right" Command="{Binding CloseCommand}"></touch:TouchIconButton> + </DockPanel> + </Border> + + <Grid Margin="10"> + <explorer:ExplorerControl x:Name="explorer" CurrentPath="{Binding CurrentPath,Mode=TwoWay}" FileSelectedCommand="{Binding FileSelectedCommand}" /> + </Grid> + + </DockPanel> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/StorageView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/StorageView.xaml.cs new file mode 100644 index 000000000..d558d08bf --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/StorageView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.UI.Views +{ + /// <summary> + /// Interaction logic for StorageView.xaml + /// </summary> + public partial class StorageView : UserControl + { + public StorageView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs b/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs index 6f276f184..0c713a7db 100644 --- a/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs +++ b/Software/Visual_Studio/Tango.Explorer/ExplorerControl.cs @@ -53,6 +53,14 @@ namespace Tango.Explorer public static readonly DependencyProperty BackCommandProperty = DependencyProperty.Register("BackCommand", typeof(RelayCommand), typeof(ExplorerControl), new PropertyMetadata(null)); + public RelayCommand<ExplorerFileItem> FileSelectedCommand + { + get { return (RelayCommand<ExplorerFileItem>)GetValue(FileSelectedCommandProperty); } + set { SetValue(FileSelectedCommandProperty, value); } + } + public static readonly DependencyProperty FileSelectedCommandProperty = + DependencyProperty.Register("FileSelectedCommand", typeof(RelayCommand<ExplorerFileItem>), typeof(ExplorerControl), new PropertyMetadata(null)); + static ExplorerControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(ExplorerControl), new FrameworkPropertyMetadata(typeof(ExplorerControl))); @@ -99,16 +107,23 @@ namespace Tango.Explorer CurrentFolder = folder; SelectedItem = null; } + else if (SelectedItem is ExplorerFileItem) + { + FileSelectedCommand?.Execute(SelectedItem); + } } } private void NavigateBack() { - var parentPath = CurrentFolder.GetParentPath(); - - if (parentPath != null) + if (CurrentFolder != null) { - CurrentFolder = ExplorerFolderItem.LoadFromPath(parentPath); + var parentPath = CurrentFolder.GetParentPath(); + + if (parentPath != null) + { + CurrentFolder = ExplorerFolderItem.LoadFromPath(parentPath); + } } } } |
