From 4c653eddb1ee30bdc7e5fa429501c9eefc59b6e0 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:09:30 +0100 Subject: [PATCH] Color Temp Controls --- app/Display/VisualControl.cs | 20 ++++++++++++++++++-- app/Settings.Designer.cs | 21 +++++++++++++++++++-- app/Settings.cs | 15 +++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/Display/VisualControl.cs b/app/Display/VisualControl.cs index b0708a17..90eacadb 100644 --- a/app/Display/VisualControl.cs +++ b/app/Display/VisualControl.cs @@ -39,7 +39,7 @@ namespace GHelper.Display private static System.Timers.Timer brightnessTimer = new System.Timers.Timer(100); - + public const int DefaultColorTemp = 50; static VisualControl() { brightnessTimer.Elapsed += BrightnessTimerTimer_Elapsed; @@ -98,6 +98,20 @@ namespace GHelper.Display }; } + public static Dictionary GetTemperatures() + { + return new Dictionary + { + { 0, "Warmest"}, + { 15, "Warmer"}, + { 30, "Warm"}, + { 50, "Neutral"}, + { 70, "Cold"}, + { 85, "Colder"}, + { 100, "Coldest"}, + }; + } + public static void SetGamut(int mode = 50) { if (RunSplendid(SplendidCommand.GamutMode, 0, mode)) return; @@ -110,11 +124,13 @@ namespace GHelper.Display } } - public static void SetVisual(SplendidCommand mode = SplendidCommand.Default, int whiteBalance = 50, bool init = false) + public static void SetVisual(SplendidCommand mode = SplendidCommand.Default, int whiteBalance = DefaultColorTemp, bool init = false) { if (mode == SplendidCommand.None) return; if (mode == SplendidCommand.Default && init) return; // Skip default setting on init + if (whiteBalance != DefaultColorTemp && !init) ProcessHelper.RunAsAdmin(); + int balance = mode == SplendidCommand.Eyecare ? 2 : whiteBalance; if (RunSplendid(mode, 0, balance)) return; diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 25943bd9..8aa260bd 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -131,6 +131,7 @@ namespace GHelper labelGamma = new Label(); pictureGamma = new PictureBox(); labelGammaTitle = new Label(); + comboColorTemp = new RComboBox(); panelMatrix.SuspendLayout(); panelMatrixAuto.SuspendLayout(); tableLayoutMatrix.SuspendLayout(); @@ -1694,6 +1695,7 @@ namespace GHelper tableVisual.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); tableVisual.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); tableVisual.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F)); + tableVisual.Controls.Add(comboColorTemp, 0, 0); tableVisual.Controls.Add(comboVisual, 0, 0); tableVisual.Controls.Add(comboGamut, 0, 0); tableVisual.Dock = DockStyle.Top; @@ -1715,7 +1717,6 @@ namespace GHelper comboVisual.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboVisual.FormattingEnabled = true; comboVisual.ItemHeight = 32; - comboVisual.Items.AddRange(new object[] { "Static", "Breathe", "Rainbow", "Strobe" }); comboVisual.Location = new Point(266, 11); comboVisual.Margin = new Padding(4, 11, 4, 8); comboVisual.Name = "comboVisual"; @@ -1732,7 +1733,6 @@ namespace GHelper comboGamut.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboGamut.FormattingEnabled = true; comboGamut.ItemHeight = 32; - comboGamut.Items.AddRange(new object[] { "Static", "Breathe", "Rainbow", "Strobe" }); comboGamut.Location = new Point(4, 11); comboGamut.Margin = new Padding(4, 11, 4, 8); comboGamut.Name = "comboGamut"; @@ -1800,6 +1800,22 @@ namespace GHelper labelGammaTitle.TabIndex = 37; labelGammaTitle.Text = "Flicker-free Dimming"; // + // comboColorTemp + // + comboColorTemp.BorderColor = Color.White; + comboColorTemp.ButtonColor = Color.FromArgb(255, 255, 255); + comboColorTemp.Dock = DockStyle.Top; + comboColorTemp.FlatStyle = FlatStyle.Flat; + comboColorTemp.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + comboColorTemp.FormattingEnabled = true; + comboColorTemp.ItemHeight = 32; + comboColorTemp.Location = new Point(528, 11); + comboColorTemp.Margin = new Padding(4, 11, 4, 8); + comboColorTemp.Name = "comboColorTemp"; + comboColorTemp.Size = new Size(255, 40); + comboColorTemp.TabIndex = 15; + comboColorTemp.Visible = false; + // // SettingsForm // AutoScaleDimensions = new SizeF(192F, 192F); @@ -1996,5 +2012,6 @@ namespace GHelper private TableLayoutPanel tableVisual; private RComboBox comboVisual; private RComboBox comboGamut; + private RComboBox comboColorTemp; } } diff --git a/app/Settings.cs b/app/Settings.cs index 8769c094..a12be771 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -286,6 +286,7 @@ namespace GHelper tableVisual.Visible = true; var visualValue = (SplendidCommand)AppConfig.Get("visual", (int)SplendidCommand.Default); + var colorTempValue = AppConfig.Get("color_temp", VisualControl.DefaultColorTemp); comboVisual.DropDownStyle = ComboBoxStyle.DropDownList; comboVisual.DataSource = new BindingSource(VisualControl.GetVisualModes(), null); @@ -293,11 +294,20 @@ namespace GHelper comboVisual.ValueMember = "Key"; comboVisual.SelectedValue = visualValue; - VisualControl.SetVisual(mode : visualValue, init : true); + comboColorTemp.DropDownStyle = ComboBoxStyle.DropDownList; + comboColorTemp.DataSource = new BindingSource(VisualControl.GetTemperatures(), null); + comboColorTemp.DisplayMember = "Value"; + comboColorTemp.ValueMember = "Key"; + comboColorTemp.SelectedValue = colorTempValue; + + VisualControl.SetVisual(visualValue, colorTempValue, true); comboVisual.SelectedValueChanged += ComboVisual_SelectedValueChanged; comboVisual.Visible = true; + comboColorTemp.SelectedValueChanged += ComboVisual_SelectedValueChanged; + comboColorTemp.Visible = true; + if (gamuts.Count <= 1) return; comboGamut.DropDownStyle = ComboBoxStyle.DropDownList; @@ -320,7 +330,8 @@ namespace GHelper private void ComboVisual_SelectedValueChanged(object? sender, EventArgs e) { AppConfig.Set("visual", (int)comboVisual.SelectedValue); - VisualControl.SetVisual((SplendidCommand)comboVisual.SelectedValue); + AppConfig.Set("color_temp", (int)comboColorTemp.SelectedValue); + VisualControl.SetVisual((SplendidCommand)comboVisual.SelectedValue, (int)comboColorTemp.SelectedValue); } public void VisualiseBrightness()