aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs81
1 files changed, 49 insertions, 32 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index 6ddfee545..4f8c8a9b1 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -58,8 +58,9 @@ namespace Tango.MachineStudio.UI.ViewModels
private IEventLogger _eventLogger;
private MachineStudioSettings _settings;
private MachineStudioWebClient _machineStudioWebClient;
- private IExternalBridgeSecureClient _reconnectionMachine;
+ private IExternalBridgeClient _reconnectionMachine;
private MachineLoginViewVM _reconnectionMachineConfig;
+ private bool _lastUploadHardwareConfigLocal;
/// <summary>
/// Gets or sets the current loaded module.
@@ -350,9 +351,16 @@ namespace Tango.MachineStudio.UI.ViewModels
ApplicationManager.ReconnectionRequired += ApplicationManager_ReconnectionRequired;
}
- private void ApplicationManager_ReconnectionRequired(object sender, EventArgs e)
+ private async void ApplicationManager_ReconnectionRequired(object sender, EventArgs e)
{
- ConnectToMachineSecure(_reconnectionMachine, _reconnectionMachineConfig);
+ if (_reconnectionMachine is IExternalBridgeSecureClient client)
+ {
+ ConnectToMachineSecure(client, _reconnectionMachineConfig);
+ }
+ else
+ {
+ await ConnectToMachineLocal(_reconnectionMachine, _reconnectionMachine.Machine, _lastUploadHardwareConfigLocal);
+ }
}
private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e)
@@ -486,41 +494,15 @@ namespace Tango.MachineStudio.UI.ViewModels
{
if (vm.SelectedMachine != null)
{
- using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
- {
- try
- {
- await x.SelectedMachine.Connect();
- x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber;
- ApplicationManager.SetConnectedMachine(x.SelectedMachine);
-
- PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
- _settings.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber;
- _settings.Save();
-
- if (x.UploadHardwareConfiguration)
- {
- UploadHardwareConfiguration(false);
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex);
-
- _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message);
-
- }
-
- InvalidateRelayCommands();
- }
+ await ConnectToMachineLocal(x.SelectedMachine, vm.SelectedMachine, x.UploadHardwareConfiguration);
}
});
}
- InvalidateRelayCommands();
+ base.InvalidateRelayCommands();
}
- InvalidateRelayCommands();
+ base.InvalidateRelayCommands();
});
}
else
@@ -585,6 +567,41 @@ namespace Tango.MachineStudio.UI.ViewModels
InvalidateRelayCommands();
}
+ private async Task ConnectToMachineLocal(IExternalBridgeClient client, Machine machine, bool uploadHardwareConfig)
+ {
+ using (NotificationProvider.PushTaskItem("Connecting to " + client.ToString() + "..."))
+ {
+ try
+ {
+ _reconnectionMachine = client;
+
+ await client.Connect();
+ client.SerialNumber = machine.SerialNumber;
+ ApplicationManager.SetConnectedMachine(client);
+
+ PostMessage(new MachineConnectionChangedMessage() { Machine = client });
+ _settings.LastVirtualMachineSerialNumber = machine.SerialNumber;
+ _settings.Save();
+
+ _lastUploadHardwareConfigLocal = uploadHardwareConfig;
+
+ if (uploadHardwareConfig)
+ {
+ UploadHardwareConfiguration(false);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex);
+
+ _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message);
+
+ }
+
+ InvalidateRelayCommands();
+ }
+ }
+
private async void ConnectToMachineSecure(IExternalBridgeSecureClient machine, MachineLoginViewVM config)
{
using (NotificationProvider.PushTaskItem("Connecting to machine " + machine.ToString() + "..."))