diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-07-31 10:06:51 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-07-31 10:06:51 +0300 |
| commit | b6b2f9ad4c96deface6763adbb2ac533e9706d1b (patch) | |
| tree | 732a7ce2f629ab4cd9a1bfc1bec79adf97185025 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels | |
| parent | 90b65a54cd28ee8b0d908c86795a7096c4073e83 (diff) | |
| parent | c728eba7cf217972c47e0a65afcb1975f6d6f6f1 (diff) | |
| download | Tango-b6b2f9ad4c96deface6763adbb2ac533e9706d1b.tar.gz Tango-b6b2f9ad4c96deface6763adbb2ac533e9706d1b.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs | 76 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 6 |
2 files changed, 78 insertions, 4 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs new file mode 100644 index 000000000..3c348c796 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs @@ -0,0 +1,76 @@ +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.Core.DI; +using Tango.Integration.ExternalBridge; +using Tango.PPC.Common; +using Tango.PPC.Common.ExternalBridge; +using Tango.PPC.Common.Navigation; + +namespace Tango.PPC.UI.ViewModels +{ + [TangoCreateWhenRegistered] + public class ExternalBridgeViewVM : PPCViewModel + { + private ExternalBridgeClientConnectedEventArgs _connection; + public ExternalBridgeClientConnectedEventArgs Connection + { + get { return _connection; } + set { _connection = value; RaisePropertyChangedAuto(); } + } + + private User _user; + public User User + { + get { return _user; } + set { _user = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand CloseSessionCommand { get; set; } + + public ExternalBridgeViewVM() + { + CloseSessionCommand = new RelayCommand(CloseSession); + } + + private void CloseSession() + { + ExternalBridgeService.DisconnectSession(); + } + + public override void OnApplicationStarted() + { + ExternalBridgeService.ClientConnected += ExternalBridgeService_ClientConnected; + ExternalBridgeService.ClientDisconnected += ExternalBridgeService_ClientDisconnected; + } + + private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e) + { + InvokeUI(() => + { + NavigationManager.NavigateTo(NavigationView.HomeModule); + }); + } + + private void ExternalBridgeService_ClientConnected(object sender, ExternalBridgeClientConnectedEventArgs e) + { + if (e.Request.Password == MachineProvider.Machine.ExternalBridgePassword) + { + e.Confirmed = true; + + Connection = e; + + User = Adapter.Users.SingleOrDefault(x => x.Guid == e.Request.UserGuid); + + InvokeUI(() => + { + NavigationManager.NavigateTo(NavigationView.ExternalBridgeView, false); + }); + } + } + } +} 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 faac9ad16..67d885685 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -4,9 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.DI; +using Tango.Integration.ExternalBridge; using Tango.PPC.Common; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; @@ -20,12 +22,8 @@ namespace Tango.PPC.UI.ViewModels /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class MainViewVM : PPCViewModel { - /// <summary> - /// Called when the application has been started. - /// </summary> public override void OnApplicationStarted() { - } } } |
