aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-04-16 09:27:48 +0300
committerAvi Levkovich <avi@twine-s.com>2018-04-16 09:27:48 +0300
commiteafb576fe1bf76898b9cc17671a89d1585e2c8e4 (patch)
treed833a983eb84c53b35b19a45af475aa3e88953c0 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
parentcf441513c1010eb4363e985b3b7af61a8503456e (diff)
parent53f93d7fd2d2aa4571bad6e93e0c519fce242753 (diff)
downloadTango-eafb576fe1bf76898b9cc17671a89d1585e2c8e4.tar.gz
Tango-eafb576fe1bf76898b9cc17671a89d1585e2c8e4.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
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.cs127
1 files changed, 70 insertions, 57 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 f9bffae29..8e451cdce 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -384,89 +384,101 @@ namespace Tango.MachineStudio.UI.ViewModels
/// </summary>
private void ConnectToMachine()
{
- _notificationProvider.ShowModalDialog<MachineConnectionViewVM>(async (x) =>
+ if (ApplicationManager.ConnectedMachine == null)
{
- if (x.SelectedMachine != null)
+ _notificationProvider.ShowModalDialog<MachineConnectionViewVM>(async (x) =>
{
- if (ApplicationManager.IsMachineConnected)
+ if (x.SelectedMachine != null)
{
- using (_notificationProvider.PushTaskItem("Disconnecting..."))
+ if (ApplicationManager.IsMachineConnected)
{
- await ApplicationManager.ConnectedMachine.Disconnect();
- await Task.Delay(1000);
- }
- }
-
- if (x.SelectedMachine.RequiresAuthentication)
- {
- _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) =>
- {
- using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "..."))
+ using (_notificationProvider.PushTaskItem("Disconnecting..."))
{
- try
- {
- await x.SelectedMachine.Connect();
-
- var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password);
- if (!authenticated)
- {
- _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine.");
- }
- else
- {
- ApplicationManager.ConnectedMachine = x.SelectedMachine;
- PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
- _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber));
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex);
- _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
- _notificationProvider.ShowError(ex.Message);
- }
-
- InvalidateRelayCommands();
+ await ApplicationManager.ConnectedMachine.Disconnect();
+ await Task.Delay(1000);
}
- });
- }
- else
- {
- _notificationProvider.ShowModalDialog<MachineSerialViewVM>(async (vm) =>
+ }
+
+ if (x.SelectedMachine.RequiresAuthentication)
{
- if (vm.SelectedMachine != null)
+ _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) =>
{
- using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
+ using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "..."))
{
try
{
await x.SelectedMachine.Connect();
- x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber;
- ApplicationManager.ConnectedMachine = x.SelectedMachine;
- PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
- _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber));
- SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber;
- SettingsManager.SaveDefaultSettings();
+ var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password);
+ if (!authenticated)
+ {
+ _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine.");
+ }
+ else
+ {
+ ApplicationManager.ConnectedMachine = x.SelectedMachine;
+ PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
+ _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber));
+ }
}
catch (Exception ex)
{
LogManager.Log(ex);
_eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
- _notificationProvider.ShowError(ex.Message);
+ _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message);
}
InvalidateRelayCommands();
}
- }
- });
+ });
+ }
+ else
+ {
+ _notificationProvider.ShowModalDialog<MachineSerialViewVM>(async (vm) =>
+ {
+ if (vm.SelectedMachine != null)
+ {
+ using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
+ {
+ try
+ {
+ await x.SelectedMachine.Connect();
+ x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber;
+ ApplicationManager.ConnectedMachine = x.SelectedMachine;
+
+ PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
+ _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber));
+ SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber;
+ SettingsManager.SaveDefaultSettings();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex);
+ _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
+ _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message);
+ }
+
+ InvalidateRelayCommands();
+ }
+ }
+ });
+ }
+
+ InvalidateRelayCommands();
}
InvalidateRelayCommands();
- }
+ });
+ }
+ else
+ {
+ _notificationProvider.ShowModalDialog<ConnectedMachineViewVM>((x) =>
+ {
+ DisconnectFromMachine();
+ });
+ }
- InvalidateRelayCommands();
- });
+ InvalidateRelayCommands();
}
/// <summary>
@@ -581,6 +593,7 @@ namespace Tango.MachineStudio.UI.ViewModels
{
if (ApplicationManager.ConnectedMachine != null && machineEvent.EventType.Resolvable)
{
+ _eventLogger.Log(String.Format("Event '{0}' resolved by user.", machineEvent.EventType.Name));
await ApplicationManager.ConnectedMachine.ResolveEvent((PMR.Diagnostics.EventType)machineEvent.Type);
}
}