diff options
| author | Mirta <mirta@twine-s.com> | 2020-11-23 16:13:53 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-11-23 16:13:53 +0200 |
| commit | 91c007adced573e09b77ab4be4a5aba623a816cc (patch) | |
| tree | 250221fc2def7d59f1393be8394f766faf576656 /Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings | |
| parent | 4e9af2b852eb3b9eecfa09e9bc76869558e183cb (diff) | |
| parent | 50a3c0b857b4aa88a9e3970d69256f12b5b24eb8 (diff) | |
| download | Tango-91c007adced573e09b77ab4be4a5aba623a816cc.tar.gz Tango-91c007adced573e09b77ab4be4a5aba623a816cc.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs | 112 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml | 22 |
2 files changed, 131 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index 3f6024b38..ef1126261 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -19,6 +19,8 @@ using Tango.PPC.Common; using Tango.PPC.Common.Connection; using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Messages; +using Tango.PPC.Common.OS; +using Tango.PPC.Common.UWF; using Tango.SharedUI.Components; using Tango.WiFi; @@ -30,8 +32,17 @@ namespace Tango.PPC.MachineSettings.ViewModels /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class MainViewVM : PPCViewModel { + private TimeZoneInfo _previousTimeZone; + private bool _previousEnableUWF; + #region Properties + [TangoInject] + private IOperationSystemManager OperationSystemManager { get; set; } + + [TangoInject] + private IUnifiedWriteFilterManager UnifiedWriteFilterManager { get; set; } + private Machine _machine; public Machine Machine { @@ -151,6 +162,34 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _autoCheckForUpdates = value; RaisePropertyChangedAuto(); } } + private List<TimeZoneInfo> _timeZones; + /// <summary> + /// Gets or sets the available time zones. + /// </summary> + public List<TimeZoneInfo> TimeZones + { + get { return _timeZones; } + set { _timeZones = value; RaisePropertyChangedAuto(); } + } + + private TimeZoneInfo _selectedTimeZone; + /// <summary> + /// Gets or sets the selected time zone. + /// </summary> + public TimeZoneInfo SelectedTimeZone + { + get { return _selectedTimeZone; } + set { _selectedTimeZone = value; RaisePropertyChangedAuto(); } + } + + private bool _enableUWF; + public bool EnableUWF + { + get { return _enableUWF; } + set { _enableUWF = value; RaisePropertyChangedAuto(); } + } + + #endregion #region Commands @@ -210,6 +249,55 @@ namespace Tango.PPC.MachineSettings.ViewModels Settings.Save(); await MachineProvider.SaveMachine(); + + if (_previousTimeZone.ToStringSafe() != SelectedTimeZone.ToStringSafe()) + { + if (await NotificationProvider.ShowQuestion("Changing the time zone requires the application to restart. Do you wish to restart the application?")) + { + try + { + LogManager.Log($"Setting new time zone to '{SelectedTimeZone.ToString()}'."); + NotificationProvider.SetGlobalBusyMessage("Setting new time zone..."); + await OperationSystemManager.ChangeTimeZone(SelectedTimeZone); + NotificationProvider.ReleaseGlobalBusyMessage(); + ApplicationManager.Restart(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error changing the time zone."); + NotificationProvider.ReleaseGlobalBusyMessage(); + await NotificationProvider.ShowError($"Error setting timezone.\n{ex.FlattenMessage()}"); + } + } + } + + if (_previousEnableUWF != EnableUWF) + { + await NotificationProvider.ShowWarning("Changes to disk protection (UWF) will take effect only after a full system restart."); + + try + { + LogManager.Log($"Changing UWF mode to '{EnableUWF}'."); + if (EnableUWF) + { + NotificationProvider.SetGlobalBusyMessage("Enabling disk protection (UWF)..."); + await UnifiedWriteFilterManager.Enable(); + } + else + { + NotificationProvider.SetGlobalBusyMessage("Disabling disk protection (UWF)..."); + await UnifiedWriteFilterManager.Disable(); + } + NotificationProvider.ReleaseGlobalBusyMessage(); + } + catch (Exception ex) + { + NotificationProvider.ReleaseGlobalBusyMessage(); + LogManager.Log(ex, "Error setting UWF mode."); + await NotificationProvider.ShowError($"Could not change the disk protection mode\n{ex.FlattenMessage()}"); + } + } + await NavigationManager.NavigateBack(); } } @@ -224,7 +312,14 @@ namespace Tango.PPC.MachineSettings.ViewModels /// </summary> public override void OnApplicationStarted() { - + try + { + TimeZones = OperationSystemManager.GetAvailableTimeZones().ToList(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error retrieving available time zones."); + } } public async override void OnApplicationReady() @@ -239,7 +334,7 @@ namespace Tango.PPC.MachineSettings.ViewModels } } - public override void OnNavigatedTo() + public async override void OnNavigatedTo() { base.OnNavigatedTo(); @@ -274,6 +369,19 @@ namespace Tango.PPC.MachineSettings.ViewModels SynchronizeDiagnostics = Settings.SynchronizeDiagnostics; AutoCheckForUpdates = Settings.AutoCheckForUpdates; + + SelectedTimeZone = TimeZones.SingleOrDefault(x => x.StandardName == TimeZone.CurrentTimeZone.StandardName); + _previousTimeZone = SelectedTimeZone; + + try + { + EnableUWF = await UnifiedWriteFilterManager.IsEnabled(); + _previousEnableUWF = EnableUWF; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error getting UWF status."); + } } private async void OnEnableRemoteAssistanceChanged() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index c8e2d4fff..ba3516be4 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -87,7 +87,7 @@ </touch:TouchExpander> <!--JOBS--> - <touch:TouchExpander Margin="0 20 0 0" Header="JOBS" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}"> + <touch:TouchExpander Margin="0 20 0 0" Header="Jobs" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}"> <StackPanel> <controls:TableGrid Margin="10" RowHeight="70" MakeFirstColumnVerticalAlignmentBottom="False" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> <TextBlock VerticalAlignment="Center">Supported Job Types</TextBlock> @@ -253,6 +253,21 @@ </StackPanel> </touch:TouchExpander> + <!--DATE & TIME--> + <touch:TouchExpander Margin="0 20 0 0" Header="Date & Time" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}" Visibility="{Binding ApplicationManager.IsInTechnicianMode,Converter={StaticResource BooleanToVisibilityConverter}}"> + <StackPanel Margin="10 30 10 10"> + + <DockPanel TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> + <StackPanel> + <TextBlock VerticalAlignment="Center">Time Zone</TextBlock> + <touch:TouchComboBox Margin="0 10 0 0" ItemsSource="{Binding TimeZones}" SelectedItem="{Binding SelectedTimeZone,Mode=TwoWay}"> + + </touch:TouchComboBox> + </StackPanel> + </DockPanel> + </StackPanel> + </touch:TouchExpander> + <!--TECHNICIAN--> <touch:TouchExpander Visibility="{Binding ApplicationManager.IsInTechnicianMode,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0 20 0 0" Header="Advanced" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}"> <StackPanel Margin="10 30 10 10"> @@ -337,6 +352,11 @@ <touch:TouchNumericTextBox Minimum="1" Maximum="120" KeyboardContainer="{Binding ElementName=Container}" Value="{Binding Settings.InsightsMaxStorageDuration,Converter={StaticResource TimeSpanToDaysConverter}}" Margin="0 0 100 0" DockPanel.Dock="Right" HorizontalAlignment="Right" Width="90"></touch:TouchNumericTextBox> </DockPanel> + <DockPanel Margin="0 20 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> + <TextBlock VerticalAlignment="Center">Enable UWF (Disk Protection)</TextBlock> + <touch:TouchToggleSlider IsChecked="{Binding EnableUWF}" Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90"></touch:TouchToggleSlider> + </DockPanel> + <DockPanel Margin="0 20 0 0"> <touch:TouchIcon VerticalAlignment="Top" Icon="InformationOutline" Foreground="{StaticResource TangoGrayTextBrush}"></touch:TouchIcon> <TextBlock Margin="10 0 0 0" VerticalAlignment="Top" TextWrapping="Wrap" FontSize="{StaticResource TangoSmallFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> |
