aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-05 19:33:06 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-05 19:33:06 +0200
commitb9009a814b9c91010e44534b42fa15fe164757a3 (patch)
tree007aa60379f5a519ce3c3328887c8aec4951931f /Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs
parentee3f1aa159ebb326e7c7053501130afa06bf47d4 (diff)
downloadTango-b9009a814b9c91010e44534b42fa15fe164757a3.tar.gz
Tango-b9009a814b9c91010e44534b42fa15fe164757a3.zip
Completed ThreadBreak/Loading Wizards !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs176
1 files changed, 0 insertions, 176 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs
deleted file mode 100644
index 95fb77e48..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/ThreadLoadingViewVM - Copy.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.BL.Entities;
-using Tango.Core.Commands;
-using Tango.Integration.Operation;
-using Tango.PMR.ThreadLoading;
-using Tango.PPC.Common.Connection;
-using Tango.SharedUI;
-
-namespace Tango.PPC.UI.Dialogs
-{
- public class ThreadLoadingViewVM : DialogViewVM
- {
- public class ThreadLoadingResult
- {
- public bool IsCompleted { get; set; }
- public Exception FailedException { get; set; }
- }
-
- private ThreadLoadingConfirmationRequiredEventArgs _confirmationArgs;
-
- public ThreadLoadingResult Result { get; set; }
-
- public IMachineProvider MachineProvider { get; set; }
-
- private StartThreadLoadingResponse _status;
- public StartThreadLoadingResponse Status
- {
- get { return _status; }
- set { _status = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _isFinalizing;
- public bool IsFinalizing
- {
- get { return _isFinalizing; }
- set { _isFinalizing = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
- }
-
- private bool _isPreparing;
- public bool IsPreparing
- {
- get { return _isPreparing; }
- set { _isPreparing = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
- }
-
- public List<Rml> Rmls { get; set; }
-
- private Rml _selectedRml;
- public Rml SelectedRml
- {
- get { return _selectedRml; }
- set { _selectedRml = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
- }
-
- public RelayCommand ContinueCommand { get; set; }
-
- public ThreadLoadingViewVM(IMachineProvider machineProvider)
- {
- CanClose = false;
- IsPreparing = true;
- ContinueCommand = new RelayCommand(ContinueThreadLoading, () => !IsFinalizing && SelectedRml != null);
- MachineProvider = machineProvider;
- MachineProvider.MachineOperator.ThreadLoadingStatusChanged += MachineOperator_ThreadLoadingStatusChanged;
- MachineProvider.MachineOperator.ThreadLoadingCompleted += MachineOperator_ThreadLoadingCompleted;
- MachineProvider.MachineOperator.ThreadLoadingFailed += MachineOperator_ThreadLoadingFailed;
- MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired;
- }
-
- public ThreadLoadingViewVM(IMachineProvider machineProvider, ThreadLoadingConfirmationRequiredEventArgs confirmationArgs) : this(machineProvider)
- {
- _confirmationArgs = confirmationArgs;
- IsPreparing = false;
- }
-
- private void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e)
- {
- _confirmationArgs = e;
- IsPreparing = false;
- }
-
- private async void ContinueThreadLoading()
- {
- IsFinalizing = true;
-
- try
- {
- await Task.Factory.StartNew(() => { _confirmationArgs.Confirm(SelectedRml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); });
- }
- catch (Exception ex)
- {
- Result = new ThreadLoadingResult()
- {
- FailedException = ex,
- };
-
- IsFinalizing = false;
-
- if (IsVisible)
- {
- InvokeUI(() =>
- {
- Accept();
- });
- }
- }
- }
-
- private void MachineOperator_ThreadLoadingCompleted(object sender, StartThreadLoadingResponse e)
- {
- Result = new ThreadLoadingResult()
- {
- IsCompleted = true
- };
-
- if (IsVisible)
- {
- InvokeUI(() =>
- {
- Accept();
- });
- }
- }
-
- private void MachineOperator_ThreadLoadingFailed(object sender, StartThreadLoadingResponse e)
- {
- Result = new ThreadLoadingResult()
- {
- FailedException = new Exception(e.ErrorReason),
- };
-
- if (IsVisible)
- {
- InvokeUI(() =>
- {
- Accept();
- });
- }
- }
-
- private void MachineOperator_ThreadLoadingStatusChanged(object sender, StartThreadLoadingResponse e)
- {
- Status = e;
-
- if (Status.State == ThreadLoadingState.Finalizing)
- {
- IsFinalizing = true;
- }
- }
-
- protected override void Cancel()
- {
- IsFinalizing = false;
- ClearEvents();
- base.Cancel();
- }
-
- protected override void Accept()
- {
- IsFinalizing = false;
- ClearEvents();
- base.Accept();
- }
-
- private void ClearEvents()
- {
- MachineProvider.MachineOperator.ThreadLoadingStatusChanged -= MachineOperator_ThreadLoadingStatusChanged;
- MachineProvider.MachineOperator.ThreadLoadingCompleted -= MachineOperator_ThreadLoadingCompleted;
- MachineProvider.MachineOperator.ThreadLoadingFailed -= MachineOperator_ThreadLoadingFailed;
- MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired -= MachineOperator_ThreadLoadingConfirmationRequired;
- }
- }
-}