aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-04-11 14:50:47 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-04-11 14:50:47 +0300
commitc400fa026cdb2bc5c1c5c25f5bfae37461e87cab (patch)
tree07c9d4027e82ecfdd3be47ecd2a79369210097f6 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
parentf33393bff08e57360953143e6bb93aa8eb03a852 (diff)
downloadTango-c400fa026cdb2bc5c1c5c25f5bfae37461e87cab.tar.gz
Tango-c400fa026cdb2bc5c1c5c25f5bfae37461e87cab.zip
Added Disconnect & Connect requests.
Fixed issue with Machine Connection View Scanning. Fixed issue with ShowModalDialog close event.. Added ConnectedMachineView. Added TransferRate for Adapters.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs36
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs125
2 files changed, 105 insertions, 56 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs
new file mode 100644
index 000000000..9f84cfb53
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs
@@ -0,0 +1,36 @@
+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.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.Common.StudioApplication;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.UI.ViewModels
+{
+ public class ConnectedMachineViewVM : DialogViewVM
+ {
+ private IStudioApplicationManager _applicationManager;
+ public IStudioApplicationManager ApplicationManager
+ {
+ get { return _applicationManager; }
+ set { _applicationManager = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand DisconnectCommand { get; set; }
+
+ public ConnectedMachineViewVM(IStudioApplicationManager application)
+ {
+ ApplicationManager = application;
+ DisconnectCommand = new RelayCommand(Disconnect);
+ }
+
+ private void Disconnect()
+ {
+ Accept();
+ }
+ }
+}
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..f78cc15be 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -384,70 +384,42 @@ 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)
{
@@ -458,15 +430,55 @@ namespace Tango.MachineStudio.UI.ViewModels
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(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);
}
}