Rebranding.

This commit is contained in:
Jared Goodwin 2019-03-02 14:31:35 -08:00
parent 0a7b099c38
commit 29b3c01704
6 changed files with 38 additions and 37 deletions

View File

@ -76,7 +76,7 @@ namespace Remotely_ScreenCast.Capture
PreviousFrame = new Bitmap(CurrentScreenBounds.Width, CurrentScreenBounds.Height, PixelFormat.Format32bppArgb);
graphic = Graphics.FromImage(CurrentFrame);
desktopName = Win32Interop.GetCurrentDesktop();
hWnd = User32.GetDesktopWindow();
//hWnd = User32.GetDesktopWindow();
}
public void Capture()
@ -88,7 +88,7 @@ namespace Remotely_ScreenCast.Capture
var inputDesktop = Win32Interop.OpenInputDesktop();
var success = User32.SetThreadDesktop(inputDesktop);
User32.CloseDesktop(inputDesktop);
Logger.Write($"Set thread desktop: {success}");
Logger.Write($"Set thread desktop to {currentDesktop}: {success}");
}
// Keep framerate below 30 FPS.
@ -103,13 +103,13 @@ namespace Remotely_ScreenCast.Capture
{
lock (ScreenLock)
{
hWnd = User32.GetDesktopWindow();
//hWnd = User32.GetDesktopWindow();
//hDC = User32.GetWindowDC(hWnd);
//graphic = Graphics.FromImage(CurrentFrame);
//graphDC = graphic.GetHdc();
//var copyResult = GDI32.BitBlt(graphDC, 0, 0, CurrentScreenBounds.Width, CurrentScreenBounds.Height, hDC, CurrentScreenBounds.Left, CurrentScreenBounds.Top, GDI32.TernaryRasterOperations.SRCCOPY);
PreviousFrame = (Bitmap)CurrentFrame.Clone();
hDC = User32.GetWindowDC(hWnd);
graphic = Graphics.FromImage(CurrentFrame);
graphDC = graphic.GetHdc();
var copyResult = GDI32.BitBlt(graphDC, 0, 0, CurrentScreenBounds.Width, CurrentScreenBounds.Height, hDC, CurrentScreenBounds.Left, CurrentScreenBounds.Top, GDI32.TernaryRasterOperations.SRCCOPY);
//graphic.CopyFromScreen(CurrentScreenBounds.Left, CurrentScreenBounds.Top, 0, 0, new Size(CurrentScreenBounds.Width, CurrentScreenBounds.Height));
graphic.CopyFromScreen(CurrentScreenBounds.Left, CurrentScreenBounds.Top, 0, 0, new Size(CurrentScreenBounds.Width, CurrentScreenBounds.Height));
}
}
catch (Exception ex)
@ -118,14 +118,14 @@ namespace Remotely_ScreenCast.Capture
}
finally
{
if (graphDC != IntPtr.Zero)
{
graphic.ReleaseHdc(graphDC);
}
if (hDC != IntPtr.Zero)
{
User32.ReleaseDC(hWnd, hDC);
}
//if (graphDC != IntPtr.Zero)
//{
// graphic.ReleaseHdc(graphDC);
//}
//if (hDC != IntPtr.Zero)
//{
// User32.ReleaseDC(hWnd, hDC);
//}
}
}
}

View File

@ -130,12 +130,6 @@ namespace Remotely_ScreenCast.Capture
{
try
{
if (NeedsInit)
{
duplicatedOutput?.Dispose();
Init();
NeedsInit = false;
}
var currentDesktop = Win32Interop.GetCurrentDesktop();
if (currentDesktop != desktopName)
{
@ -144,9 +138,17 @@ namespace Remotely_ScreenCast.Capture
var success = User32.SetThreadDesktop(inputDesktop);
User32.CloseDesktop(inputDesktop);
Logger.Write($"Set thread desktop to {currentDesktop}: {success}");
NeedsInit = true;
return;
}
if (NeedsInit)
{
duplicatedOutput?.Dispose();
Init();
NeedsInit = false;
}
SharpDX.DXGI.Resource screenResource;
OutputDuplicateFrameInformation duplicateFrameInformation;
@ -210,9 +212,15 @@ namespace Remotely_ScreenCast.Capture
{
if (e.ResultCode.Code != SharpDX.DXGI.ResultCode.WaitTimeout.Result.Code)
{
throw;
Logger.Write(e);
NeedsInit = true;
}
}
catch (Exception e)
{
Logger.Write(e);
NeedsInit = true;
}
}
}
}

View File

@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Win32;
namespace Remotely_ScreenCast.Capture
{
@ -26,8 +27,8 @@ namespace Remotely_ScreenCast.Capture
{
if (Program.Viewers.Count == 0)
{
capturer = new BitBltCapture();
captureMode = CaptureMode.BitBtl;
capturer = new DXCapture();
captureMode = CaptureMode.DirectX;
}
else
{
@ -42,7 +43,7 @@ namespace Remotely_ScreenCast.Capture
captureMode = CaptureMode.BitBtl;
}
Logger.Write($"Starting screen cast. Requester: {requesterName}. Viewer ID: {viewerID}. Capture Mode: {captureMode.ToString()}.");
Logger.Write($"Starting screen cast. Requester: {requesterName}. Viewer ID: {viewerID}. Capture Mode: {captureMode.ToString()}. Desktop: {Win32Interop.GetCurrentDesktop()}");
var viewer = new Models.Viewer()
{
@ -99,16 +100,6 @@ namespace Remotely_ScreenCast.Capture
catch (Exception ex)
{
Logger.Write(ex);
if (captureMode == CaptureMode.DirectX)
{
capturer = new BitBltCapture();
captureMode = CaptureMode.BitBtl;
capturer.ScreenChanged += async (sender, bounds) =>
{
await outgoingMessages.SendScreenSize(bounds.Width, bounds.Height, viewerID);
};
capturer.SelectedScreen = viewer.CurrentScreenIndex;
}
}
}

View File

@ -61,6 +61,7 @@ export function ApplyInputHandlers(sockets) {
});
document.querySelector("#disconnectButton").addEventListener("click", (ev) => {
ConnectButton.removeAttribute("disabled");
RemoteControl.RCBrowserSockets.Connection.stop();
});
document.querySelector("#keyboardButton").addEventListener("click", (ev) => {
HorizontalBars.forEach(x => {

File diff suppressed because one or more lines are too long

View File

@ -65,6 +65,7 @@ export function ApplyInputHandlers(sockets: RCBrowserSockets) {
})
document.querySelector("#disconnectButton").addEventListener("click", (ev) => {
ConnectButton.removeAttribute("disabled");
RemoteControl.RCBrowserSockets.Connection.stop();
});
document.querySelector("#keyboardButton").addEventListener("click", (ev) => {
HorizontalBars.forEach(x => {