From 7689f77fe2f356d17a5ad59dbeb4a0fed3ca4a0d Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 25 May 2020 17:27:24 +0300 Subject: Added PPC power up sequence support ! Refactored AppBarItems implementation. --- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 42 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 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 b53a54682..e84fd81a1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -21,6 +21,7 @@ using Tango.PPC.Common.WatchDog; using Tango.PPC.UI.Dialogs; using Tango.SharedUI; using System.Data.Entity; +using Tango.PPC.UI.AppBarItems; namespace Tango.PPC.UI.ViewModels { @@ -33,6 +34,7 @@ namespace Tango.PPC.UI.ViewModels private DispatcherTimer _date_timer; private bool _isPowerUpDialogShown; private bool _isThreadLoadingShown; + private PowerUpAppBarItem _powerUpAppBar; private DateTime _currentDateTime; /// @@ -64,11 +66,47 @@ namespace Tango.PPC.UI.ViewModels { base.OnApplicationReady(); MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived; - MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; + MachineProvider.MachineOperator.FirmwareStarted += MachineOperator_FirmwareStarted; MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged; MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired; + + MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted; + MachineProvider.MachineOperator.PowerUpProgress += MachineOperator_PowerUpProgress; + MachineProvider.MachineOperator.PowerUpEnded += MachineOperator_PowerUpEnded; + } + + #region Power Up + + private void MachineOperator_PowerUpEnded(object sender, EventArgs e) + { + _powerUpAppBar?.Close(); + _powerUpAppBar = null; + } + + private void MachineOperator_PowerUpProgress(object sender, PMR.Power.StartPowerUpResponse status) + { + if (_powerUpAppBar != null) + { + _powerUpAppBar.Status = status; + } } + private void MachineOperator_PowerUpStarted(object sender, PMR.Power.StartPowerUpResponse e) + { + InvokeUI(() => + { + if (_powerUpAppBar != null) + { + _powerUpAppBar.Close(); + } + + _powerUpAppBar = NotificationProvider.PushAppBarItem(); + _powerUpAppBar.Priority = AppBarPriority.Low; + }); + } + + #endregion + #region Event Handlers /// @@ -101,7 +139,7 @@ namespace Tango.PPC.UI.ViewModels }); } - private async void MachineOperator_PowerUpStarted(object sender, EventArgs e) + private async void MachineOperator_FirmwareStarted(object sender, EventArgs e) { if (_isPowerUpDialogShown) { -- cgit v1.3.1