diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-27 19:10:18 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-11-27 19:10:18 +0200 |
| commit | 3f22291740c0ac631a655495f6198dbf18be2de2 (patch) | |
| tree | 3a5106dfc6258b5a30dce8e26f78a65b0b7a87d3 /Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore | |
| parent | ca29510e1e336c4d68aaa926cfea6eb72ce42779 (diff) | |
| download | Tango-3f22291740c0ac631a655495f6198dbf18be2de2.tar.gz Tango-3f22291740c0ac631a655495f6198dbf18be2de2.zip | |
A lot of work !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore')
22 files changed, 579 insertions, 53 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Tango.PPC.BackupRestore.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Tango.PPC.BackupRestore.csproj index 5e538ec89..99ac13ae4 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Tango.PPC.BackupRestore.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Tango.PPC.BackupRestore.csproj @@ -69,6 +69,22 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\RestoreCompletedView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\BackupCompletedView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\RestoreErrorView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\BackupErrorView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\RestoreProgressView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -113,10 +129,26 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\RestoreCompletedViewVM.cs" /> + <Compile Include="ViewModels\RestoreErrorViewVM.cs" /> <Compile Include="ViewModels\BackupViewVM.cs" /> + <Compile Include="ViewModels\BackupCompletedViewVM.cs" /> + <Compile Include="ViewModels\BackupErrorViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\RestoreViewVM.cs" /> <Compile Include="ViewModels\WelcomeViewVM.cs" /> + <Compile Include="Views\RestoreCompletedView.xaml.cs"> + <DependentUpon>RestoreCompletedView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\BackupCompletedView.xaml.cs"> + <DependentUpon>BackupCompletedView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\RestoreErrorView.xaml.cs"> + <DependentUpon>RestoreErrorView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\BackupErrorView.xaml.cs"> + <DependentUpon>BackupErrorView.xaml</DependentUpon> + </Compile> <Compile Include="Views\RestoreProgressView.xaml.cs"> <DependentUpon>RestoreProgressView.xaml</DependentUpon> </Compile> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModelLocator.cs index e414bca51..698a70cd7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModelLocator.cs @@ -19,6 +19,10 @@ namespace Tango.PPC.BackupRestore TangoIOC.Default.Register<WelcomeViewVM>(); TangoIOC.Default.Register<BackupViewVM>(); TangoIOC.Default.Register<RestoreViewVM>(); + TangoIOC.Default.Register<BackupErrorViewVM>(); + TangoIOC.Default.Register<BackupCompletedViewVM>(); + TangoIOC.Default.Register<RestoreErrorViewVM>(); + TangoIOC.Default.Register<RestoreCompletedViewVM>(); } /// <summary> @@ -55,5 +59,37 @@ namespace Tango.PPC.BackupRestore return TangoIOC.Default.GetInstance<RestoreViewVM>(); } } + + public static BackupErrorViewVM BackupErrorViewVM + { + get + { + return TangoIOC.Default.GetInstance<BackupErrorViewVM>(); + } + } + + public static BackupCompletedViewVM BackupCompletedViewVM + { + get + { + return TangoIOC.Default.GetInstance<BackupCompletedViewVM>(); + } + } + + public static RestoreErrorViewVM RestoreErrorViewVM + { + get + { + return TangoIOC.Default.GetInstance<RestoreErrorViewVM>(); + } + } + + public static RestoreCompletedViewVM RestoreCompletedViewVM + { + get + { + return TangoIOC.Default.GetInstance<RestoreCompletedViewVM>(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupCompletedViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupCompletedViewVM.cs new file mode 100644 index 000000000..8c40bf288 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupCompletedViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; +using Tango.PPC.Common.BackupRestore; +using Tango.PPC.Common.Navigation; +using static Tango.PPC.BackupRestore.ViewModels.BackupCompletedViewVM; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class BackupCompletedViewVM : PPCViewModel + { + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupErrorViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupErrorViewVM.cs new file mode 100644 index 000000000..42f2c9e51 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupErrorViewVM.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; +using Tango.PPC.Common.BackupRestore; +using Tango.PPC.Common.Navigation; +using static Tango.PPC.BackupRestore.ViewModels.BackupErrorViewVM; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class BackupErrorViewVM : PPCViewModel, INavigationObjectReceiver<BackupErrorNavigationObject> + { + public class BackupErrorNavigationObject + { + public String Error { get; set; } + } + + private String _error; + public String Error + { + get { return _error; } + set { _error = value; RaisePropertyChangedAuto(); } + } + + public override void OnApplicationStarted() + { + + } + + public void OnNavigatedToWithObject(BackupErrorNavigationObject obj) + { + Error = obj.Error; + } + } +} 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 index ab8d0248f..ef5b3810c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/BackupViewVM.cs @@ -10,6 +10,7 @@ using Tango.PPC.BackupRestore.Views; using Tango.PPC.Common; using Tango.PPC.Common.BackupRestore; using Tango.PPC.Storage; +using static Tango.PPC.BackupRestore.ViewModels.BackupErrorViewVM; namespace Tango.PPC.BackupRestore.ViewModels { @@ -94,17 +95,31 @@ namespace Tango.PPC.BackupRestore.ViewModels private async void StartBackup() { - await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(BackupProgressView)); + await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(BackupProgressView), false); - if (IsFree) + try { IsFree = false; + NavigationManager.IsBackEnabled = false; await BackupManager.CreateBackup(_backupFileName, BackupName, new BackupSettings() { Mode = IsBackupFull ? BackupMode.Full : BackupMode.Jobs, }); - await Task.Delay(10000); + await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(BackupCompletedView), false); + } + catch (Exception ex) + { + LogManager.Log(ex, "The backup operation failed."); + + await NavigationManager.NavigateWithObject<BackupRestoreModule, BackupErrorView, BackupErrorNavigationObject>(new BackupErrorNavigationObject() + { + Error = ex.FlattenMessage(), + }, false); + } + finally + { IsFree = true; + NavigationManager.IsBackEnabled = true; } } @@ -141,9 +156,8 @@ namespace Tango.PPC.BackupRestore.ViewModels if (result != null) { _backupFileName = result.Path + ExplorerFileDefinition.Backup.Extension; - BackupLocation = System.IO.Path.GetFileNameWithoutExtension(result.Path) + ExplorerFileDefinition.Backup.Extension; + BackupLocation = result.Path + ExplorerFileDefinition.Backup.Extension; } } - } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreCompletedViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreCompletedViewVM.cs new file mode 100644 index 000000000..6e949cd48 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreCompletedViewVM.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.PPC.Common; +using Tango.PPC.Common.BackupRestore; +using Tango.PPC.Common.Navigation; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class RestoreCompletedViewVM : PPCViewModel, INavigationObjectReceiver<RestoreResult> + { + private RestoreResult _restoreResult; + + public RelayCommand RestartCommand { get; set; } + + public RestoreCompletedViewVM() + { + RestartCommand = new RelayCommand(Restart); + } + + private void Restart() + { + if (_restoreResult.BackupFile.Settings.Mode == BackupMode.Jobs) + { + //Perform normal restart. + } + else + { + //Perform update restart using the result path. + } + } + + public override void OnApplicationStarted() + { + + } + + public void OnNavigatedToWithObject(RestoreResult restoreResult) + { + _restoreResult = restoreResult; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreErrorViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreErrorViewVM.cs new file mode 100644 index 000000000..b6df53318 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreErrorViewVM.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.BackupRestore.Views; +using Tango.PPC.Common; +using Tango.PPC.Common.BackupRestore; +using Tango.PPC.Common.Navigation; +using static Tango.PPC.BackupRestore.ViewModels.RestoreErrorViewVM; + +namespace Tango.PPC.BackupRestore.ViewModels +{ + public class RestoreErrorViewVM : PPCViewModel, INavigationObjectReceiver<RestoreErrorNavigationObject> + { + public class RestoreErrorNavigationObject + { + public String Error { get; set; } + } + + private String _error; + public String Error + { + get { return _error; } + set { _error = value; RaisePropertyChangedAuto(); } + } + + public override void OnApplicationStarted() + { + + } + + public void OnNavigatedToWithObject(RestoreErrorNavigationObject obj) + { + Error = obj.Error; + } + } +} 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 index ec6083436..d925ebad1 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreViewVM.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,12 +11,14 @@ using Tango.PPC.BackupRestore.Views; using Tango.PPC.Common; using Tango.PPC.Common.BackupRestore; using Tango.PPC.Storage; +using static Tango.PPC.BackupRestore.ViewModels.RestoreErrorViewVM; namespace Tango.PPC.BackupRestore.ViewModels { public class RestoreViewVM : PPCViewModel { private string _backupFileLocation; + private bool _isBrowsing; [TangoInject] public IBackupManager BackupManager { get; set; } @@ -48,6 +51,13 @@ namespace Tango.PPC.BackupRestore.ViewModels set { _currentRestoreProgress = value; RaisePropertyChangedAuto(); } } + private long _backupSize; + public long BackupSize + { + get { return _backupSize; } + set { _backupSize = value; RaisePropertyChangedAuto(); } + } + public RelayCommand BrowseForBackupCommand { get; set; } public RelayCommand RestoreCommand { get; set; } @@ -61,18 +71,36 @@ namespace Tango.PPC.BackupRestore.ViewModels private async void StartRestore() { - await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(RestoreProgressView)); + await NavigationManager.NavigateTo<BackupRestoreModule>(nameof(RestoreProgressView), false); - if (IsFree) + try { IsFree = false; + NavigationManager.IsBackEnabled = false; var result = await BackupManager.Restore(_backupFileLocation, RestoreSettings); + await NavigationManager.NavigateWithObject<BackupRestoreModule, RestoreCompletedView, RestoreResult>(result, false); + } + catch (Exception ex) + { + LogManager.Log(ex, "The restore operation failed."); + + await NavigationManager.NavigateWithObject<BackupRestoreModule, RestoreErrorView, RestoreErrorNavigationObject>(new RestoreErrorNavigationObject() + { + Error = ex.FlattenMessage(), + }, false); + + NavigationManager.IsBackEnabled = true; + } + finally + { IsFree = true; } } private async void BrowseForBackup() { + _isBrowsing = true; + var result = await NavigationManager. NavigateForResult<StorageModule, Storage.Views.MainView, ExplorerFileItem, @@ -84,6 +112,8 @@ namespace Tango.PPC.BackupRestore.ViewModels Title = "Select Backup File", }); + _isBrowsing = false; + if (result != null) { _backupFileLocation = result.Path; @@ -91,7 +121,8 @@ namespace Tango.PPC.BackupRestore.ViewModels try { BackupFile = await BackupManager.ExtractBackupConfiguration(_backupFileLocation); - BackupFileName = System.IO.Path.GetFileName(result.Path); + BackupFileName = Path.GetFileName(result.Path); + BackupSize = new System.IO.FileInfo(_backupFileLocation).Length; } catch (Exception ex) { @@ -101,12 +132,21 @@ namespace Tango.PPC.BackupRestore.ViewModels } } + public override Task<bool> OnNavigateBackRequest() + { + return Task.FromResult(IsFree); + } + public override void OnNavigatedFrom() { base.OnNavigatedFrom(); - BackupFileName = null; - BackupFile = null; - _backupFileLocation = null; + + if (!_isBrowsing) + { + BackupFileName = null; + BackupFile = null; + _backupFileLocation = null; + } } public override void OnApplicationReady() 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 index daddfeedc..4fbac321e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/WelcomeViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/WelcomeViewVM.cs @@ -32,5 +32,17 @@ namespace Tango.PPC.BackupRestore.ViewModels { } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + NotificationProvider.NotificationsVisible = false; + } + + public override Task<bool> OnNavigateBackRequest() + { + NotificationProvider.NotificationsVisible = true; + return base.OnNavigateBackRequest(); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupCompletedView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupCompletedView.xaml new file mode 100644 index 000000000..470c16256 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupCompletedView.xaml @@ -0,0 +1,37 @@ +<UserControl x:Class="Tango.PPC.BackupRestore.Views.BackupCompletedView" + 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:vm="clr-namespace:Tango.PPC.BackupRestore.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.PPC.BackupRestore" + xmlns:local="clr-namespace:Tango.PPC.BackupRestore.Views" + mc:Ignorable="d" + d:DesignHeight="700" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:BackupCompletedViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.BackupCompletedViewVM}"> + + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <DockPanel Margin="30 0 30 30"> + <Grid DockPanel.Dock="Top"> + <StackPanel> + <TextBlock TextWrapping="Wrap" FontSize="{StaticResource TangoDefaultFontSize}"> + <Run FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoSuccessBrush}">Backup completed</Run> + <LineBreak/> + <LineBreak/> + <Run>The backup operation was completed successfully.</Run> + </TextBlock> + </StackPanel> + </Grid> + + <Grid DockPanel.Dock="Bottom"> + + </Grid> + + <Grid> + + </Grid> + + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupCompletedView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupCompletedView.xaml.cs new file mode 100644 index 000000000..2a9779ed1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupCompletedView.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.BackupRestore.Views +{ + /// <summary> + /// Interaction logic for BackupView.xaml + /// </summary> + public partial class BackupCompletedView : UserControl + { + public BackupCompletedView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupErrorView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupErrorView.xaml new file mode 100644 index 000000000..b54694a50 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupErrorView.xaml @@ -0,0 +1,39 @@ +<UserControl x:Class="Tango.PPC.BackupRestore.Views.BackupErrorView" + 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:vm="clr-namespace:Tango.PPC.BackupRestore.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.PPC.BackupRestore" + xmlns:local="clr-namespace:Tango.PPC.BackupRestore.Views" + mc:Ignorable="d" + d:DesignHeight="700" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:BackupErrorViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.BackupErrorViewVM}"> + + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <DockPanel Margin="30 0 30 30"> + <Grid DockPanel.Dock="Top"> + <StackPanel> + <TextBlock TextWrapping="Wrap" FontSize="{StaticResource TangoDefaultFontSize}"> + <Run FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoErrorBrush}">Backup failed</Run> + <LineBreak/> + <LineBreak/> + <Run>The backup operation has failed due to the following reason.</Run> + </TextBlock> + </StackPanel> + </Grid> + + <Grid DockPanel.Dock="Bottom"> + + </Grid> + + <Grid> + <TextBlock Text="{Binding Error}" Margin="0 10 0 0" Height="Auto" TextWrapping="Wrap" Foreground="{StaticResource TangoGrayTextBrush}"> + + </TextBlock> + </Grid> + + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupErrorView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupErrorView.xaml.cs new file mode 100644 index 000000000..cf050140d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupErrorView.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.BackupRestore.Views +{ + /// <summary> + /// Interaction logic for BackupView.xaml + /// </summary> + public partial class BackupErrorView : UserControl + { + public BackupErrorView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupProgressView.xaml index 53056e794..7785c1c0f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupProgressView.xaml @@ -29,7 +29,7 @@ <Grid> <StackPanel VerticalAlignment="Center"> <TextBlock Text="{Binding CurrentBackupProgress.Stage,Converter={StaticResource EnumToDescriptionConverter},FallbackValue='Backing up data'}" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}"></TextBlock> - <touch:TouchProgressBar Margin="0 20" Height="10" IsIndeterminate="{Binding CurrentBackupProgress.IsIntermediate}" Maximum="{Binding CurrentBackupProgress.Total}" Value="{Binding CurrentBackupProgress.Progress,Mode=OneWay}" /> + <touch:TouchProgressBar Margin="0 20" Height="10" IsIndeterminate="{Binding CurrentBackupProgress.IsIntermediate}" Maximum="{Binding CurrentBackupProgress.MaxProgress}" Value="{Binding CurrentBackupProgress.Progress,Mode=OneWay}" /> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupView.xaml index 52dd87d92..bd37594ef 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/BackupView.xaml @@ -15,18 +15,7 @@ <DockPanel Margin="30 0 30 30"> <Grid DockPanel.Dock="Bottom"> <DockPanel> - <touch:TouchButton Command="{Binding BackupCommand}" HorizontalAlignment="Right" Height="80" Width="300" CornerRadius="40"> - <touch:TouchButton.Style> - <Style TargetType="touch:TouchButton" BasedOn="{StaticResource {x:Type touch:TouchButton}}"> - <Setter Property="Content" Value="START"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding IsFree}" Value="False"> - <Setter Property="Content" Value="IN PROGRESS"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </touch:TouchButton.Style> - </touch:TouchButton> + <touch:TouchButton Command="{Binding BackupCommand}" HorizontalAlignment="Right" Height="80" Width="300" CornerRadius="40" Content="START"/> </DockPanel> </Grid> <StackPanel IsEnabled="{Binding IsFree}"> @@ -85,7 +74,7 @@ <TextBlock>Please select the destination of your backup file</TextBlock> <DockPanel Height="50" Margin="0 20 0 0"> - <touch:TouchButton Command="{Binding BrowseBackupLocationCommand}" Margin="20 0 0 0" Width="150" DockPanel.Dock="Right" Foreground="{StaticResource TangoDarkForegroundBrush}" BorderBrush="{StaticResource TangoDarkForegroundBrush}" Style="{StaticResource TangoHollowButton}">BROWSE</touch:TouchButton> + <touch:TouchButton Command="{Binding BrowseBackupLocationCommand}" Margin="20 0 0 0" Width="150" DockPanel.Dock="Right" Foreground="{StaticResource TangoDarkForegroundBrush}" BorderBrush="{StaticResource TangoDarkForegroundBrush}" Style="{StaticResource TangoHollowButton}">SELECT</touch:TouchButton> <touch:TouchTextBox Text="{Binding BackupLocation}" IsReadOnly="True" /> </DockPanel> </StackPanel> @@ -100,7 +89,7 @@ <StackPanel Margin="0 20 0 0"> <TextBlock>Please enter the name of your backup</TextBlock> - <touch:TouchTextBox Margin="0 20 0 0" Text="{Binding BackupName}" /> + <touch:TouchTextBox Margin="0 20 0 0" Text="{Binding BackupName}" KeyboardContainer="{Binding RelativeSource={RelativeSource AncestorType=touch:TouchKeyboardContainer}}" /> </StackPanel> </StackPanel> </touch:TouchDropShadowBorder> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/MainView.xaml index d9c4c06a3..0caabd0e1 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/MainView.xaml @@ -11,7 +11,7 @@ mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <touch:TouchKeyboardContainer Background="{StaticResource TangoPrimaryBackgroundBrush}"> <DockPanel> <Grid DockPanel.Dock="Top"> <StackPanel DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0 20 0 0"> @@ -24,10 +24,16 @@ <local:WelcomeView/> <local:BackupView/> <local:RestoreView/> + <local:BackupProgressView/> <local:RestoreProgressView/> + <local:BackupErrorView/> + <local:RestoreErrorView/> + + <local:BackupCompletedView/> + <local:RestoreCompletedView/> </controls:NavigationControl> </DockPanel> - </Grid> + </touch:TouchKeyboardContainer> </UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreCompletedView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreCompletedView.xaml new file mode 100644 index 000000000..6352797e7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreCompletedView.xaml @@ -0,0 +1,37 @@ +<UserControl x:Class="Tango.PPC.BackupRestore.Views.RestoreCompletedView" + 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:vm="clr-namespace:Tango.PPC.BackupRestore.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.PPC.BackupRestore" + xmlns:local="clr-namespace:Tango.PPC.BackupRestore.Views" + mc:Ignorable="d" + d:DesignHeight="700" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RestoreCompletedViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RestoreCompletedViewVM}"> + + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <DockPanel Margin="30 0 30 30"> + <Grid DockPanel.Dock="Top"> + <StackPanel> + <TextBlock TextWrapping="Wrap" FontSize="{StaticResource TangoDefaultFontSize}"> + <Run FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoSuccessBrush}">System restored</Run> + <LineBreak/> + <LineBreak/> + <Run>Your system was successfully restored. The system needs to restart in order apply the changes.</Run> + </TextBlock> + </StackPanel> + </Grid> + + <Grid DockPanel.Dock="Bottom"> + <touch:TouchButton Command="{Binding RestartCommand}" HorizontalAlignment="Right" Height="80" Width="300" CornerRadius="40" Content="RESTART"/> + </Grid> + + <Grid> + + </Grid> + + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreCompletedView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreCompletedView.xaml.cs new file mode 100644 index 000000000..5c3fbeaec --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreCompletedView.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.BackupRestore.Views +{ + /// <summary> + /// Interaction logic for BackupView.xaml + /// </summary> + public partial class RestoreCompletedView : UserControl + { + public RestoreCompletedView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreErrorView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreErrorView.xaml new file mode 100644 index 000000000..2d09326ea --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreErrorView.xaml @@ -0,0 +1,39 @@ +<UserControl x:Class="Tango.PPC.BackupRestore.Views.RestoreErrorView" + 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:vm="clr-namespace:Tango.PPC.BackupRestore.ViewModels" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:global="clr-namespace:Tango.PPC.BackupRestore" + xmlns:local="clr-namespace:Tango.PPC.BackupRestore.Views" + mc:Ignorable="d" + d:DesignHeight="700" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RestoreErrorViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RestoreErrorViewVM}"> + + <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> + <DockPanel Margin="30 0 30 30"> + <Grid DockPanel.Dock="Top"> + <StackPanel> + <TextBlock TextWrapping="Wrap" FontSize="{StaticResource TangoDefaultFontSize}"> + <Run FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoErrorBrush}">Restore failed</Run> + <LineBreak/> + <LineBreak/> + <Run>The restore operation has failed due to the following reason.</Run> + </TextBlock> + </StackPanel> + </Grid> + + <Grid DockPanel.Dock="Bottom"> + + </Grid> + + <Grid> + <TextBlock Text="{Binding Error}" Margin="0 10 0 0" Height="Auto" TextWrapping="Wrap" Foreground="{StaticResource TangoGrayTextBrush}"> + + </TextBlock> + </Grid> + + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreErrorView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreErrorView.xaml.cs new file mode 100644 index 000000000..c0268d020 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreErrorView.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.BackupRestore.Views +{ + /// <summary> + /// Interaction logic for BackupView.xaml + /// </summary> + public partial class RestoreErrorView : UserControl + { + public RestoreErrorView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreProgressView.xaml index f83bb0bd5..65c1678c5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreProgressView.xaml @@ -29,7 +29,7 @@ <Grid> <StackPanel VerticalAlignment="Center"> <TextBlock Text="{Binding CurrentRestoreProgress.Stage,Converter={StaticResource EnumToDescriptionConverter},FallbackValue='Restoring data'}" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}"></TextBlock> - <touch:TouchProgressBar Margin="0 20" Height="10" IsIndeterminate="{Binding CurrentRestoreProgress.IsIntermediate}" Maximum="{Binding CurrentRestoreProgress.Total}" Value="{Binding CurrentRestoreProgress.Progress,Mode=OneWay}" /> + <touch:TouchProgressBar Margin="0 20" Height="10" IsIndeterminate="{Binding CurrentRestoreProgress.IsIntermediate}" Maximum="{Binding CurrentRestoreProgress.MaxProgress}" Value="{Binding CurrentRestoreProgress.Progress,Mode=OneWay}" /> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreView.xaml index 0f91f8ae6..fca7a668e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/Views/RestoreView.xaml @@ -15,18 +15,7 @@ <DockPanel Margin="30 0 30 30"> <Grid DockPanel.Dock="Bottom"> <DockPanel> - <touch:TouchButton Command="{Binding RestoreCommand}" HorizontalAlignment="Right" Height="80" Width="300" CornerRadius="40"> - <touch:TouchButton.Style> - <Style TargetType="touch:TouchButton" BasedOn="{StaticResource {x:Type touch:TouchButton}}"> - <Setter Property="Content" Value="START"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding IsFree}" Value="False"> - <Setter Property="Content" Value="IN PROGRESS"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </touch:TouchButton.Style> - </touch:TouchButton> + <touch:TouchButton Command="{Binding RestoreCommand}" HorizontalAlignment="Right" Height="80" Width="300" CornerRadius="40" Content="START"/> </DockPanel> </Grid> <StackPanel IsEnabled="{Binding IsFree}"> @@ -47,14 +36,14 @@ <TextBlock>Please insert a storage device and select your backup file</TextBlock> <DockPanel Height="50" Margin="0 20 0 0"> - <touch:TouchButton Command="{Binding BrowseForBackupCommand}" Margin="20 0 0 0" Width="150" DockPanel.Dock="Right" Foreground="{StaticResource TangoDarkForegroundBrush}" BorderBrush="{StaticResource TangoDarkForegroundBrush}" Style="{StaticResource TangoHollowButton}">BROWSE</touch:TouchButton> + <touch:TouchButton Command="{Binding BrowseForBackupCommand}" Margin="20 0 0 0" Width="150" DockPanel.Dock="Right" Foreground="{StaticResource TangoDarkForegroundBrush}" BorderBrush="{StaticResource TangoDarkForegroundBrush}" Style="{StaticResource TangoHollowButton}">SELECT</touch:TouchButton> <touch:TouchTextBox Text="{Binding BackupFileName}" IsReadOnly="True" /> </DockPanel> </StackPanel> </StackPanel> </touch:TouchDropShadowBorder> - <touch:TouchDropShadowBorder Padding="10" Margin="0 10 0 0"> + <touch:TouchDropShadowBorder Padding="10 10 10 0" Margin="0 10 0 0" Visibility="{Binding BackupFile,Converter={StaticResource IsNullToVisibilityConverter}}"> <StackPanel> <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <TextBlock VerticalAlignment="Center" Foreground="{StaticResource TangoPrimaryAccentBrush}">Information</TextBlock> @@ -65,13 +54,16 @@ <StackPanel> <controls:TableGrid RowHeight="20"> <TextBlock Text="Name:"></TextBlock> - <TextBlock Text="{Binding BackupFile.Name}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupFile.Name}"></TextBlock> <TextBlock Text="Date:"></TextBlock> - <TextBlock Text="{Binding BackupFile.Date}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupFile.Date}"></TextBlock> + + <TextBlock Text="Size:"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupSize,Converter={StaticResource ByteArrayToFileSizeConverter}}"></TextBlock> <TextBlock Text="Mode:"></TextBlock> - <TextBlock Text="{Binding BackupFile.Settings.Mode}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupFile.Settings.Mode}"></TextBlock> </controls:TableGrid> </StackPanel> @@ -88,7 +80,7 @@ </StackPanel.Style> <controls:TableGrid RowHeight="20"> <TextBlock Text="Jobs:"></TextBlock> - <TextBlock Text="{Binding BackupFile.JobFiles.Count}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupFile.JobFiles.Count}"></TextBlock> </controls:TableGrid> </StackPanel> @@ -105,10 +97,10 @@ </StackPanel.Style> <controls:TableGrid RowHeight="20"> <TextBlock Text="Application Version:"></TextBlock> - <TextBlock Text="{Binding BackupFile.ApplicationVersion}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupFile.ApplicationVersion}"></TextBlock> <TextBlock Text="Firmware Version:"></TextBlock> - <TextBlock Text="{Binding BackupFile.FirmwareVersion}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" Text="{Binding BackupFile.FirmwareVersion}"></TextBlock> </controls:TableGrid> </StackPanel> </StackPanel> @@ -118,10 +110,10 @@ <touch:TouchDropShadowBorder Padding="10" Margin="0 10 0 0"> <touch:TouchDropShadowBorder.Style> <Style TargetType="touch:TouchDropShadowBorder"> - <Setter Property="Visibility" Value="Visible"></Setter> + <Setter Property="Visibility" Value="Collapsed"></Setter> <Style.Triggers> - <DataTrigger Binding="{Binding BackupFile.Settings.Mode}" Value="Full"> - <Setter Property="Visibility" Value="Collapsed"></Setter> + <DataTrigger Binding="{Binding BackupFile.Settings.Mode}" Value="Jobs"> + <Setter Property="Visibility" Value="Visible"></Setter> </DataTrigger> </Style.Triggers> </Style> @@ -147,7 +139,7 @@ <touch:TouchCheckBox.Content> <TextBlock> <Run>Overwrite existing jobs</Run> - <Run Style="{StaticResource run}">(existing jobs will not change)</Run> + <Run Style="{StaticResource run}">(existing jobs will change if there are conflicts)</Run> </TextBlock> </touch:TouchCheckBox.Content> </touch:TouchCheckBox> |
