aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs76
1 files changed, 74 insertions, 2 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 8a4d20b76..eeb11ffab 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
@@ -63,6 +63,7 @@ namespace Tango.PPC.UI.ViewModels
base.OnApplicationReady();
MachineProvider.MachineOperator.CartridgeValidationRequestReceived += MachineOperator_CartridgeValidationRequestReceived;
MachineProvider.MachineOperator.PowerUpStarted += MachineOperator_PowerUpStarted;
+ MachineProvider.MachineOperator.ThreadLoadingConfirmationRequired += MachineOperator_ThreadLoadingConfirmationRequired;
}
#region Event Handlers
@@ -120,7 +121,7 @@ namespace Tango.PPC.UI.ViewModels
rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildListAsync();
}
- var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LastPowerUpSelectedRmlGuid);
+ var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid);
vm = new PowerUpViewVM();
vm.Rmls = rmls;
@@ -165,7 +166,7 @@ namespace Tango.PPC.UI.ViewModels
LogManager.Log("Uploading process parameters...");
var r = MachineProvider.MachineOperator.UploadProcessParameters(processToLoad).Result;
- Settings.LastPowerUpSelectedRmlGuid = vm.IsSelectedRml ? vm.SelectedRml.Guid : null;
+ Settings.LoadedRmlGuid = vm.IsSelectedRml ? vm.SelectedRml.Guid : null;
Settings.Save();
}
}
@@ -177,6 +178,77 @@ namespace Tango.PPC.UI.ViewModels
});
}
+ private async void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e)
+ {
+ LogManager.Log("Thread loading confirmation detected, showing thread loading screen...");
+
+ if (!Settings.DisplayAutomaticThreadLoadingScreen)
+ {
+ LogManager.Log("Thread loading screen disabled. skipping...");
+ return;
+ }
+
+ ThreadLoadingViewVM vm;
+
+ try
+ {
+ LogManager.Log("Loading site rmls...");
+
+ List<Rml> rmls = new List<Rml>();
+
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync();
+ }
+
+ var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid);
+
+ vm = new ThreadLoadingViewVM(MachineProvider, e);
+ vm.Rmls = rmls;
+ vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error initializing thread loading screen.");
+ return;
+ }
+
+ InvokeUI(async () =>
+ {
+ await NotificationProvider.ShowDialog<ThreadLoadingViewVM>(vm);
+
+ LogManager.Log("Thread loading screen closed.");
+
+ if (!vm.DialogResult)
+ {
+ LogManager.Log("Thread loading screen aborted by user. No operation was performed.");
+ return;
+ }
+
+ try
+ {
+ if (vm.Result.IsCompleted)
+ {
+ await NotificationProvider.ShowSuccess("Thread loading completed successfully.");
+ }
+ else
+ {
+ await NotificationProvider.ShowError($"Thread loading failed due to the following reason:\n{vm.Result.FailedException.FlattenException()}");
+ }
+
+ if (vm.SelectedRml != null)
+ {
+ Settings.LoadedRmlGuid = vm.SelectedRml.Guid;
+ Settings.Save();
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error occurred after thread loading screen closed.");
+ }
+ });
+ }
+
#endregion
}
}