From 00b7de2653058bd9657217075eae834f6a1a4ec5 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 18 Feb 2020 16:26:46 +0200 Subject: Implemented PPC thread loading from preparation.. --- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index 5c518f60d..048234949 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -32,6 +32,7 @@ namespace Tango.PPC.UI.ViewModels { private DispatcherTimer _date_timer; private bool _isPowerUpDialogShown; + private bool _isThreadLoadingShown; private DateTime _currentDateTime; /// @@ -64,6 +65,7 @@ namespace Tango.PPC.UI.ViewModels base.OnApplicationReady(); MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived; MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; + MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged; MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired; } @@ -187,12 +189,30 @@ namespace Tango.PPC.UI.ViewModels }); } - private async void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e) + private void MachineOperator_ThreadLoadingStatusChanged(object sender, PMR.ThreadLoading.StartThreadLoadingResponse e) { - LogManager.Log("Thread loading confirmation detected, showing thread loading screen..."); + if (e.State == PMR.ThreadLoading.ThreadLoadingState.Preparing) + { + DisplayThreadLoading(); + } + } + + private void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e) + { + DisplayThreadLoading(e); + } + + private async void DisplayThreadLoading(ThreadLoadingConfirmationRequiredEventArgs confirmationArgs = null) + { + if (_isThreadLoadingShown) return; + + _isThreadLoadingShown = true; + + LogManager.Log("Thread loading preparation/finalization detected, showing thread loading screen..."); if (!Settings.DisplayAutomaticThreadLoadingScreen) { + _isThreadLoadingShown = false; LogManager.Log("Thread loading screen disabled. skipping..."); return; } @@ -212,12 +232,21 @@ namespace Tango.PPC.UI.ViewModels var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid); - vm = new ThreadLoadingViewVM(MachineProvider, e); + if (confirmationArgs == null) + { + vm = new ThreadLoadingViewVM(MachineProvider); + } + else + { + vm = new ThreadLoadingViewVM(MachineProvider, confirmationArgs); + } + vm.Rmls = rmls; vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault(); } catch (Exception ex) { + _isThreadLoadingShown = false; LogManager.Log(ex, "Error initializing thread loading screen."); return; } @@ -226,6 +255,8 @@ namespace Tango.PPC.UI.ViewModels { await NotificationProvider.ShowDialog(vm); + _isThreadLoadingShown = false; + LogManager.Log("Thread loading screen closed."); if (!vm.DialogResult) @@ -257,7 +288,6 @@ namespace Tango.PPC.UI.ViewModels } }); } - #endregion } } -- cgit v1.3.1