diff options
Diffstat (limited to 'Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs index e671bcfe5..b4031783c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs @@ -11,9 +11,11 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media.Imaging; using Tango.Core.Commands; +using Tango.Core.DI; using Tango.Core.Threading; using Tango.FSE.Common; using Tango.FSE.Common.Notifications; +using Tango.FSE.Common.RemoteActions; using Tango.FSE.Common.RemoteDesktop; using Tango.RemoteDesktop.Frames; using Tango.RemoteDesktop.Network; @@ -72,6 +74,9 @@ namespace Tango.FSE.PPCConsole.ViewModels set { _touchMode = value; RaisePropertyChangedAuto(); } } + [TangoInject] + public IRemoteActionsProvider RemoteActionsProvider { get; set; } + #endregion #region Commands @@ -111,6 +116,11 @@ namespace Tango.FSE.PPCConsole.ViewModels /// </summary> public RelayCommand StopRecordingCommand { get; set; } + /// <summary> + /// Gets or sets the restart application command. + /// </summary> + public RelayCommand RestartApplicationCommand { get; set; } + #endregion #region Constructors @@ -131,6 +141,7 @@ namespace Tango.FSE.PPCConsole.ViewModels TakeSnapshotCommand = new RelayCommand(TakeSnapshot); StartRecordingCommand = new RelayCommand(StartRecording); StopRecordingCommand = new RelayCommand(StopRecording, () => IsRecording); + RestartApplicationCommand = new RelayCommand(RestartApplication); } #endregion @@ -323,6 +334,44 @@ namespace Tango.FSE.PPCConsole.ViewModels RemoteDesktopProvider.SendCommand(RemoteDesktopCommand.HideAndOpenShell); } + private async void RestartApplication() + { + if (await NotificationProvider.ShowWarningQuestion("Are you sure you want to restart the remote application?", "RESTART")) + { + bool restarted = false; + + try + { + try + { + await RemoteDesktopProvider.EndSession(); + } + catch { } + + await Task.Factory.StartNew(RemoteActionsProvider.RestartApplication); + restarted = true; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error restarting the remote application."); + } + + if (restarted) + { + try + { + await MachineProvider.DisconnectAndWaitForReconnection(TimeSpan.FromSeconds(20), TimeSpan.FromMinutes(1), "The remote PPC is now restarting..."); + + if (MachineProvider.IsConnected) + { + StartRemoteDesktop(); + } + } + catch { } + } + } + } + #endregion #region Video Recording |
