diff options
| author | Roy <roy.mail.net@gmail.com> | 2017-12-26 21:16:15 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2017-12-26 21:16:15 +0200 |
| commit | 2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc (patch) | |
| tree | a21ff27fff08876e835df82c5242def1f0d09c17 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels | |
| parent | 6450fc175114a6f8d0b75cb21386d1bb0c902711 (diff) | |
| download | Tango-2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc.tar.gz Tango-2ea2bb5bcd96045f1bd6cb4c3d8b8416dbaa05dc.zip | |
MERGE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
3 files changed, 53 insertions, 18 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 6505bcf88..f213af0d4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -31,7 +31,6 @@ namespace Tango.MachineStudio.UI.ViewModels { StaThreadHelper.StartStaThread(() => { - Thread.Sleep(1000); try { ObservablesEntitiesAdapter.Instance.Initialize(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs new file mode 100644 index 000000000..a6ee9ee2a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class MachineLoginViewVM : DialogViewVM + { + public String Password { get; set; } + + public RelayCommand<String> LoginCommand { get; set; } + + public RelayCommand CancelCommand { get; set; } + + public MachineLoginViewVM() + { + LoginCommand = new RelayCommand<string>(Login); + CancelCommand = new RelayCommand(Cancel); + } + + private void Login(string password) + { + Password = password; + 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 6c44c8480..92c0afa21 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -124,33 +124,38 @@ namespace Tango.MachineStudio.UI.ViewModels private void ConnectToMachine() { - _notificationProvider.ShowModalDialog<MachineConnectionViewVM>(async (x) => + _notificationProvider.ShowModalDialog<MachineConnectionViewVM>((x) => { if (x.SelectedMachine != null) { - using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "...")) + _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) => { - try + using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "...")) { - await x.SelectedMachine.Connect(); - var authenticated = await x.SelectedMachine.Authenticate(); - if (!authenticated) + try { - _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); + await x.SelectedMachine.Connect(); + var authenticated = await x.SelectedMachine.Authenticate(login.Password); + if (!authenticated) + { + _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); + } + else + { + ApplicationManager.ConnectedMachine = x.SelectedMachine; + } } - else + catch (Exception ex) { - ApplicationManager.ConnectedMachine = x.SelectedMachine; - var response = await x.SelectedMachine.SendRequest<CalculateRequest, CalculateResponse>(new CalculateRequest() { A = 10, B = 5 }); - _notificationProvider.ShowInfo(response.ToString()); + LogManager.Log(ex); + _notificationProvider.ShowError(ex.Message); } + + InvalidateRelayCommands(); } - catch (Exception ex) - { - LogManager.Log(ex); - _notificationProvider.ShowError(ex.Message); - } - } + }); + + InvalidateRelayCommands(); } InvalidateRelayCommands(); |
