aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-06-01 02:06:40 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-06-01 02:06:40 +0300
commitaff00af76242117e3991b0ee526df905a63debce (patch)
tree96bc51983c314a6c08cc7f804c599a28f23efd8a /Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
parent862ee0839083ca350125d48841ce7427d5a578d9 (diff)
downloadTango-aff00af76242117e3991b0ee526df905a63debce.tar.gz
Tango-aff00af76242117e3991b0ee526df905a63debce.zip
Remote Cursor.
Cursor Visibility. Mouse Scroll. PPC notification bar workaround.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs40
1 files changed, 39 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
index b118dcdda..9a815df11 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Security.Authentication;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Input;
using Tango.Core;
using Tango.Core.DI;
@@ -38,6 +39,9 @@ namespace Tango.PPC.Common.RemoteDesktop
private JsonSerializerSettings _jsonSettings;
private IOperationSystemManager _osManager;
private IPPCApplicationManager _appManager;
+ private bool _drawCursor;
+ private bool _isMouseDown;
+ private bool _ensureMouseDown;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="IPPCService" /> is enabled.
@@ -137,6 +141,17 @@ namespace Tango.PPC.Common.RemoteDesktop
//}
}
+ mainWindow.PreviewMouseDown += (_, __) =>
+ {
+ _isMouseDown = true;
+ _ensureMouseDown = true;
+ };
+
+ mainWindow.PreviewMouseUp += (_, __) =>
+ {
+ _isMouseDown = false;
+ };
+
_engine.Comparer.MaxDifferencesThrow = _engine.CaptureRegion.Width * _engine.CaptureRegion.Height / 2;
}
@@ -300,6 +315,10 @@ namespace Tango.PPC.Common.RemoteDesktop
{
MouseController.DoubleClick();
}
+ else if (request.EventType == MouseEventType.Scroll)
+ {
+ MouseController.Scroll(request.ScrollDelta);
+ }
if (receiver != null)
{
@@ -339,8 +358,21 @@ namespace Tango.PPC.Common.RemoteDesktop
await receiver.SendGenericResponse(new RemoteDesktopCommandResponse(), token);
}
+ [ExternalBridgeRequestHandlerMethod(typeof(SetCursorVisibilityRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnSetCursorVisibilityRequest(SetCursorVisibilityRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ _drawCursor = request.Visible;
+ await receiver.SendGenericResponse(new SetCursorVisibilityResponse(), token);
+ }
+
private async void _engine_FrameReceived(object sender, ScreenCaptureFrameReceivedEventArgs<RasterFrame> e)
{
+ if (_drawCursor)
+ {
+ e.Frame.DrawImage((_isMouseDown || _ensureMouseDown) ? Properties.Resources.tap : Properties.Resources.finger3, new System.Drawing.Point(System.Windows.Forms.Cursor.Position.X - 5, System.Windows.Forms.Cursor.Position.Y - 4));
+ _ensureMouseDown = false;
+ }
+
_initialPacket = new RemoteDesktopPacket()
{
Bitmap = e.Frame.ToEncoder<PngEncoder>().ToArray(),
@@ -396,11 +428,15 @@ namespace Tango.PPC.Common.RemoteDesktop
{
RemoteDesktopPacket packet = null;
+ Point mousePosition = new Point(System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y);
+
if (!e.Frame.DifferenceAvailable)
{
packet = new RemoteDesktopPacket()
{
- Bitmap = e.Frame.ToEncoder<TurboJpegEncoder>().ToArray(30)
+ Bitmap = e.Frame.ToEncoder<TurboJpegEncoder>().ToArray(30),
+ MousePosition = mousePosition,
+ CursorVisible = _drawCursor
};
}
else
@@ -413,6 +449,8 @@ namespace Tango.PPC.Common.RemoteDesktop
Bitmap = diffFrame.ToEncoder<PngEncoder>().ToArray(),
IsPartial = true,
PartialRegion = new CaptureRegion(diffFrame.Left, diffFrame.Top, diffFrame.Width, diffFrame.Height),
+ MousePosition = mousePosition,
+ CursorVisible = _drawCursor
};
diffFrame.Dispose();