aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-12-15 13:12:20 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-12-15 13:12:20 +0200
commit13c57f7ccabadd3ed75ffaef195d35c15c2a8c68 (patch)
tree938bd6dd844cf2645510aa3d42f3bfbe24e52a7e /Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings
parentd1859415972bb991cba6639482c1cd2a9e19e8d8 (diff)
parent957ca86b8e899eb488626c456d9c37dd4545bd80 (diff)
downloadTango-13c57f7ccabadd3ed75ffaef195d35c15c2a8c68.tar.gz
Tango-13c57f7ccabadd3ed75ffaef195d35c15c2a8c68.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_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.cs84
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml59
2 files changed, 139 insertions, 4 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 598b1a194..5077fd884 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
@@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Tango.BL;
+using Tango.BL.Builders;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Core.Commands;
@@ -52,6 +53,13 @@ namespace Tango.PPC.MachineSettings.ViewModels
set { _selectedColorSpaces = value; RaisePropertyChangedAuto(); }
}
+ private ObservableCollection<Rml> _rmls;
+ public ObservableCollection<Rml> Rmls
+ {
+ get { return _rmls; }
+ set { _rmls = value; RaisePropertyChangedAuto(); }
+ }
+
private bool _enableHotSpot;
public bool EnableHotSpot
{
@@ -122,6 +130,27 @@ namespace Tango.PPC.MachineSettings.ViewModels
set { _defaultSpoolType = value; RaisePropertyChangedAuto(); }
}
+ private bool _synchronizeJobs;
+ public bool SynchronizeJobs
+ {
+ get { return _synchronizeJobs; }
+ set { _synchronizeJobs = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+ private bool _synchronizeDiagnostics;
+ public bool SynchronizeDiagnostics
+ {
+ get { return _synchronizeDiagnostics; }
+ set { _synchronizeDiagnostics = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+ private bool _autoCheckForUpdates;
+ public bool AutoCheckForUpdates
+ {
+ get { return _autoCheckForUpdates; }
+ set { _autoCheckForUpdates = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -136,12 +165,18 @@ namespace Tango.PPC.MachineSettings.ViewModels
/// </summary>
public RelayCommand DiscardCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the synchronize command.
+ /// </summary>
+ public RelayCommand SynchronizeCommand { get; set; }
+
#endregion
public MainViewVM()
{
SaveCommand = new RelayCommand(Save);
DiscardCommand = new RelayCommand(Discard);
+ SynchronizeCommand = new RelayCommand(Synchronize, () => !MachineDataSynchronizer.IsSynchronizing && IsFree && (SynchronizeJobs || SynchronizeDiagnostics));
}
private void Discard()
@@ -155,7 +190,7 @@ namespace Tango.PPC.MachineSettings.ViewModels
{
Settings.SupportedJobTypes = SelectedJobTypes.SynchedSource.ToList();
Settings.SupportedColorSpaces = SelectedColorSpaces.SynchedSource.ToList();
- Machine.MapPrimitivesWithStrings(MachineProvider.Machine);
+ Machine.MapPropertiesTo(MachineProvider.Machine, MappingFlags.NoReferenceTypes);
Settings.EnableHotSpot = EnableHotSpot;
Settings.HotSpotPassword = HotSpotPassword;
@@ -166,6 +201,12 @@ namespace Tango.PPC.MachineSettings.ViewModels
Settings.LockScreenPassword = LockScreenPassword;
Settings.DefaultRmlGuid = DefaultRML?.Guid;
Settings.DefaultSpoolTypeGuid = DefaultSpoolType?.Guid;
+ Settings.SynchronizeJobs = SynchronizeJobs;
+ Settings.SynchronizeDiagnostics = SynchronizeDiagnostics;
+ Settings.AutoCheckForUpdates = AutoCheckForUpdates;
+
+ MachineDataSynchronizer.IsEnabled = SynchronizeJobs || SynchronizeDiagnostics;
+
Settings.Save();
await MachineProvider.SaveMachine();
@@ -186,6 +227,18 @@ namespace Tango.PPC.MachineSettings.ViewModels
}
+ public async override void OnApplicationReady()
+ {
+ base.OnApplicationReady();
+ MachineDataSynchronizer.SynchronizationStarted += (_, __) => InvalidateRelayCommands();
+ MachineDataSynchronizer.SynchronizationEnded += (_, __) => InvalidateRelayCommands();
+
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ Rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildAsync();
+ }
+ }
+
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
@@ -216,6 +269,11 @@ namespace Tango.PPC.MachineSettings.ViewModels
DefaultRML = Adapter.Rmls.SingleOrDefault(x => x.Guid == Settings.DefaultRmlGuid);
DefaultSpoolType = Adapter.SpoolTypes.SingleOrDefault(x => x.Guid == Settings.DefaultSpoolTypeGuid);
+
+ SynchronizeJobs = Settings.SynchronizeJobs;
+ SynchronizeDiagnostics = Settings.SynchronizeDiagnostics;
+
+ AutoCheckForUpdates = Settings.AutoCheckForUpdates;
}
private async void OnEnableRemoteAssistanceChanged()
@@ -290,5 +348,29 @@ namespace Tango.PPC.MachineSettings.ViewModels
{
ExternalBridgeService.Enabled = EnableExternalBridge;
}
+
+ private async void Synchronize()
+ {
+ try
+ {
+ IsFree = false;
+ NotificationProvider.SetGlobalBusyMessage("Synchronizing...");
+
+ await MachineDataSynchronizer.Synchronize();
+
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ await NotificationProvider.ShowSuccess("Synchronization completed successfully.");
+ }
+ catch (Exception ex)
+ {
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ await NotificationProvider.ShowError($"Error occurred while trying to synchronize.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ IsFree = true;
+ }
+ }
}
}
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 0d9a3cea1..4a2f1e253 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
@@ -11,9 +11,9 @@
xmlns:global="clr-namespace:Tango.PPC.MachineSettings"
xmlns:local="clr-namespace:Tango.PPC.MachineSettings.Views"
mc:Ignorable="d"
- d:DesignHeight="2500" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+ d:DesignHeight="3000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
- <Grid Background="{StaticResource TangoMidBackgroundBrush}">
+ <Grid Background="{StaticResource TangoMidBackgroundBrush}" IsEnabled="{Binding IsFree}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
@@ -137,7 +137,7 @@
</ItemsControl>
<TextBlock VerticalAlignment="Bottom">Default Thread</TextBlock>
- <touch:TouchComboBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" ItemsSource="{Binding Adapter.Rmls}" SelectedItem="{Binding DefaultRML}" DisplayMemberPath="Name"></touch:TouchComboBox>
+ <touch:TouchComboBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" ItemsSource="{Binding Rmls}" SelectedItem="{Binding DefaultRML}" DisplayMemberPath="Name"></touch:TouchComboBox>
<TextBlock VerticalAlignment="Bottom">Default Spool</TextBlock>
<touch:TouchComboBox HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="200" ItemsSource="{Binding Adapter.SpoolTypes}" SelectedItem="{Binding DefaultSpoolType}" DisplayMemberPath="Name"></touch:TouchComboBox>
@@ -195,6 +195,59 @@
</DockPanel>
</StackPanel>
</touch:TouchExpander>
+
+ <!--SYNCHRONIZATION-->
+ <touch:TouchExpander Margin="0 20 0 0" Header="Cloud Synchronization" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}">
+ <StackPanel Margin="10 30 10 10">
+
+ <DockPanel TextElement.FontSize="{StaticResource TangoDefaultFontSize}">
+ <StackPanel>
+ <TextBlock VerticalAlignment="Center">Auto Update Check</TextBlock>
+ <DockPanel Margin="0 5 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}">
+ Automatically check for software and database updates.
+ </TextBlock>
+ </DockPanel>
+ </StackPanel>
+ <touch:TouchToggleSlider Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90" IsChecked="{Binding AutoCheckForUpdates}"></touch:TouchToggleSlider>
+ </DockPanel>
+
+ <DockPanel Margin="0 40 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}">
+ <StackPanel>
+ <TextBlock VerticalAlignment="Center">Synchronize Jobs</TextBlock>
+ <DockPanel Margin="0 5 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}">
+ Synchronize your jobs with twine's cloud services.
+ </TextBlock>
+ </DockPanel>
+ </StackPanel>
+ <touch:TouchToggleSlider Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90" IsChecked="{Binding SynchronizeJobs}"></touch:TouchToggleSlider>
+ </DockPanel>
+
+ <DockPanel Margin="0 40 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}">
+ <StackPanel>
+ <TextBlock VerticalAlignment="Center">Synchronize Diagnostics Data</TextBlock>
+ <DockPanel Margin="0 5 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}">
+ Help us improve your experience using this system.
+ </TextBlock>
+ </DockPanel>
+ </StackPanel>
+ <touch:TouchToggleSlider Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90" IsChecked="{Binding SynchronizeDiagnostics}"></touch:TouchToggleSlider>
+ </DockPanel>
+
+ <DockPanel Margin="0 40 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}">
+ Once enabled, synchronization occurres automatically in the background. you can choose to synchronize right now.
+ </TextBlock>
+ </DockPanel>
+ <touch:TouchButton Command="{Binding SynchronizeCommand}" IsEnabled="{Binding MachineDataSynchronizer.IsEnabled}" HorizontalAlignment="Left" Margin="25 10 0 0" Style="{StaticResource TangoHollowButton}" FontSize="{StaticResource TangoDefaultFontSize}" Padding="15 10" CornerRadius="22">Synchronize Now</touch:TouchButton>
+ </StackPanel>
+ </touch:TouchExpander>
</StackPanel>
</touch:LightTouchScrollViewer>
</Grid>