diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 6835da91..509bc9e5 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -395,6 +395,11 @@ public static class AppConfig return ContainsModel("GA503") || IsSlash(); } + public static bool IsOLED() + { + return ContainsModel("OLED") || IsSlash() || ContainsModel("UX64") || ContainsModel("UX34") || ContainsModel("K360") || ContainsModel("X150"); + } + public static bool IsStrix() { return ContainsModel("Strix") || ContainsModel("Scar") || ContainsModel("G703G"); diff --git a/app/Display/DisplayGammaRamp.cs b/app/Display/DisplayGammaRamp.cs new file mode 100644 index 00000000..ca150f6f --- /dev/null +++ b/app/Display/DisplayGammaRamp.cs @@ -0,0 +1,112 @@ +namespace GHelper.Display +{ + + public class DisplayGammaRamp + { + + public DisplayGammaRamp(ushort[] red, ushort[] green, ushort[] blue) + { + if (red?.Length != GammaRamp.DataPoints) + { + throw new ArgumentOutOfRangeException(nameof(red)); + } + + if (green?.Length != GammaRamp.DataPoints) + { + throw new ArgumentOutOfRangeException(nameof(green)); + } + + if (blue?.Length != GammaRamp.DataPoints) + { + throw new ArgumentOutOfRangeException(nameof(blue)); + } + + Red = red; + Green = green; + Blue = blue; + } + + public DisplayGammaRamp(double brightness = 1, double contrast = 1, double gamma = 1) + : this( + CalculateLUT(brightness, contrast, gamma), + CalculateLUT(brightness, contrast, gamma), + CalculateLUT(brightness, contrast, gamma) + ) + { + } + + public DisplayGammaRamp( + double redBrightness, + double redContrast, + double redGamma, + double greenBrightness, + double greenContrast, + double greenGamma, + double blueBrightness, + double blueContrast, + double blueGamma + ) + : this( + CalculateLUT(redBrightness, redContrast, redGamma), + CalculateLUT(greenBrightness, greenContrast, greenGamma), + CalculateLUT(blueBrightness, blueContrast, blueGamma) + ) + { + } + + internal DisplayGammaRamp(GammaRamp ramp) : + this(ramp.Red, ramp.Green, ramp.Blue) + { + } + public ushort[] Blue { get; } + public ushort[] Green { get; } + public ushort[] Red { get; } + private static ushort[] CalculateLUT(double brightness, double contrast, double gamma) + { + brightness = 0.5 + brightness / 2; + var result = new ushort[GammaRamp.DataPoints]; + for (var i = 0; i < result.Length; i++) + { + result[i] = (ushort)(brightness * ushort.MaxValue * i / (float)(result.Length - 1)); + } + return result; + } + + public bool IsOriginal() + { + int MaxRed = Red[Red.Length - 1]; + int MaxGreen = Green[Green.Length - 1]; + int MaxBlue = Blue[Blue.Length - 1]; + return (Math.Abs((MaxRed + MaxGreen + MaxBlue) / 3 - ushort.MaxValue) < 256); + } + + private static ushort[] Brightness(ushort[] data, double brightness) + { + var result = new ushort[GammaRamp.DataPoints]; + for (var i = 0; i < result.Length; i++) + { + if (brightness < 0.5) + result[i] = (ushort)(0.5 * ushort.MaxValue * Math.Pow((float)i/(result.Length - 1), 2 - brightness*2)); + else + result[i] = (ushort)(data[i] * brightness); + } + return result; + } + + internal GammaRamp AsBrightnessRamp(double brightness) + { + return new GammaRamp( + Brightness(Red, brightness), + Brightness(Green, brightness), + Brightness(Blue, brightness) + ); + } + + internal GammaRamp AsRamp() + { + return new GammaRamp(Red, Green, Blue); + } + + + } +} \ No newline at end of file diff --git a/app/Display/GammaRamp.cs b/app/Display/GammaRamp.cs new file mode 100644 index 00000000..0b1321db --- /dev/null +++ b/app/Display/GammaRamp.cs @@ -0,0 +1,56 @@ +using System.Runtime.InteropServices; + +namespace GHelper.Display +{ + + [StructLayout(LayoutKind.Sequential)] + internal struct GammaRamp + { + public const int DataPoints = 256; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = DataPoints)] + public readonly ushort[] Red; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = DataPoints)] + public readonly ushort[] Green; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = DataPoints)] + public readonly ushort[] Blue; + + public GammaRamp(ushort[] red, ushort[] green, ushort[] blue) + { + if (red == null) + { + throw new ArgumentNullException(nameof(red)); + } + + if (green == null) + { + throw new ArgumentNullException(nameof(green)); + } + + if (blue == null) + { + throw new ArgumentNullException(nameof(blue)); + } + + if (red.Length != DataPoints) + { + throw new ArgumentOutOfRangeException(nameof(red)); + } + + if (green.Length != DataPoints) + { + throw new ArgumentOutOfRangeException(nameof(green)); + } + + if (blue.Length != DataPoints) + { + throw new ArgumentOutOfRangeException(nameof(blue)); + } + + Red = red; + Green = green; + Blue = blue; + } + } + +} \ No newline at end of file diff --git a/app/Display/ScreenControl.cs b/app/Display/ScreenControl.cs index 6331baaf..4220f4a4 100644 --- a/app/Display/ScreenControl.cs +++ b/app/Display/ScreenControl.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Runtime.InteropServices; namespace GHelper.Display { @@ -7,6 +7,8 @@ namespace GHelper.Display public const int MAX_REFRESH = 1000; + public static DisplayGammaRamp? gammaRamp; + public void AutoScreen(bool force = false) { if (force || AppConfig.Is("screen_auto")) @@ -22,6 +24,70 @@ namespace GHelper.Display } } + public void SaveGamma() + { + var screenName = ScreenNative.FindLaptopScreen(); + if (screenName is null) return; + + try + { + var handle = ScreenNative.CreateDC(screenName, screenName, null, IntPtr.Zero); + var gammaRamp = new GammaRamp(); + if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaRamp)) + { + var gamma = new DisplayGammaRamp(gammaRamp); + Logger.WriteLine("Gamma R: " + string.Join("-", gamma.Red)); + Logger.WriteLine("Gamma G: " + string.Join("-", gamma.Green)); + Logger.WriteLine("Gamma B: " + string.Join("-", gamma.Blue)); + } + } + catch (Exception ex) + { + Logger.WriteLine(ex.ToString()); + } + } + + public void SetGamma(int brightness = 100) + { + var bright = Math.Round((float)brightness / 200 + 0.5, 2); + + var screenName = ScreenNative.FindLaptopScreen(); + if (screenName is null) return; + + try + { + var handle = ScreenNative.CreateDC(screenName, screenName, null, IntPtr.Zero); + if (gammaRamp is null) + { + var gammaDump = new GammaRamp(); + if (ScreenNative.GetDeviceGammaRamp(handle, ref gammaDump)) + { + gammaRamp = new DisplayGammaRamp(gammaDump); + Logger.WriteLine("Gamma R: " + string.Join("-", gammaRamp.Red)); + Logger.WriteLine("Gamma G: " + string.Join("-", gammaRamp.Green)); + Logger.WriteLine("Gamma B: " + string.Join("-", gammaRamp.Blue)); + } + } + + if (gammaRamp is null || !gammaRamp.IsOriginal()) + { + Logger.WriteLine("Default Gamma"); + gammaRamp = new DisplayGammaRamp(); + } + + var ramp = gammaRamp.AsBrightnessRamp(bright); + bool result = ScreenNative.SetDeviceGammaRamp(handle, ref ramp); + + Logger.WriteLine("Brightness " + bright.ToString() + ": " + result); + + } catch (Exception ex) + { + Logger.WriteLine(ex.ToString()); + } + + //ScreenBrightness.Set(60 + (int)(40 * bright)); + } + public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1) { var laptopScreen = ScreenNative.FindLaptopScreen(true); @@ -71,7 +137,8 @@ namespace GHelper.Display if (miniled1 >= 0) { miniled = (miniled1 == 1) ? 0 : 1; - } else + } + else { switch (miniled2) { diff --git a/app/Display/ScreenNative.cs b/app/Display/ScreenNative.cs index 90cfdbf0..0b260fd3 100644 --- a/app/Display/ScreenNative.cs +++ b/app/Display/ScreenNative.cs @@ -32,6 +32,16 @@ namespace GHelper.Display } internal class ScreenNative { + + [DllImport("gdi32", CharSet = CharSet.Unicode)] + internal static extern IntPtr CreateDC(string driver, string device, string port, IntPtr deviceMode); + + [DllImport("gdi32")] + internal static extern bool SetDeviceGammaRamp(IntPtr dcHandle, ref GammaRamp ramp); + + [DllImport("gdi32")] + internal static extern bool GetDeviceGammaRamp(IntPtr dcHandle, ref GammaRamp ramp); + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct DEVMODE { @@ -146,7 +156,7 @@ namespace GHelper.Display public const string defaultDevice = @"\\.\DISPLAY1"; - private static string? FindInternalName(bool log = false) + public static string? FindInternalName(bool log = false) { try { diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs index 8ff78342..971b35c6 100644 --- a/app/Properties/Resources.Designer.cs +++ b/app/Properties/Resources.Designer.cs @@ -210,6 +210,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_brightness_32 { + get { + object obj = ResourceManager.GetObject("icons8-brightness-32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx index 7d0ca668..ea07c07c 100644 --- a/app/Properties/Resources.resx +++ b/app/Properties/Resources.resx @@ -136,6 +136,9 @@ ..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -163,9 +166,15 @@ ..\Resources\icons8-automation-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-settings-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\brightness-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\brightness-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-processor-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -187,15 +196,9 @@ ..\Resources\icons8-laptop-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\ally.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\icons8-remove-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-share-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\icons8-function-mac-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -229,14 +232,11 @@ ..\Resources\icons8-xbox-rt-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\icons8-fan-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-settings-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-maus-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -250,8 +250,11 @@ ..\Resources\dot-ultimate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\brightness-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-heartbeat-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ally.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\backlight-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -319,8 +322,8 @@ ..\Resources\icons8-software-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-share-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-soonvibes-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -331,7 +334,7 @@ ..\Resources\icons8-charging-battery-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-heartbeat-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-brightness-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/app/Resources/icons8-brightness-32.png b/app/Resources/icons8-brightness-32.png new file mode 100644 index 00000000..a1deb58f Binary files /dev/null and b/app/Resources/icons8-brightness-32.png differ diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 73fd98a7..35d73cb1 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -34,6 +34,7 @@ namespace GHelper tableLayoutMatrix = new TableLayoutPanel(); comboMatrix = new RComboBox(); comboMatrixRunning = new RComboBox(); + comboInterval = new RComboBox(); buttonMatrix = new RButton(); panelMatrixTitle = new Panel(); pictureMatrix = new PictureBox(); @@ -119,7 +120,12 @@ namespace GHelper panelAllyTitle = new Panel(); pictureAlly = new PictureBox(); labelAlly = new Label(); - comboInterval = new RComboBox(); + panelGamma = new Panel(); + sliderGamma = new Slider(); + panelGammaTitle = new Panel(); + labelGamma = new Label(); + pictureGamma = new PictureBox(); + labelGammaTitle = new Label(); panelMatrix.SuspendLayout(); tableLayoutMatrix.SuspendLayout(); panelMatrixTitle.SuspendLayout(); @@ -158,6 +164,9 @@ namespace GHelper tableLayoutAlly.SuspendLayout(); panelAllyTitle.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureAlly).BeginInit(); + panelGamma.SuspendLayout(); + panelGammaTitle.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureGamma).BeginInit(); SuspendLayout(); // // panelMatrix @@ -169,7 +178,7 @@ namespace GHelper panelMatrix.Controls.Add(panelMatrixTitle); panelMatrix.Controls.Add(checkMatrix); panelMatrix.Dock = DockStyle.Top; - panelMatrix.Location = new Point(11, 827); + panelMatrix.Location = new Point(11, 950); panelMatrix.Margin = new Padding(0); panelMatrix.Name = "panelMatrix"; panelMatrix.Padding = new Padding(20, 20, 20, 10); @@ -230,6 +239,21 @@ namespace GHelper comboMatrixRunning.Size = new Size(248, 40); comboMatrixRunning.TabIndex = 17; // + // comboInterval + // + comboInterval.BorderColor = Color.White; + comboInterval.ButtonColor = Color.FromArgb(255, 255, 255); + comboInterval.Dock = DockStyle.Top; + comboInterval.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + comboInterval.FormattingEnabled = true; + comboInterval.ItemHeight = 32; + comboInterval.Location = new Point(7, 75); + comboInterval.Margin = new Padding(7, 11, 7, 8); + comboInterval.Name = "comboInterval"; + comboInterval.Size = new Size(248, 40); + comboInterval.TabIndex = 19; + comboInterval.Visible = false; + // // buttonMatrix // buttonMatrix.Activated = false; @@ -301,7 +325,7 @@ namespace GHelper panelBattery.Controls.Add(sliderBattery); panelBattery.Controls.Add(panelBatteryTitle); panelBattery.Dock = DockStyle.Top; - panelBattery.Location = new Point(11, 1485); + panelBattery.Location = new Point(11, 1608); panelBattery.Margin = new Padding(0); panelBattery.Name = "panelBattery"; panelBattery.Padding = new Padding(20, 20, 20, 10); @@ -393,7 +417,7 @@ namespace GHelper panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelFooter.Controls.Add(tableButtons); panelFooter.Dock = DockStyle.Top; - panelFooter.Location = new Point(11, 1660); + panelFooter.Location = new Point(11, 1783); panelFooter.Margin = new Padding(0); panelFooter.Name = "panelFooter"; panelFooter.Padding = new Padding(20); @@ -1140,7 +1164,7 @@ namespace GHelper panelKeyboard.Controls.Add(tableLayoutKeyboard); panelKeyboard.Controls.Add(panelKeyboardTitle); panelKeyboard.Dock = DockStyle.Top; - panelKeyboard.Location = new Point(11, 1143); + panelKeyboard.Location = new Point(11, 1266); panelKeyboard.Margin = new Padding(0); panelKeyboard.Name = "panelKeyboard"; panelKeyboard.Padding = new Padding(20); @@ -1316,7 +1340,7 @@ namespace GHelper panelVersion.Controls.Add(labelCharge); panelVersion.Controls.Add(checkStartup); panelVersion.Dock = DockStyle.Top; - panelVersion.Location = new Point(11, 1604); + panelVersion.Location = new Point(11, 1727); panelVersion.Margin = new Padding(4); panelVersion.Name = "panelVersion"; panelVersion.Size = new Size(827, 56); @@ -1341,7 +1365,7 @@ namespace GHelper panelPeripherals.Controls.Add(tableLayoutPeripherals); panelPeripherals.Controls.Add(panelPeripheralsTile); panelPeripherals.Dock = DockStyle.Top; - panelPeripherals.Location = new Point(11, 1287); + panelPeripherals.Location = new Point(11, 1410); panelPeripherals.Margin = new Padding(0); panelPeripherals.Name = "panelPeripherals"; panelPeripherals.Padding = new Padding(20, 20, 20, 10); @@ -1483,7 +1507,7 @@ namespace GHelper panelAlly.Controls.Add(tableLayoutAlly); panelAlly.Controls.Add(panelAllyTitle); panelAlly.Dock = DockStyle.Top; - panelAlly.Location = new Point(11, 1003); + panelAlly.Location = new Point(11, 1126); panelAlly.Margin = new Padding(0); panelAlly.Name = "panelAlly"; panelAlly.Padding = new Padding(20, 20, 20, 0); @@ -1611,20 +1635,79 @@ namespace GHelper labelAlly.TabIndex = 26; labelAlly.Text = "Ally Controller"; // - // comboInterval + // panelGamma // - comboInterval.BorderColor = Color.White; - comboInterval.ButtonColor = Color.FromArgb(255, 255, 255); - comboInterval.Dock = DockStyle.Top; - comboInterval.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); - comboInterval.FormattingEnabled = true; - comboInterval.ItemHeight = 32; - comboInterval.Location = new Point(7, 75); - comboInterval.Margin = new Padding(7, 11, 7, 8); - comboInterval.Name = "comboInterval"; - comboInterval.Size = new Size(248, 40); - comboInterval.TabIndex = 19; - comboInterval.Visible = false; + panelGamma.AutoSize = true; + panelGamma.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelGamma.Controls.Add(sliderGamma); + panelGamma.Controls.Add(panelGammaTitle); + panelGamma.Dock = DockStyle.Top; + panelGamma.Location = new Point(11, 827); + panelGamma.Margin = new Padding(0); + panelGamma.Name = "panelGamma"; + panelGamma.Padding = new Padding(20, 20, 20, 10); + panelGamma.Size = new Size(827, 123); + panelGamma.TabIndex = 9; + panelGamma.Visible = false; + // + // sliderGamma + // + sliderGamma.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + sliderGamma.Location = new Point(40, 69); + sliderGamma.Margin = new Padding(4); + sliderGamma.Max = 100; + sliderGamma.Min = 0; + sliderGamma.Name = "sliderGamma"; + sliderGamma.Size = new Size(752, 40); + sliderGamma.Step = 10; + sliderGamma.TabIndex = 20; + sliderGamma.Text = "sliderGamma"; + sliderGamma.Value = 100; + // + // panelGammaTitle + // + panelGammaTitle.Controls.Add(labelGamma); + panelGammaTitle.Controls.Add(pictureGamma); + panelGammaTitle.Controls.Add(labelGammaTitle); + panelGammaTitle.Dock = DockStyle.Top; + panelGammaTitle.Location = new Point(20, 20); + panelGammaTitle.Margin = new Padding(4); + panelGammaTitle.Name = "panelGammaTitle"; + panelGammaTitle.Padding = new Padding(0, 0, 0, 4); + panelGammaTitle.Size = new Size(787, 44); + panelGammaTitle.TabIndex = 40; + // + // labelGamma + // + labelGamma.Anchor = AnchorStyles.Top | AnchorStyles.Right; + labelGamma.Location = new Point(675, 4); + labelGamma.Margin = new Padding(8, 0, 8, 0); + labelGamma.Name = "labelGamma"; + labelGamma.Size = new Size(107, 36); + labelGamma.TabIndex = 39; + labelGamma.Text = " "; + labelGamma.TextAlign = ContentAlignment.TopRight; + // + // pictureGamma + // + pictureGamma.BackgroundImage = Properties.Resources.icons8_brightness_32; + pictureGamma.BackgroundImageLayout = ImageLayout.Zoom; + pictureGamma.Location = new Point(4, 2); + pictureGamma.Margin = new Padding(4); + pictureGamma.Name = "pictureGamma"; + pictureGamma.Size = new Size(32, 32); + pictureGamma.TabIndex = 38; + pictureGamma.TabStop = false; + // + // labelGammaTitle + // + labelGammaTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelGammaTitle.Location = new Point(43, 0); + labelGammaTitle.Margin = new Padding(8, 0, 8, 0); + labelGammaTitle.Name = "labelGammaTitle"; + labelGammaTitle.Size = new Size(307, 32); + labelGammaTitle.TabIndex = 37; + labelGammaTitle.Text = "Flicker-free Dimming"; // // SettingsForm // @@ -1632,7 +1715,7 @@ namespace GHelper AutoScaleMode = AutoScaleMode.Dpi; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; - ClientSize = new Size(849, 1717); + ClientSize = new Size(849, 2119); Controls.Add(panelFooter); Controls.Add(panelVersion); Controls.Add(panelBattery); @@ -1640,6 +1723,7 @@ namespace GHelper Controls.Add(panelKeyboard); Controls.Add(panelAlly); Controls.Add(panelMatrix); + Controls.Add(panelGamma); Controls.Add(panelScreen); Controls.Add(panelGPU); Controls.Add(panelPerformance); @@ -1708,6 +1792,9 @@ namespace GHelper panelAllyTitle.ResumeLayout(false); panelAllyTitle.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureAlly).EndInit(); + panelGamma.ResumeLayout(false); + panelGammaTitle.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureGamma).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -1803,5 +1890,11 @@ namespace GHelper private RButton buttonController; private RButton buttonOverlay; private RComboBox comboInterval; + private Panel panelGamma; + private Slider sliderGamma; + private Panel panelGammaTitle; + private Label labelGamma; + private PictureBox pictureGamma; + private Label labelGammaTitle; } } diff --git a/app/Settings.cs b/app/Settings.cs index 3b14d100..3d4291ae 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -253,9 +253,19 @@ namespace GHelper VisualiseFnLock(); buttonFnLock.Click += ButtonFnLock_Click; + panelGamma.Visible = AppConfig.IsOLED(); + sliderGamma.ValueChanged += SliderGamma_ValueChanged; + labelGamma.Text = "100%"; + panelPerformance.Focus(); } + private void SliderGamma_ValueChanged(object? sender, EventArgs e) + { + screenControl.SetGamma(sliderGamma.Value); + labelGamma.Text = sliderGamma.Value + "%"; + } + private void ButtonOverlay_Click(object? sender, EventArgs e) { KeyboardHook.KeyKeyKeyPress(Keys.LControlKey, Keys.LShiftKey, Keys.O);