diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-07-01 17:56:49 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-07-01 17:56:49 +0300 |
| commit | 8a1e772f025eaf3bfdf17905d9e33c460993e559 (patch) | |
| tree | b6d705cca71033cd6c5f814596ceb9abc849bf50 /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | c0fd8dcc53e45aa5aa0095cc2c8c5f39a34f7886 (diff) | |
| download | Tango-8a1e772f025eaf3bfdf17905d9e33c460993e559.tar.gz Tango-8a1e772f025eaf3bfdf17905d9e33c460993e559.zip | |
Many bug fixes !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
3 files changed, 58 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index dabfc5893..53e143def 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -28,6 +28,8 @@ namespace Tango.PPC.UI.Connectivity private INotificationProvider _notification; private IMachineProvider _machineProvider; private Rfc2898Cryptographer _cryptographer; + private System.Timers.Timer _updateTimer; + private WiFiNetwork _connectedNetwork; /// <summary> /// Occurs when the connectivity provider state has changed (e.g network connected/disconnected). @@ -136,12 +138,40 @@ namespace Tango.PPC.UI.Connectivity IsConnected = networks.Exists(x => x.IsConnected); + if (IsConnected) + { + _connectedNetwork = auto_connect_network; + } + if (auto_connect_network != null && !auto_connect_network.IsConnected) { auto_connect_network.AutoConnect = true; await Connect(auto_connect_network, _cryptographer.Decrypt(settings.AutoConnectWiFiPassword)); } }); + + _updateTimer = new System.Timers.Timer(TimeSpan.FromSeconds(30).TotalMilliseconds); + _updateTimer.Elapsed += _updateTimer_Elapsed; + _updateTimer.Start(); + } + + /// <summary> + /// Periodically checks if WiFI network is gone/disconnected. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="System.Timers.ElapsedEventArgs"/> instance containing the event data.</param> + private void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + if (IsConnected && _connectedNetwork != null) + { + var networks = GetAvailableWiFiNetworks().Result; + var matching_network = networks.FirstOrDefault(x => x.Name == _connectedNetwork.Name); + + if (matching_network == null || !matching_network.AccessPoint.IsConnected) + { + OnConnectionStateChanged(false); + } + } } /// <summary> @@ -264,6 +294,7 @@ namespace Tango.PPC.UI.Connectivity settings.AutoConnectWiFiName = network.AutoConnect ? network.Name : null; settings.AutoConnectWiFiPassword = _cryptographer.Encrypt(auth.Password); settings.Save(); + _connectedNetwork = network; } return result; @@ -295,6 +326,10 @@ namespace Tango.PPC.UI.Connectivity /// <param name="connected">if set to <c>true</c> [connected].</param> protected virtual void OnConnectionStateChanged(bool connected) { + if (!connected) + { + _connectedNetwork = null; + } IsConnected = connected; ConnectionStateChanged?.Invoke(this, new ConnectionStateEventArgs() { IsConnected = connected }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index 1f09023cb..456c69625 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -45,6 +45,8 @@ namespace Tango.PPC.UI.Printing /// <returns></returns> public async Task<JobHandler> Print(Job job, ObservablesContext context) { + ThrowIfJobInvalid(job); + JobHandler handler = null; #if STUBPRINT @@ -149,6 +151,8 @@ namespace Tango.PPC.UI.Printing /// <returns></returns> public async Task<JobHandler> PrintSample(Job job, ObservablesContext context) { + ThrowIfJobInvalid(job); + LogManager.Log("Cloning job..."); Job sampleDyeJob = job.Clone(); sampleDyeJob.Guid = job.Guid; @@ -202,6 +206,8 @@ namespace Tango.PPC.UI.Printing /// <returns></returns> public async Task<JobHandler> PrintFineTuning(Job job, ObservablesContext context, IEnumerable<FineTuneItem> fineTuneItems) { + ThrowIfJobInvalid(job); + LogManager.Log("Cloning job..."); Job fineTuneJob = job.Clone(); fineTuneJob.NumberOfUnits = 1; @@ -241,5 +247,21 @@ namespace Tango.PPC.UI.Printing { TangoMessenger.Default.Send(new JobSavedMessage() { Job = job }); } + + private void ThrowIfJobInvalid(Job job) + { + if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.IsOutOfGamut)) + { + throw new InvalidOperationException("Error starting job. Color is out of range."); + } + if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.ColorSpace.IsCatalog && x.ColorCatalog == null)) + { + throw new InvalidOperationException("Error starting job. Please select a catalog color."); + } + if (job.Rml.Ccts.Count == 0) + { + throw new InvalidOperationException($"Error starting job. No color table found for thread '{job.Rml.Name}'."); + } + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />--> </requestedPrivileges> </security> </trustInfo> |
