diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-02-18 16:26:46 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-02-18 16:26:46 +0200 |
| commit | 00b7de2653058bd9657217075eae834f6a1a4ec5 (patch) | |
| tree | 91fdcc6cb1ac25e17967cb0c74cc842b405026bc /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | |
| parent | b7f4088f257c3c9c816f680c97a652f6f73de940 (diff) | |
| download | Tango-00b7de2653058bd9657217075eae834f6a1a4ec5.tar.gz Tango-00b7de2653058bd9657217075eae834f6a1a4ec5.zip | |
Implemented PPC thread loading from preparation..
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 38 |
1 files changed, 34 insertions, 4 deletions
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; /// <summary> @@ -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<ThreadLoadingViewVM>(vm); + _isThreadLoadingShown = false; + LogManager.Log("Thread loading screen closed."); if (!vm.DialogResult) @@ -257,7 +288,6 @@ namespace Tango.PPC.UI.ViewModels } }); } - #endregion } } |
