aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-21 16:24:37 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-21 16:24:37 +0200
commita9c3aaed4d5c007f138bfc16f05aecdee73f1268 (patch)
treebc41f31dec6a0f96e4c6e16372f8884053c7c17f /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent9ee373ebf7518c96fdf685da792568680dd7f135 (diff)
downloadTango-a9c3aaed4d5c007f138bfc16f05aecdee73f1268.tar.gz
Tango-a9c3aaed4d5c007f138bfc16f05aecdee73f1268.zip
Working on PPC Storage Provider !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs12
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/StorageViewVM.cs97
2 files changed, 109 insertions, 0 deletions
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}");
+ }
+ }
+}