aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs
diff options
context:
space:
mode:
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.cs108
1 files changed, 54 insertions, 54 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 eb5d57447..c8365af3b 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
@@ -6,10 +6,13 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
using System.Windows.Media.Imaging;
using Tango.Core.Commands;
using Tango.Core.Threading;
using Tango.FSE.Common;
+using Tango.FSE.Common.RemoteDesktop;
using Tango.RemoteDesktop.Frames;
using Tango.RemoteDesktop.Network;
@@ -17,8 +20,6 @@ namespace Tango.FSE.PPCConsole.ViewModels
{
public class RemoteDesktopViewVM : FSEViewModel
{
- private RasterFrame _currentFrame;
-
private BitmapSource _source;
public BitmapSource Source
{
@@ -31,7 +32,7 @@ namespace Tango.FSE.PPCConsole.ViewModels
public RemoteDesktopViewVM()
{
- StartCommand = new RelayCommand(StartRemoteDesktop, () => MachineProvider.IsConnected);
+ StartCommand = new RelayCommand(StartRemoteDesktop);
StopCommand = new RelayCommand(StopRemoteDesktop);
}
@@ -39,71 +40,70 @@ namespace Tango.FSE.PPCConsole.ViewModels
{
base.OnApplicationStarted();
- MachineProvider.MachineConnected += (_, __) => InvalidateRelayCommands();
- MachineProvider.MachineDisconnected += (_, __) => InvalidateRelayCommands();
+ RemoteDesktopProvider.FrameReceived += RemoteDesktopProvider_FrameReceived;
}
- private void StartRemoteDesktop()
+ private async void StartRemoteDesktop()
{
- SequencerThread<StartRemoteDesktopSessionResponse> sequencer = null;
- sequencer = new SequencerThread<StartRemoteDesktopSessionResponse>((response) =>
+ try
+ {
+ await RemoteDesktopProvider.StartSession();
+ }
+ catch (Exception ex)
{
- if (response.Packet == null)
- {
- sequencer.FrameRate = 1000 / response.FrameRate;
- return; //Returned just to notice that there was no timeout..
- }
+ await NotificationProvider.ShowError($"Error starting remote desktop session.\n{ex.FlattenMessage()}");
+ }
+ }
- try
- {
- if (!response.Packet.IsPartial)
- {
- using (MemoryStream ms = new MemoryStream(response.Packet.Bitmap))
- {
- if (_currentFrame != null)
- {
- _currentFrame.Dispose();
- }
+ private async void StopRemoteDesktop()
+ {
+ try
+ {
+ await RemoteDesktopProvider.EndSession();
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Error stopping remote desktop session.\n{ex.FlattenMessage()}");
+ }
+ }
- _currentFrame = new RasterFrame(new Bitmap(ms));
- }
- }
- else
- {
- using (MemoryStream ms = new MemoryStream(response.Packet.Bitmap))
- {
- var diffFrame = new RasterFrame(new Bitmap(ms), response.Packet.PartialRegion.Left, response.Packet.PartialRegion.Top);
- diffFrame.Apply(_currentFrame);
- diffFrame.Dispose();
- }
- }
+ private void RemoteDesktopProvider_FrameReceived(object sender, DesktopFrameReceivedEventArgs e)
+ {
+ Source = e.Source;
+ }
- Source = _currentFrame.ToBitmapSource();
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"Error on remote desktop packet received: {ex.Message}");
- }
- });
+ #region Mouse & Keyboard Handlers From View
- sequencer.Start();
+ public void OnMouseDown(MouseButton changedButton, System.Windows.Point point, System.Windows.Size size)
+ {
+ RemoteDesktopProvider.MouseDown(changedButton, point, size);
+ }
- MachineProvider.MachineOperator.SendGenericContinuousRequest<StartRemoteDesktopSessionRequest, StartRemoteDesktopSessionResponse>(new StartRemoteDesktopSessionRequest() { }, new Transport.TransportContinuousRequestConfig()
- {
- ContinuousTimeout = TimeSpan.FromSeconds(30),
- }).Subscribe((response) =>
- {
- sequencer.Push(response);
+ public void OnMouseUp(MouseButton changedButton, System.Windows.Point point, System.Windows.Size size)
+ {
+ RemoteDesktopProvider.MouseUp(changedButton, point, size);
+ }
- }, (ex) =>
- {
- Debug.WriteLine(ex);
- }, () => { });
+ public void OnMouseMove(System.Windows.Point point, System.Windows.Size size)
+ {
+ //RemoteDesktopProvider.MouseMove(point, size);
}
- private void StopRemoteDesktop()
+ public void OnMouseDoubleClick(MouseButton changedButton, System.Windows.Point point, System.Windows.Size size)
{
+ RemoteDesktopProvider.MouseDoubleClick(changedButton, point, size);
+ }
+ public void OnKeyboardDown(Key key, bool ctrlDown, bool shitDown, bool altDown)
+ {
+ throw new NotImplementedException();
}
+
+ public void OnKeyboardUp(Key key, bool ctrlDown, bool shitDown, bool altDown)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
}
}