aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs
new file mode 100644
index 000000000..0e2f4bb56
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/WasteReplacementViewVM.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.Core.DI;
+using Tango.PMR.Diagnostics;
+using Tango.PPC.Common.Connection;
+using Tango.SharedUI;
+
+namespace Tango.PPC.UI.Dialogs
+{
+ public class WasteReplacementViewVM : DialogViewVM
+ {
+ private bool _doorClosed;
+ private bool _doorOpened;
+
+ [TangoInject]
+ private IMachineProvider MachineProvider { get; set; }
+
+ public WasteReplacementViewVM()
+ {
+ TangoIOC.Default.Inject(this);
+ MachineProvider.MachineOperator.EventsNotification += MachineOperator_EventsNotification;
+ }
+
+ private void MachineOperator_EventsNotification(object sender, StartEventsNotificationResponse e)
+ {
+ if (!_doorOpened)
+ {
+ if (e.Events.Select(x => x.Type).Contains(PMR.Diagnostics.EventType.CartridgesCoverOpen))
+ {
+ _doorOpened = true;
+ }
+ }
+ else
+ {
+ if (!e.Events.Select(x => x.Type).Contains(PMR.Diagnostics.EventType.CartridgesCoverOpen))
+ {
+ _doorClosed = true;
+ InvalidateRelayCommands();
+ }
+ }
+ }
+
+ protected override void Accept()
+ {
+ DisposeEvents();
+ base.Accept();
+ }
+
+ protected override void Cancel()
+ {
+ DisposeEvents();
+ base.Cancel();
+ }
+
+ protected override bool CanOK()
+ {
+ return base.CanOK() && _doorClosed && _doorOpened;
+ }
+
+ private void DisposeEvents()
+ {
+ MachineProvider.MachineOperator.EventsNotification -= MachineOperator_EventsNotification;
+ }
+ }
+}