Minor fixes

This commit is contained in:
seerge
2023-03-07 21:19:04 +01:00
parent 30f678d08f
commit be133cd238
3 changed files with 14 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Management; using System.Management;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms;
public class NativeMethods public class NativeMethods
{ {
@@ -258,24 +259,25 @@ public class NativeMethods
{ {
if ((d.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0) if ((d.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
{ {
//Debug.WriteLine(d.DeviceID);
//Debug.WriteLine(d.DeviceName);
if (counter == deviceNum) if (counter == deviceNum)
{ {
laptopScreen = d.DeviceName; laptopScreen = d.DeviceName;
//Debug.WriteLine(d.DeviceID);
//Debug.WriteLine(d.DeviceName);
} }
counter++; counter++;
} }
} }
/* // Mismatch between active screens and enumerated screens, fallback to old method
if (laptopScreen is null) if (counter != activeScreens.Count)
{ {
foreach (var screen in screens) laptopScreen = null;
Debug.WriteLine(screen.DeviceName); foreach (var screen in Screen.AllScreens)
if (screen.DeviceName == laptopScreenName)
laptopScreen = screen.DeviceName;
} }
*/
return laptopScreen; return laptopScreen;
} }

View File

@@ -96,6 +96,9 @@ namespace GHelper
private static void SetAutoModes() private static void SetAutoModes()
{ {
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus; PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
Debug.WriteLine(isPlugged.ToString());
settingsForm.AutoGPUMode(isPlugged); settingsForm.AutoGPUMode(isPlugged);
settingsForm.AutoScreen(isPlugged); settingsForm.AutoScreen(isPlugged);
settingsForm.AutoPerformance(isPlugged); settingsForm.AutoPerformance(isPlugged);

View File

@@ -97,6 +97,8 @@ namespace GHelper
} }
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e) private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
{ {
if (sender is null) return; if (sender is null) return;