LANCommander.PlaynitePlugin/LANCommander.PowerShell/Cmdlets/Get-PrimaryDisplay.cs

38 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-07-03 17:53:00 -05:00
using LANCommander.PowerShell.Extensions;
using LANCommander.PowerShell.Models;
using System.Linq;
using System.Management.Automation;
namespace LANCommander.PowerShell.Cmdlets
{
[Cmdlet(VerbsCommon.Get, "PrimaryDisplay")]
[OutputType(typeof(string))]
2023-11-16 15:21:50 -06:00
public class GetPrimaryDisplayCmdlet : Cmdlet
{
protected override void ProcessRecord()
{
2024-07-03 17:53:00 -05:00
var screens = System.Windows.Forms.Screen.AllScreens;
2024-07-03 17:53:00 -05:00
var primaryScreen = screens.First(s => s.Primary);
var mode = primaryScreen.GetDeviceMode();
var screen = new Screen
{
Bounds = new Bounds
{
Width = primaryScreen.Bounds.Width,
Height = primaryScreen.Bounds.Height
},
Width = primaryScreen.Bounds.Width,
Height = primaryScreen.Bounds.Height,
Primary = true,
RefreshRate = mode.dmNup,
BitsPerPixel = primaryScreen.BitsPerPixel
};
WriteObject(screen);
}
}
}