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-08-13 16:12:45 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-13 16:12:45 +0300
commit998cc8d4d91a7f85389cd0918f127257576c2c13 (patch)
tree368ecd76f09b8ff1c4156a554b799cd231c42119 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
parent4490b0a76d4188cb285d62b106e208803ceaa133 (diff)
downloadTango-998cc8d4d91a7f85389cd0918f127257576c2c13.tar.gz
Tango-998cc8d4d91a7f85389cd0918f127257576c2c13.zip
Logs and comments for PPC.UI !
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.cs82
1 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
index a5a8d9ac3..3b672411d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs
@@ -13,12 +13,21 @@ using Tango.PPC.Common.Navigation;
namespace Tango.PPC.UI.ViewModels
{
+ /// <summary>
+ /// Represents the external bridge view ViewModel.
+ /// </summary>
+ /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
[TangoCreateWhenRegistered]
public class ExternalBridgeViewVM : PPCViewModel
{
private bool _disconnecting;
+ #region Properties
+
private ExternalBridgeClientConnectedEventArgs _connection;
+ /// <summary>
+ /// Gets or sets the last client connection event arguments.
+ /// </summary>
public ExternalBridgeClientConnectedEventArgs Connection
{
get { return _connection; }
@@ -26,26 +35,58 @@ namespace Tango.PPC.UI.ViewModels
}
private User _user;
+ /// <summary>
+ /// Gets or sets the user connected user.
+ /// </summary>
public User User
{
get { return _user; }
- set { _user = value; RaisePropertyChangedAuto(); }
+ set { _user = value; RaisePropertyChangedAuto(); }
}
+ #endregion
+
+ #region Commands
+
+ /// <summary>
+ /// Gets or sets the close session command.
+ /// </summary>
public RelayCommand CloseSessionCommand { get; set; }
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ExternalBridgeViewVM"/> class.
+ /// </summary>
public ExternalBridgeViewVM()
{
- CloseSessionCommand = new RelayCommand(CloseSession,() => !_disconnecting);
+ CloseSessionCommand = new RelayCommand(CloseSession, () => !_disconnecting);
}
+ #endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Closes the current session.
+ /// </summary>
private void CloseSession()
{
+ LogManager.Log("Disconnecting current external bridge session.");
_disconnecting = true;
InvalidateRelayCommands();
ExternalBridgeService.DisconnectSession();
}
+ #endregion
+
+ #region Override Methods
+
+ /// <summary>
+ /// Called when the navigation system has navigated to this VM view.
+ /// </summary>
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
@@ -54,22 +95,43 @@ namespace Tango.PPC.UI.ViewModels
InvalidateRelayCommands();
}
+ /// <summary>
+ /// Called when the application has been started.
+ /// </summary>
public override void OnApplicationStarted()
{
- ExternalBridgeService.ConnectionRequest += ExternalBridgeService_ClientConnected;
+ ExternalBridgeService.ConnectionRequest += ExternalBridgeService_ConnectionRequest;
ExternalBridgeService.ClientDisconnected += ExternalBridgeService_ClientDisconnected;
}
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handles the <see cref="ExternalBridgeService.ClientDisconnected"/> event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e)
{
+ LogManager.Log("External bridge client disconnected. Navigating to home module...");
+
InvokeUI(() =>
{
NavigationManager.NavigateTo(NavigationView.HomeModule);
});
}
- private void ExternalBridgeService_ClientConnected(object sender, ExternalBridgeClientConnectedEventArgs e)
+ /// <summary>
+ /// Handles the <see cref="ExternalBridgeService.ConnectionRequest"/> event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="e">The <see cref="ExternalBridgeClientConnectedEventArgs"/> instance containing the event data.</param>
+ private void ExternalBridgeService_ConnectionRequest(object sender, ExternalBridgeClientConnectedEventArgs e)
{
+ LogManager.Log($"External bridge connection request received.\n{e.ToJsonString()}");
+
if (e.Request.Password == MachineProvider.Machine.ExternalBridgePassword)
{
e.Confirmed = true;
@@ -78,11 +140,23 @@ namespace Tango.PPC.UI.ViewModels
User = Adapter.Users.SingleOrDefault(x => x.Guid == e.Request.UserGuid);
+ if (User != null)
+ {
+ LogManager.Log($"External bridge connection user has been identified as {User.Contact.FullName}");
+ }
+
+ LogManager.Log("Navigating to external bridge view...");
InvokeUI(() =>
{
NavigationManager.NavigateTo(NavigationView.ExternalBridgeView, false);
});
}
+ else
+ {
+ LogManager.Log("Connection password did not match the machine external bridge password.");
+ }
}
+
+ #endregion
}
}