From aff00af76242117e3991b0ee526df905a63debce Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 1 Jun 2020 02:06:40 +0300 Subject: Remote Cursor. Cursor Visibility. Mouse Scroll. PPC notification bar workaround. --- .../Properties/Resources.Designer.cs | 22 +++++++++++- .../PPC/Tango.PPC.Common/Properties/Resources.resx | 20 ++++++++--- .../RemoteDesktop/DefaultRemoteDesktopService.cs | 40 ++++++++++++++++++++- .../PPC/Tango.PPC.Common/Resources/finger3.png | Bin 0 -> 1005 bytes .../PPC/Tango.PPC.Common/Resources/tap.png | Bin 0 -> 1316 bytes .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 8 ++++- 6 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/finger3.png create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/tap.png (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.Designer.cs index 60e2bdb01..30828af87 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.Designer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Tango.PPC.Common.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -59,5 +59,25 @@ namespace Tango.PPC.Common.Properties { resourceCulture = value; } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap finger3 { + get { + object obj = ResourceManager.GetObject("finger3", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap tap { + get { + object obj = ResourceManager.GetObject("tap", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.resx b/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.resx index af7dbebba..ca6197f54 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.resx +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,16 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\finger3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\tap.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file 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; /// /// Gets or sets a value indicating whether this 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 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().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().ToArray(30) + Bitmap = e.Frame.ToEncoder().ToArray(30), + MousePosition = mousePosition, + CursorVisible = _drawCursor }; } else @@ -413,6 +449,8 @@ namespace Tango.PPC.Common.RemoteDesktop Bitmap = diffFrame.ToEncoder().ToArray(), IsPartial = true, PartialRegion = new CaptureRegion(diffFrame.Left, diffFrame.Top, diffFrame.Width, diffFrame.Height), + MousePosition = mousePosition, + CursorVisible = _drawCursor }; diffFrame.Dispose(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/finger3.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/finger3.png new file mode 100644 index 000000000..c0a6ce9cd Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/finger3.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/tap.png b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/tap.png new file mode 100644 index 000000000..4fa679b81 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/tap.png differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 47b5e310b..6fc24e22a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -458,6 +458,12 @@ + + + + + + @@ -468,7 +474,7 @@ - + \ No newline at end of file -- cgit v1.3.1