mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Remotely.ScreenCast.Core.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Remotely.ScreenCast.Core.Enums;
|
|
using Remotely.ScreenCast.Core.Services;
|
|
using Remotely.ScreenCast.Core;
|
|
using Remotely.ScreenCast.Core.Models;
|
|
using Remotely.Shared.Models;
|
|
using Remotely.Shared.Win32;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Threading;
|
|
|
|
namespace Remotely.ScreenCast.Win.Services
|
|
{
|
|
public class ScreenCasterWin : ScreenCasterBase, IScreenCaster
|
|
{
|
|
public ScreenCasterWin(CursorIconWatcher cursorIconWatcher)
|
|
{
|
|
CursorIconWatcher = cursorIconWatcher;
|
|
}
|
|
|
|
public CursorIconWatcher CursorIconWatcher { get; }
|
|
|
|
public async Task BeginScreenCasting(ScreenCastRequest screenCastRequest)
|
|
{
|
|
if (Win32Interop.GetCurrentDesktop(out var currentDesktopName))
|
|
{
|
|
Logger.Write($"Setting desktop to {currentDesktopName} before screen casting.");
|
|
Win32Interop.SwitchToInputDesktop();
|
|
}
|
|
else
|
|
{
|
|
Logger.Write("Failed to get current desktop before screen casting.");
|
|
}
|
|
|
|
var conductor = ServiceContainer.Instance.GetRequiredService<Conductor>();
|
|
await conductor.CasterSocket.SendCursorChange(CursorIconWatcher.GetCurrentCursor(), new List<string>() { screenCastRequest.ViewerID });
|
|
_ = BeginScreenCasting(screenCastRequest.ViewerID, screenCastRequest.RequesterName, ServiceContainer.Instance.GetRequiredService<IScreenCapturer>());
|
|
}
|
|
}
|
|
}
|