From b94719adb0e5768cdbef632da72c68e9dac29313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Sat, 19 Nov 2022 09:19:57 +0100 Subject: [PATCH] Order resolutions --- .../Helpers/PhysicalMonitorBrightnessController.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/PowerControl/Helpers/PhysicalMonitorBrightnessController.cs b/PowerControl/Helpers/PhysicalMonitorBrightnessController.cs index 54c946a..2a92a8f 100644 --- a/PowerControl/Helpers/PhysicalMonitorBrightnessController.cs +++ b/PowerControl/Helpers/PhysicalMonitorBrightnessController.cs @@ -1,6 +1,7 @@ using Microsoft.VisualBasic.Logging; using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -200,7 +201,7 @@ namespace PowerControl.Helpers UpdateMonitors(); } - public struct DisplayResolution + public struct DisplayResolution : IComparable { public int Width { get; set; } public int Height { get; set; } @@ -218,6 +219,13 @@ namespace PowerControl.Helpers public override readonly int GetHashCode() => HashCode.Combine(Width, Height); + public int CompareTo(DisplayResolution other) + { + var index = Width.CompareTo(other.Width); + if (index == 0) index = Height.CompareTo(other.Height); + return index; + } + public override string ToString() { return String.Format("{0}x{1}", Width, Height); @@ -254,7 +262,7 @@ namespace PowerControl.Helpers { return FindAllDisplaySettings() .Select((dm) => new DisplayResolution(dm.dmPelsWidth, dm.dmPelsHeight)) - .ToHashSet() + .ToImmutableSortedSet() .ToArray(); }