aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-30 18:16:30 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-30 18:16:30 +0300
commitead172c9292326266b2c1622f058df5e2039bd05 (patch)
tree13c73297dec8e2507544fd5b0f2194750c942922 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
parentba5a7741072abbda41e674fe19308a9b505b49f8 (diff)
downloadTango-ead172c9292326266b2c1622f058df5e2039bd05.tar.gz
Tango-ead172c9292326266b2c1622f058df5e2039bd05.zip
Working on PPC Machine Studio External Bridge !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs63
1 files changed, 57 insertions, 6 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
index f0b6bbfdf..3c348c796 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
@@ -3,23 +3,74 @@ 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
{
- /// <summary>
- /// Gets or sets the external bridge service.
- /// </summary>
- [TangoInject]
- public IPPCExternalBridgeService ExternalBridgeService { get; set; }
+ 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()
{
- //throw new NotImplementedException();
+ 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);
+ });
+ }
}
}
}