From ac3c227bb5d12339fee6fb4c243f3a5f67217915 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 28 Nov 2018 20:16:11 +0200 Subject: Working on machine studio storage ! --- .../ViewModels/MainViewVM.cs | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/ViewModels') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/ViewModels/MainViewVM.cs index d7eec4d36..f28783590 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/ViewModels/MainViewVM.cs @@ -3,15 +3,94 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Integration.ExternalBridge; +using Tango.Integration.Storage; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.StudioApplication; namespace Tango.MachineStudio.Storage.ViewModels { public class MainViewVM : StudioViewModel { + private IStudioApplicationManager _applicationManager; + private bool _machine_operator_changed = true; + + private StorageManager _storageManager; + public StorageManager StorageManager + { + get { return _storageManager; } + set { _storageManager = value; RaisePropertyChangedAuto(); } + } + + private StorageItem _selectedStorageItem; + public StorageItem SelectedStorageItem + { + get { return _selectedStorageItem; } + set { _selectedStorageItem = value; RaisePropertyChangedAuto(); } + } + + private String _currentPath; + public String CurrentPath + { + get { return _currentPath; } + set { _currentPath = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand BackCommand { get; set; } + + public RelayCommand RefreshCommand { get; set; } + + public RelayCommand GoCommand { get; set; } + + public MainViewVM(IStudioApplicationManager applicationManager) + { + _applicationManager = applicationManager; + _applicationManager.ConnectedMachineChanged += _applicationManager_ConnectedMachineChanged; + + GoCommand = new RelayCommand(NavigateToCurrentPath); + } + + private void _applicationManager_ConnectedMachineChanged(object sender, IExternalBridgeClient e) + { + _machine_operator_changed = true; + + if (IsVisible) + { + Initialize(); + } + } + public override void OnApplicationReady() { } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (_machine_operator_changed) + { + _machine_operator_changed = false; + Initialize(); + } + } + + private async void NavigateToCurrentPath() + { + await StorageManager.GetFolder(CurrentPath); + } + + private async void Initialize() + { + if (_applicationManager.ConnectedMachine != null) + { + StorageManager = _applicationManager.ConnectedMachine.CreateStorageManager(); + await StorageManager.GetStorageDrive(); + await StorageManager.GetRootFolder(); + CurrentPath = StorageManager.StorageDrive.Root; + } + } } } -- cgit v1.3.1