aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-16 14:32:39 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-16 14:32:39 +0200
commitadabe4e1b99bc57f0381fb0a5bb3192ac0fdff18 (patch)
treeadfce075209485fb449af343b1b7877d02b93e64 /Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs
parentb188d7bfd91062f65474bd139bb8a434694f117b (diff)
downloadTango-adabe4e1b99bc57f0381fb0a5bb3192ac0fdff18.tar.gz
Tango-adabe4e1b99bc57f0381fb0a5bb3192ac0fdff18.zip
Working on FSE/PPC FileSystem Provider/Service.
Diffstat (limited to 'Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs')
-rw-r--r--Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs80
1 files changed, 72 insertions, 8 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs
index 44bd03c39..f9eff7e6f 100644
--- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs
+++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs
@@ -1,15 +1,19 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
using Tango.Core.Commands;
using Tango.FileSystem;
using Tango.FSE.Common;
+using Tango.FSE.Common.Connection;
+using static Tango.SharedUI.Controls.NavigationControl;
namespace Tango.FSE.PPCConsole.ViewModels
{
- public class FileSystemViewVM : FSEViewModel
+ public class FileSystemViewVM : FSEViewModel, INavigationViewModel
{
private FileSystemItem _currentItem;
public FileSystemItem CurrentItem
@@ -26,32 +30,92 @@ namespace Tango.FSE.PPCConsole.ViewModels
}
public RelayCommand NavigateCommand { get; set; }
+ public RelayCommand<FileSystemItem> OpenItemCommand { get; set; }
+ public RelayCommand BackCommand { get; set; }
public FileSystemViewVM()
{
- NavigateCommand = new RelayCommand(Navigate);
+ NavigateCommand = new RelayCommand(NavigateToCurrentPath);
+ OpenItemCommand = new RelayCommand<FileSystemItem>(OpenFileSystemItem);
+ BackCommand = new RelayCommand(NavigateBack, () => !(CurrentItem is FolderItem) || !(CurrentItem as FolderItem).IsRoot);
+ }
+
+ private async void NavigateBack()
+ {
+ if (CurrentItem.Path.Length == 3)
+ {
+ await Navigate(null);
+ }
+ else
+ {
+ String parent = Path.GetDirectoryName(CurrentItem.Path);
+ await Navigate(parent);
+ }
+ }
+
+ public override void OnApplicationStarted()
+ {
+ base.OnApplicationStarted();
+ MachineProvider.MachineConnected += MachineProvider_MachineConnected;
}
public override void OnApplicationReady()
{
base.OnApplicationReady();
+ }
+
+ private async void MachineProvider_MachineConnected(object sender, MachineConnectedEventArgs e)
+ {
+ await Navigate(null);
+ }
+
+ private async void NavigateToCurrentPath()
+ {
+ await Navigate(CurrentPath);
+ }
- FileSystemManager manager = new FileSystemManager();
- CurrentItem = FileSystemItem.FromDTO(manager.GetFolder(@"C:\"));
+ private async void OpenFileSystemItem(FileSystemItem item)
+ {
+ if (item != null)
+ {
+ await Navigate(item.Path);
+ }
}
- private void Navigate()
+ private async Task Navigate(String path)
{
- if (CurrentPath.IsNotNullOrEmpty())
+ try
+ {
+ IsFree = false;
+
+ Mouse.OverrideCursor = Cursors.AppStarting;
+
+ if (path != null)
+ {
+ CurrentItem = await FileSystemProvider.GetFolder(path) as FileSystemItem;
+ }
+ else
+ {
+ CurrentItem = await FileSystemProvider.GetThisPC() as FileSystemItem;
+ }
+ }
+ catch (Exception ex)
+ {
+ IsFree = true;
+ Mouse.OverrideCursor = null;
+ await NotificationProvider.ShowError($"Error navigating to the specified path.\n{ex.FlattenMessage()}");
+ }
+ finally
{
- FileSystemManager manager = new FileSystemManager();
- CurrentItem = FileSystemItem.FromDTO(manager.GetFolder(CurrentPath));
+ IsFree = true;
+ Mouse.OverrideCursor = null;
}
}
private void OnCurrentItemChanged()
{
CurrentPath = CurrentItem.Path;
+ InvalidateRelayCommands();
}
}
}