From b7c007b5fe37c6da247ebc82292cb40d9943f812 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Thu, 28 Mar 2019 06:05:50 -0700 Subject: [PATCH] Change ICapturer's signature. --- Remotely_ScreenCast.Core/Capture/ICapturer.cs | 8 ++++---- .../Capture/ScreenCaster.cs | 4 ++-- .../Capture/X11Capture.cs | 18 +++++++++++++++--- Remotely_ScreenCast.Linux/Program.cs | 1 + .../Capture/BitBltCapture.cs | 16 +++++++++++++--- Remotely_ScreenCast.Win/Capture/DXCapture.cs | 15 ++++++++++++--- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Remotely_ScreenCast.Core/Capture/ICapturer.cs b/Remotely_ScreenCast.Core/Capture/ICapturer.cs index 56126725..96ef089b 100644 --- a/Remotely_ScreenCast.Core/Capture/ICapturer.cs +++ b/Remotely_ScreenCast.Core/Capture/ICapturer.cs @@ -8,16 +8,16 @@ using System.Threading.Tasks; namespace Remotely_ScreenCast.Core.Capture { public interface ICapturer : IDisposable - { + { bool CaptureFullscreen { get; set; } Bitmap CurrentFrame { get; set; } Rectangle CurrentScreenBounds { get; } Bitmap PreviousFrame { get; set; } EventHandler ScreenChanged { get; set; } int SelectedScreen { get; set; } - int ScreenCount { get; set; } - double VirtualScreenHeight { get; set; } - double VirtualScreenWidth { get; set; } + int GetScreenCount(); + double GetVirtualScreenHeight(); + double GetVirtualScreenWidth(); void Capture(); void Init(); diff --git a/Remotely_ScreenCast.Core/Capture/ScreenCaster.cs b/Remotely_ScreenCast.Core/Capture/ScreenCaster.cs index be080ec7..c257804c 100644 --- a/Remotely_ScreenCast.Core/Capture/ScreenCaster.cs +++ b/Remotely_ScreenCast.Core/Capture/ScreenCaster.cs @@ -48,7 +48,7 @@ namespace Remotely_ScreenCast.Core.Capture await outgoingMessages.SendScreenCount( capturer.SelectedScreen, - capturer.ScreenCount, + capturer.GetScreenCount(), viewerID); await outgoingMessages.SendScreenSize(capturer.CurrentScreenBounds.Width, capturer.CurrentScreenBounds.Height, viewerID); @@ -157,7 +157,7 @@ namespace Remotely_ScreenCast.Core.Capture { var absoluteX = (capturer.CurrentScreenBounds.Width * percentX) + capturer.CurrentScreenBounds.Left; var absoluteY = (capturer.CurrentScreenBounds.Height * percentY) + capturer.CurrentScreenBounds.Top; - return new Tuple(absoluteX / capturer.VirtualScreenWidth, absoluteY / capturer.VirtualScreenHeight); + return new Tuple(absoluteX / capturer.GetVirtualScreenWidth(), absoluteY / capturer.GetVirtualScreenHeight()); } public static Tuple GetAbsolutePointFromRelativePercent(double percentX, double percentY, ICapturer capturer) { diff --git a/Remotely_ScreenCast.Linux/Capture/X11Capture.cs b/Remotely_ScreenCast.Linux/Capture/X11Capture.cs index a9afa12d..2231cb3b 100644 --- a/Remotely_ScreenCast.Linux/Capture/X11Capture.cs +++ b/Remotely_ScreenCast.Linux/Capture/X11Capture.cs @@ -16,9 +16,6 @@ namespace Remotely_ScreenCast.Linux.Capture public System.Drawing.Bitmap PreviousFrame { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public EventHandler ScreenChanged { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public int SelectedScreen { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public int ScreenCount { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public double VirtualScreenHeight { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public double VirtualScreenWidth { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public void Capture() { @@ -30,6 +27,21 @@ namespace Remotely_ScreenCast.Linux.Capture throw new NotImplementedException(); } + public int GetScreenCount() + { + throw new NotImplementedException(); + } + + public double GetVirtualScreenHeight() + { + throw new NotImplementedException(); + } + + public double GetVirtualScreenWidth() + { + throw new NotImplementedException(); + } + public void Init() { throw new NotImplementedException(); diff --git a/Remotely_ScreenCast.Linux/Program.cs b/Remotely_ScreenCast.Linux/Program.cs index 9b3d0d3f..f92d0d42 100644 --- a/Remotely_ScreenCast.Linux/Program.cs +++ b/Remotely_ScreenCast.Linux/Program.cs @@ -20,6 +20,7 @@ namespace Remotely_ScreenCast.Linux try { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + // TODO: Works. Now make it happen. //var display = Xlib.XOpenDisplay(null); //Console.WriteLine($"Display is {display.ToString()}"); //var count = Xlib.XScreenCount(display); diff --git a/Remotely_ScreenCast.Win/Capture/BitBltCapture.cs b/Remotely_ScreenCast.Win/Capture/BitBltCapture.cs index 8d64c918..20d877a9 100644 --- a/Remotely_ScreenCast.Win/Capture/BitBltCapture.cs +++ b/Remotely_ScreenCast.Win/Capture/BitBltCapture.cs @@ -57,9 +57,19 @@ namespace Remotely_ScreenCast.Win.Capture } } public Rectangle CurrentScreenBounds { get; set; } = Screen.PrimaryScreen.Bounds; - public int ScreenCount { get; set; } = Screen.AllScreens.Length; - public double VirtualScreenHeight { get; set; } = SystemInformation.VirtualScreen.Width; - public double VirtualScreenWidth { get; set; } = SystemInformation.VirtualScreen.Height; + public int GetScreenCount() + { + return Screen.AllScreens.Length; + } + public double GetVirtualScreenHeight() + { + return SystemInformation.VirtualScreen.Width; + } + public double GetVirtualScreenWidth() + { + return SystemInformation.VirtualScreen.Height; + } + private int selectedScreen = Screen.AllScreens.ToList().IndexOf(Screen.PrimaryScreen); private Graphics graphic; diff --git a/Remotely_ScreenCast.Win/Capture/DXCapture.cs b/Remotely_ScreenCast.Win/Capture/DXCapture.cs index 3d5f3542..120b2433 100644 --- a/Remotely_ScreenCast.Win/Capture/DXCapture.cs +++ b/Remotely_ScreenCast.Win/Capture/DXCapture.cs @@ -65,9 +65,18 @@ namespace Remotely_ScreenCast.Win.Capture } } - public int ScreenCount { get; set; } = Screen.AllScreens.Length; - public double VirtualScreenHeight { get; set; } = SystemInformation.VirtualScreen.Width; - public double VirtualScreenWidth { get; set; } = SystemInformation.VirtualScreen.Height; + public int GetScreenCount() + { + return Screen.AllScreens.Length; + } + public double GetVirtualScreenHeight() + { + return SystemInformation.VirtualScreen.Width; + } + public double GetVirtualScreenWidth() + { + return SystemInformation.VirtualScreen.Height; + } public void Capture() {