aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.RemoteDesktop
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-03-03 18:56:58 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-03-03 18:56:58 +0200
commitc38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad (patch)
tree20cc57b06f4260b6f86fdaca04129e1a8ace53cd /Software/Visual_Studio/Tango.RemoteDesktop
parent1b0bdf6f8148e9cc4e7e07e41e9e2d75039c1349 (diff)
downloadTango-c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad.tar.gz
Tango-c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad.zip
Machine Studio v4.1.2
PPC v1.1.5 Added BYPASS_ROCKERS to SQLExaminer config. Started integrating FSE Remote/Console To PPC. Added support for generic continuous request.
Diffstat (limited to 'Software/Visual_Studio/Tango.RemoteDesktop')
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Clipping/BitmapCliper.cs20
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Frame.cs10
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Network/RemoteDesktopPacket.cs26
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionRequest.cs16
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionResponse.cs25
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs43
-rw-r--r--Software/Visual_Studio/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj3
7 files changed, 114 insertions, 29 deletions
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Clipping/BitmapCliper.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Clipping/BitmapCliper.cs
index 4f93eeb66..8866f6d9a 100644
--- a/Software/Visual_Studio/Tango.RemoteDesktop/Clipping/BitmapCliper.cs
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Clipping/BitmapCliper.cs
@@ -30,8 +30,8 @@ namespace Tango.RemoteDesktop.Clipping
//determine top
for (int i = 0; i < rgbValues.Length; i++)
{
- int color = rgbValues[i] & 0x00ffffff;
- if (color != 0x00ffffff)
+ int color = rgbValues[i] & 0xffffff;
+ if (color != 0x0)
{
int r = i / bd.Width;
int c = i % bd.Width;
@@ -53,8 +53,8 @@ namespace Tango.RemoteDesktop.Clipping
//determine bottom
for (int i = rgbValues.Length - 1; i >= 0; i--)
{
- int color = rgbValues[i] & 0x00ffffff;
- if (color != 0x00ffffff)
+ int color = rgbValues[i] & 0xffffff;
+ if (color != 0x0)
{
int r = i / bd.Width;
int c = i % bd.Width;
@@ -79,8 +79,8 @@ namespace Tango.RemoteDesktop.Clipping
//determine left
for (int c = 0; c < left; c++)
{
- int color = rgbValues[r * bd.Width + c] & 0x00ffffff;
- if (color != 0x00ffffff)
+ int color = rgbValues[r * bd.Width + c] & 0xffffff;
+ if (color != 0x0)
{
if (left > c)
{
@@ -93,8 +93,8 @@ namespace Tango.RemoteDesktop.Clipping
//determine right
for (int c = bd.Width - 1; c > right; c--)
{
- int color = rgbValues[r * bd.Width + c] & 0x00ffffff;
- if (color != 0x00ffffff)
+ int color = rgbValues[r * bd.Width + c] & 0xffffff;
+ if (color != 0x0)
{
if (right < c)
{
@@ -128,9 +128,7 @@ namespace Tango.RemoteDesktop.Clipping
//create new image
Bitmap newImage = new Bitmap(width, height, PixelFormat.Format32bppArgb);
- BitmapData nbd
- = newImage.LockBits(new Rectangle(0, 0, width, height),
- ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
+ BitmapData nbd = newImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(imgData, 0, nbd.Scan0, imgData.Length);
newImage.UnlockBits(nbd);
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Frame.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Frame.cs
index 93f38bac0..e871d5da2 100644
--- a/Software/Visual_Studio/Tango.RemoteDesktop/Frame.cs
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Frame.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
+using Tango.RemoteDesktop.Frames;
namespace Tango.RemoteDesktop
{
@@ -45,6 +46,15 @@ namespace Tango.RemoteDesktop
}
/// <summary>
+ /// Applies this frame onto an existing raster frame.
+ /// </summary>
+ /// <param name="frame">The frame.</param>
+ public virtual void Apply(RasterFrame frame)
+ {
+ Apply(frame.ToBitmap());
+ }
+
+ /// <summary>
/// Returns a WPF BitmapSource representing the frame.
/// </summary>
/// <returns></returns>
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Network/RemoteDesktopPacket.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Network/RemoteDesktopPacket.cs
new file mode 100644
index 000000000..28f890a9a
--- /dev/null
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Network/RemoteDesktopPacket.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.RemoteDesktop.Network
+{
+ public class RemoteDesktopPacket
+ {
+ /// <summary>
+ /// Gets or sets the bitmap byte array.
+ /// </summary>
+ public byte[] Bitmap { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the <see cref="Bitmap"/> is a partial bitmap that needs to be applied over the previous one.
+ /// </summary>
+ public bool IsPartial { get; set; }
+
+ /// <summary>
+ /// Gets or sets the region on the previous bitmap that needs to be applied with this packet bitmap.
+ /// </summary>
+ public CaptureRegion PartialRegion { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionRequest.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionRequest.cs
new file mode 100644
index 000000000..f6d572b83
--- /dev/null
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionRequest.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.RemoteDesktop.Network
+{
+ /// <summary>
+ /// Represents a message for starting the remote desktop session.
+ /// </summary>
+ public class StartRemoteDesktopSessionRequest
+ {
+
+ }
+}
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionResponse.cs b/Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionResponse.cs
new file mode 100644
index 000000000..2c1d0e635
--- /dev/null
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Network/StartRemoteDesktopSessionResponse.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.RemoteDesktop.Network
+{
+ /// <summary>
+ /// Represents a continuous message for updating about remote desktop changes.
+ /// </summary>
+ public class StartRemoteDesktopSessionResponse
+ {
+ /// <summary>
+ /// Gets or sets the remote desktop packet.
+ /// </summary>
+ public RemoteDesktopPacket Packet { get; set; }
+
+ /// <summary>
+ /// Capture frame rate reported by the host.
+ /// Will be sent only on the first response!
+ /// </summary>
+ public int FrameRate { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs
index 1d7b4d7d4..17f54369c 100644
--- a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureEngine.cs
@@ -136,37 +136,44 @@ namespace Tango.RemoteDesktop
{
watch.Restart();
- var bitmap = CaptureMethod.GetDesktopBitmap(CaptureRegion);
-
- if (CaptureCursor)
+ try
{
- using (Graphics g = Graphics.FromImage(bitmap))
+ var bitmap = CaptureMethod.GetDesktopBitmap(CaptureRegion);
+
+ if (CaptureCursor)
{
- CursorUtils.ApplyCursor(g, bitmap, CaptureRegion.Left, CaptureRegion.Top);
+ using (Graphics g = Graphics.FromImage(bitmap))
+ {
+ CursorUtils.ApplyCursor(g, bitmap, CaptureRegion.Left, CaptureRegion.Top);
+ }
}
- }
- if (EnableComparer && Comparer != null)
- {
- if (_previousBitmap == null)
+ if (EnableComparer && Comparer != null)
{
- _previousBitmap = bitmap.Clone() as Bitmap;
- OnFrameReceived(bitmap, null, 0);
+ if (_previousBitmap == null)
+ {
+ _previousBitmap = bitmap.Clone() as Bitmap;
+ OnFrameReceived(bitmap, null, 0);
+ }
+ else
+ {
+ var result = Comparer.CreateDifference(_previousBitmap, bitmap);
+ _previousBitmap.Dispose();
+ _previousBitmap = bitmap.Clone() as Bitmap;
+ OnFrameReceived(bitmap, result.Frame, result.DifferenceCount);
+ }
}
else
{
- var result = Comparer.CreateDifference(_previousBitmap, bitmap);
- _previousBitmap.Dispose();
- _previousBitmap = bitmap.Clone() as Bitmap;
- OnFrameReceived(bitmap, result.Frame, result.DifferenceCount);
+ OnFrameReceived(bitmap, null, 0);
}
}
- else
+ catch (Exception ex)
{
- OnFrameReceived(bitmap, null, 0);
+ Debug.WriteLine($"Error in screen capture engine: {ex.Message}");
}
- int delay = Math.Max(5, (FrameRate * 10) - (int)watch.ElapsedMilliseconds);
+ int delay = Math.Max(5, (1000 / FrameRate) - (int)watch.ElapsedMilliseconds);
Thread.Sleep(delay);
}
}
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj b/Software/Visual_Studio/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj
index 06abb0040..87674b42b 100644
--- a/Software/Visual_Studio/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj
+++ b/Software/Visual_Studio/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj
@@ -79,6 +79,9 @@
<Compile Include="Engines\VectorScreenCaptureEngine.cs" />
<Compile Include="Frames\VectorFrameColor.cs" />
<Compile Include="IScreenCaptureEngine.cs" />
+ <Compile Include="Network\RemoteDesktopPacket.cs" />
+ <Compile Include="Network\StartRemoteDesktopSessionRequest.cs" />
+ <Compile Include="Network\StartRemoteDesktopSessionResponse.cs" />
<Compile Include="Quantization\ColorBgra.cs" />
<Compile Include="Quantization\OctreeQuantizer.cs" />
<Compile Include="Quantization\PaletteTable.cs" />