diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-25 16:39:01 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-25 16:39:01 +0200 |
| commit | 78c93e2ee1eddff67554edec9f956536a0b61482 (patch) | |
| tree | 208e8f9c368cfa324e255493bb287e50b79b04fa /Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels | |
| parent | ca18248f6203d7567a2276ec76360aedd4cfda0b (diff) | |
| download | Tango-78c93e2ee1eddff67554edec9f956536a0b61482.tar.gz Tango-78c93e2ee1eddff67554edec9f956536a0b61482.zip | |
Working on Backup/Restore...
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels')
4 files changed, 232 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs new file mode 100644 index 000000000..067e40d08 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.Explorer; +using Tango.PPC.BackupRestore.Views; +using Tango.PPC.Common; +using Tango.PPC.Common.BackupRestore; +using Tango.PPC.Storage; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class BackupViewVM : PPCViewModel + { + [TangoInject] + public IBackupManager BackupManager { get; set; } + + public BackupSettings BackupSettings { get; set; } + + private BackupRestoreProgressEventArgs _currentBackupProgress; + public BackupRestoreProgressEventArgs CurrentBackupProgress + { + get { return _currentBackupProgress; } + set { _currentBackupProgress = value; RaisePropertyChangedAuto(); } + } + + + private bool _isBackupJobs; + public bool IsBackupJobs + { + get { return _isBackupJobs; } + set + { + if (value) + { + _isBackupJobs = value; + RaisePropertyChangedAuto(); + _isBackupFull = false; + RaisePropertyChanged(nameof(IsBackupFull)); + } + else + { + RaisePropertyChangedAuto(); + } + } + } + + private bool _isBackupFull; + public bool IsBackupFull + { + get { return _isBackupFull; } + set + { + if (value) + { + _isBackupFull = value; + RaisePropertyChangedAuto(); + _isBackupJobs = false; + RaisePropertyChanged(nameof(IsBackupJobs)); + } + else + { + RaisePropertyChangedAuto(); + } + } + } + + private String _backupLocation; + public String BackupLocation + { + get { return _backupLocation; } + set { _backupLocation = value; RaisePropertyChangedAuto(); } + } + + private String _backupName; + public String BackupName + { + get { return _backupName; } + set { _backupName = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand BackupCommand { get; set; } + + public RelayCommand BrowseBackupLocationCommand { get; set; } + + public BackupViewVM() + { + BrowseBackupLocationCommand = new RelayCommand(BrowseBackupLocation); + BackupCommand = new RelayCommand(StartBackup); + IsBackupJobs = true; + } + + private async void StartBackup() + { + await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(BackupProgressView)); + + if (IsFree) + { + IsFree = false; + await Task.Delay(10000); + IsFree = true; + } + } + + public override void OnApplicationStarted() + { + + } + + public override void OnApplicationReady() + { + base.OnApplicationReady(); + BackupManager.Progress += BackupManager_Progress; + } + + private void BackupManager_Progress(object sender, BackupRestoreProgressEventArgs e) + { + CurrentBackupProgress = e; + } + + private async void BrowseBackupLocation() + { + var result = await NavigationManager. + NavigateForResult<StorageModule, + Storage.Views.MainView, ExplorerFileItem, + Storage.Models.StorageNavigationRequest>( + new Storage.Models.StorageNavigationRequest() + { + Intent = Storage.Models.StorageNavigationIntent.SaveFile, + DefaultFileName = $"Tango-Backup-{DateTime.Now.ToFileName()}", + Filter = ExplorerFileDefinition.Backup.Extension, + Title = "Select Destination Backup File", + }); + + if (result != null) + { + BackupLocation = System.IO.Path.GetFileNameWithoutExtension(result.Path) + ExplorerFileDefinition.Backup.Extension; + } + } + + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..989f8a6ee --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/MainViewVM.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.Explorer; +using Tango.PPC.BackupRestore.Views; +using Tango.PPC.Common; +using Tango.PPC.Common.BackupRestore; +using Tango.PPC.Storage; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class MainViewVM : PPCViewModel + { + public override void OnNavigatedFrom() + { + base.OnNavigatedFrom(); + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + NavigationManager.NavigateTo<BackupRestoreModule>(nameof(WelcomeView), false); + } + + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs new file mode 100644 index 000000000..904fd9e52 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class RestoreViewVM : PPCViewModel + { + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/WelcomeViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/WelcomeViewVM.cs new file mode 100644 index 000000000..daddfeedc --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/WelcomeViewVM.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.PPC.BackupRestore.Views; +using Tango.PPC.Common; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class WelcomeViewVM : PPCViewModel + { + public RelayCommand NavigateToBackupCommand { get; set; } + + public RelayCommand NavigateToRestoreCommand { get; set; } + + public WelcomeViewVM() + { + NavigateToBackupCommand = new RelayCommand(() => + { + NavigationManager.NavigateTo<BackupRestoreModule>(nameof(BackupView)); + }); + + NavigateToRestoreCommand = new RelayCommand(() => + { + NavigationManager.NavigateTo<BackupRestoreModule>(nameof(RestoreView)); + }); + } + + public override void OnApplicationStarted() + { + + } + } +} |
