From 6b3b0b4b1754645828e345fb05f8dd34a45fbb63 Mon Sep 17 00:00:00 2001 From: Vincent Maas Date: Sat, 9 Dec 2023 14:26:26 +0100 Subject: [PATCH] implemented lazy loading of Info panel, fixed some Nvidia issues, add support for 2022 series OLED full service menu activation --- ColorControl/ColorControl.csproj | 7 +- ColorControl/Forms/InfoPanel.Designer.cs | 119 ++++++++++++++++++ ColorControl/Forms/InfoPanel.cs | 56 +++++++++ ColorControl/Forms/InfoPanel.resx | 120 +++++++++++++++++++ ColorControl/MainForm.Designer.cs | 86 +------------ ColorControl/MainForm.cs | 48 +++----- ColorControl/Program.cs | 4 +- ColorControl/Services/Common/PresetBase.cs | 2 + ColorControl/Services/LG/LgPanel.Designer.cs | 10 +- ColorControl/Services/LG/LgPanel.cs | 2 +- ColorControl/Services/NVIDIA/NvPanel.cs | 38 +++--- ColorControl/Services/NVIDIA/NvPreset.cs | 2 + ColorControl/Services/NVIDIA/NvService.cs | 60 +++++++--- novideo_srgb/DisplayConfigManager.cs | 5 + 14 files changed, 399 insertions(+), 160 deletions(-) create mode 100644 ColorControl/Forms/InfoPanel.Designer.cs create mode 100644 ColorControl/Forms/InfoPanel.cs create mode 100644 ColorControl/Forms/InfoPanel.resx diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj index 3efac85..0aa2f21 100644 --- a/ColorControl/ColorControl.csproj +++ b/ColorControl/ColorControl.csproj @@ -18,8 +18,8 @@ Maassoft Maassoft 0 - 9.7.1.0 - 9.7.1.0 + 9.7.2.0 + 9.7.2.0 false true false @@ -58,6 +58,9 @@ Form + + UserControl + Form diff --git a/ColorControl/Forms/InfoPanel.Designer.cs b/ColorControl/Forms/InfoPanel.Designer.cs new file mode 100644 index 0000000..269d1d8 --- /dev/null +++ b/ColorControl/Forms/InfoPanel.Designer.cs @@ -0,0 +1,119 @@ +namespace ColorControl.Forms +{ + partial class InfoPanel + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + wvInfo = new Microsoft.Web.WebView2.WinForms.WebView2(); + grpInfo = new System.Windows.Forms.GroupBox(); + lbPlugins = new System.Windows.Forms.ListBox(); + label7 = new System.Windows.Forms.Label(); + lblInfo = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)wvInfo).BeginInit(); + grpInfo.SuspendLayout(); + SuspendLayout(); + // + // wvInfo + // + wvInfo.AllowExternalDrop = true; + wvInfo.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + wvInfo.CreationProperties = null; + wvInfo.DefaultBackgroundColor = System.Drawing.Color.White; + wvInfo.Location = new System.Drawing.Point(433, 3); + wvInfo.Name = "wvInfo"; + wvInfo.Size = new System.Drawing.Size(671, 526); + wvInfo.Source = new System.Uri("https://github.com/Maassoft/ColorControl/releases", System.UriKind.Absolute); + wvInfo.TabIndex = 8; + wvInfo.ZoomFactor = 1D; + // + // grpInfo + // + grpInfo.Controls.Add(lbPlugins); + grpInfo.Controls.Add(label7); + grpInfo.Controls.Add(lblInfo); + grpInfo.Location = new System.Drawing.Point(4, 3); + grpInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + grpInfo.Name = "grpInfo"; + grpInfo.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + grpInfo.Size = new System.Drawing.Size(422, 336); + grpInfo.TabIndex = 7; + grpInfo.TabStop = false; + grpInfo.Text = "Info"; + // + // lbPlugins + // + lbPlugins.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + lbPlugins.FormattingEnabled = true; + lbPlugins.HorizontalScrollbar = true; + lbPlugins.ItemHeight = 15; + lbPlugins.Location = new System.Drawing.Point(11, 77); + lbPlugins.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + lbPlugins.Name = "lbPlugins"; + lbPlugins.Size = new System.Drawing.Size(403, 244); + lbPlugins.TabIndex = 3; + // + // label7 + // + label7.AutoSize = true; + label7.Location = new System.Drawing.Point(8, 59); + label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + label7.Name = "label7"; + label7.Size = new System.Drawing.Size(267, 15); + label7.TabIndex = 2; + label7.Text = "This app contains the following 3rd party plugins:"; + // + // lblInfo + // + lblInfo.AutoSize = true; + lblInfo.Location = new System.Drawing.Point(8, 23); + lblInfo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lblInfo.Name = "lblInfo"; + lblInfo.Size = new System.Drawing.Size(28, 15); + lblInfo.TabIndex = 1; + lblInfo.Text = "Info"; + // + // InfoPanel + // + Controls.Add(wvInfo); + Controls.Add(grpInfo); + Name = "InfoPanel"; + Size = new System.Drawing.Size(1110, 534); + ((System.ComponentModel.ISupportInitialize)wvInfo).EndInit(); + grpInfo.ResumeLayout(false); + grpInfo.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Microsoft.Web.WebView2.WinForms.WebView2 wvInfo; + private System.Windows.Forms.GroupBox grpInfo; + private System.Windows.Forms.ListBox lbPlugins; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label lblInfo; + } +} diff --git a/ColorControl/Forms/InfoPanel.cs b/ColorControl/Forms/InfoPanel.cs new file mode 100644 index 0000000..9133f57 --- /dev/null +++ b/ColorControl/Forms/InfoPanel.cs @@ -0,0 +1,56 @@ +using ColorControl.Shared.Forms; +using ColorControl.Shared.Services; +using System.Diagnostics; +using System.Windows.Forms; + +namespace ColorControl.Forms +{ + public partial class InfoPanel : UserControl + { + private readonly WinApiService _winApiService; + private bool _initialized; + + public InfoPanel(WinApiService winApiService) + { + _winApiService = winApiService; + InitializeComponent(); + + _initialized = true; + + if (DarkModeUtils.UseDarkMode) + { + grpInfo.ForeColor = FormUtils.CurrentForeColor; + } + + Init(); + } + + private void Init() + { + var currentVersionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath); + + Text = Application.ProductName + " " + Application.ProductVersion; + + if (_winApiService.IsAdministrator()) + { + Text += " (administrator)"; + } + + lblInfo.Text = Text + " - " + currentVersionInfo.LegalCopyright; + + lbPlugins.Items.Add("lgtv.net by gr4b4z"); + lbPlugins.Items.Add("Newtonsoft.Json by James Newton-King"); + lbPlugins.Items.Add("NLog by Jarek Kowalski, Kim Christensen, Julian Verdurmen"); + lbPlugins.Items.Add("NvAPIWrapper.Net by Soroush Falahati"); + lbPlugins.Items.Add("NWin32 by zmjack"); + lbPlugins.Items.Add("TaskScheduler by David Hall"); + lbPlugins.Items.Add("NVIDIA Profile Inspector by Orbmu2k"); + lbPlugins.Items.Add("NvidiaML wrapper by LibreHardwareMonitor"); + lbPlugins.Items.Add("Novideo sRGB by ledoge"); + lbPlugins.Items.Add("NLogViewer by dojo90"); + lbPlugins.Items.Add("WPFDarkTheme by AngryCarrot789"); + + } + + } +} diff --git a/ColorControl/Forms/InfoPanel.resx b/ColorControl/Forms/InfoPanel.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ColorControl/Forms/InfoPanel.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ColorControl/MainForm.Designer.cs b/ColorControl/MainForm.Designer.cs index 5650991..c627d91 100644 --- a/ColorControl/MainForm.Designer.cs +++ b/ColorControl/MainForm.Designer.cs @@ -59,20 +59,12 @@ chkStartMinimized = new System.Windows.Forms.CheckBox(); chkStartAfterLogin = new System.Windows.Forms.CheckBox(); tabInfo = new System.Windows.Forms.TabPage(); - webView21 = new Microsoft.Web.WebView2.WinForms.WebView2(); - groupBox3 = new System.Windows.Forms.GroupBox(); - lbPlugins = new System.Windows.Forms.ListBox(); - label7 = new System.Windows.Forms.Label(); - lblInfo = new System.Windows.Forms.Label(); btnUpdate = new System.Windows.Forms.Button(); tcMain.SuspendLayout(); tabOptions.SuspendLayout(); grpOptionsModules.SuspendLayout(); grpMiscellaneousOptions.SuspendLayout(); grpGeneralOptions.SuspendLayout(); - tabInfo.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)webView21).BeginInit(); - groupBox3.SuspendLayout(); SuspendLayout(); // // tcMain @@ -110,7 +102,7 @@ grpOptionsModules.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); grpOptionsModules.Name = "grpOptionsModules"; grpOptionsModules.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - grpOptionsModules.Size = new System.Drawing.Size(522, 131); + grpOptionsModules.Size = new System.Drawing.Size(658, 131); grpOptionsModules.TabIndex = 11; grpOptionsModules.TabStop = false; grpOptionsModules.Text = "Modules"; @@ -147,7 +139,7 @@ grpMiscellaneousOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); grpMiscellaneousOptions.Name = "grpMiscellaneousOptions"; grpMiscellaneousOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - grpMiscellaneousOptions.Size = new System.Drawing.Size(522, 131); + grpMiscellaneousOptions.Size = new System.Drawing.Size(658, 131); grpMiscellaneousOptions.TabIndex = 5; grpMiscellaneousOptions.TabStop = false; grpMiscellaneousOptions.Text = "Miscellaneous"; @@ -229,7 +221,7 @@ grpGeneralOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); grpGeneralOptions.Name = "grpGeneralOptions"; grpGeneralOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - grpGeneralOptions.Size = new System.Drawing.Size(522, 211); + grpGeneralOptions.Size = new System.Drawing.Size(662, 211); grpGeneralOptions.TabIndex = 2; grpGeneralOptions.TabStop = false; grpGeneralOptions.Text = "General"; @@ -283,7 +275,7 @@ // btnStartStopService // btnStartStopService.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - btnStartStopService.Location = new System.Drawing.Point(474, 129); + btnStartStopService.Location = new System.Drawing.Point(614, 129); btnStartStopService.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnStartStopService.Name = "btnStartStopService"; btnStartStopService.Size = new System.Drawing.Size(40, 27); @@ -439,8 +431,6 @@ // // tabInfo // - tabInfo.Controls.Add(webView21); - tabInfo.Controls.Add(groupBox3); tabInfo.Location = new System.Drawing.Point(4, 24); tabInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); tabInfo.Name = "tabInfo"; @@ -450,65 +440,6 @@ tabInfo.Text = "Info"; tabInfo.UseVisualStyleBackColor = true; // - // webView21 - // - webView21.AllowExternalDrop = true; - webView21.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - webView21.CreationProperties = null; - webView21.DefaultBackgroundColor = System.Drawing.Color.White; - webView21.Location = new System.Drawing.Point(436, 7); - webView21.Name = "webView21"; - webView21.Size = new System.Drawing.Size(671, 526); - webView21.Source = new System.Uri("https://github.com/Maassoft/ColorControl/releases", System.UriKind.Absolute); - webView21.TabIndex = 6; - webView21.ZoomFactor = 1D; - // - // groupBox3 - // - groupBox3.Controls.Add(lbPlugins); - groupBox3.Controls.Add(label7); - groupBox3.Controls.Add(lblInfo); - groupBox3.Location = new System.Drawing.Point(7, 7); - groupBox3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - groupBox3.Name = "groupBox3"; - groupBox3.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - groupBox3.Size = new System.Drawing.Size(422, 271); - groupBox3.TabIndex = 5; - groupBox3.TabStop = false; - groupBox3.Text = "Info"; - // - // lbPlugins - // - lbPlugins.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - lbPlugins.FormattingEnabled = true; - lbPlugins.HorizontalScrollbar = true; - lbPlugins.ItemHeight = 15; - lbPlugins.Location = new System.Drawing.Point(10, 77); - lbPlugins.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - lbPlugins.Name = "lbPlugins"; - lbPlugins.Size = new System.Drawing.Size(405, 184); - lbPlugins.TabIndex = 3; - // - // label7 - // - label7.AutoSize = true; - label7.Location = new System.Drawing.Point(7, 59); - label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - label7.Name = "label7"; - label7.Size = new System.Drawing.Size(267, 15); - label7.TabIndex = 2; - label7.Text = "This app contains the following 3rd party plugins:"; - // - // lblInfo - // - lblInfo.AutoSize = true; - lblInfo.Location = new System.Drawing.Point(7, 23); - lblInfo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - lblInfo.Name = "lblInfo"; - lblInfo.Size = new System.Drawing.Size(28, 15); - lblInfo.TabIndex = 1; - lblInfo.Text = "Info"; - // // btnUpdate // btnUpdate.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; @@ -555,10 +486,6 @@ grpMiscellaneousOptions.PerformLayout(); grpGeneralOptions.ResumeLayout(false); grpGeneralOptions.PerformLayout(); - tabInfo.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)webView21).EndInit(); - groupBox3.ResumeLayout(false); - groupBox3.PerformLayout(); ResumeLayout(false); } @@ -570,10 +497,6 @@ private System.Windows.Forms.CheckBox chkStartMinimized; private System.Windows.Forms.CheckBox chkStartAfterLogin; private System.Windows.Forms.TabPage tabInfo; - private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.ListBox lbPlugins; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Label lblInfo; private System.Windows.Forms.GroupBox grpMiscellaneousOptions; private System.Windows.Forms.CheckBox chkFixChromeFonts; private System.Windows.Forms.Label lblFixChromeFontsDescription; @@ -599,7 +522,6 @@ private System.Windows.Forms.CheckBox chkOptionsUseDarkMode; private System.Windows.Forms.Button btnOptionsAdvanced; private System.Windows.Forms.Button btnOptionsLog; - private Microsoft.Web.WebView2.WinForms.WebView2 webView21; } } diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs index a48f044..8a04bdf 100644 --- a/ColorControl/MainForm.cs +++ b/ColorControl/MainForm.cs @@ -1,4 +1,5 @@ -using ColorControl.Services.AMD; +using ColorControl.Forms; +using ColorControl.Services.AMD; using ColorControl.Services.Common; using ColorControl.Services.EventDispatcher; using ColorControl.Services.GameLauncher; @@ -151,7 +152,6 @@ namespace ColorControl InitShortcut(SHORTCUTID_SCREENSAVER, _config.ScreenSaverShortcut, StartScreenSaver); InitModules(); - InitInfo(); UpdateServiceInfo(); _screenStateNotify = WinApi.RegisterPowerSettingNotification(Handle, ref Utils.GUID_CONSOLE_DISPLAY_STATE, 0); @@ -387,32 +387,6 @@ namespace ColorControl } } - private void InitInfo() - { - _currentVersionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath); - - Text = Application.ProductName + " " + Application.ProductVersion; - - if (_winApiService.IsAdministrator()) - { - Text += " (administrator)"; - } - - lblInfo.Text = Text + " - " + _currentVersionInfo.LegalCopyright; - - lbPlugins.Items.Add("lgtv.net by gr4b4z"); - lbPlugins.Items.Add("Newtonsoft.Json by James Newton-King"); - lbPlugins.Items.Add("NLog by Jarek Kowalski, Kim Christensen, Julian Verdurmen"); - lbPlugins.Items.Add("NvAPIWrapper.Net by Soroush Falahati"); - lbPlugins.Items.Add("NWin32 by zmjack"); - lbPlugins.Items.Add("TaskScheduler by David Hall"); - lbPlugins.Items.Add("NVIDIA Profile Inspector by Orbmu2k"); - lbPlugins.Items.Add("NvidiaML wrapper by LibreHardwareMonitor"); - lbPlugins.Items.Add("Novideo sRGB by ledoge"); - lbPlugins.Items.Add("NLogViewer by dojo90"); - lbPlugins.Items.Add("WPFDarkTheme by AngryCarrot789"); - } - private void OpenForm(object sender, EventArgs e) { Show(); @@ -770,6 +744,7 @@ NOTE: installing the service may cause a User Account Control popup."); { if (tcMain.SelectedTab == tabInfo) { + InitInfoTab(); } else if (tcMain.SelectedTab == tabOptions) { @@ -811,6 +786,21 @@ NOTE: installing the service may cause a User Account Control popup."); UpdateServiceInfo(); } + private void InitInfoTab() + { + if (tabInfo.Controls.Count > 0) + { + return; + } + var control = _serviceProvider.GetRequiredService(); + control.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + + tabInfo.Controls.Add(control); + + control.Size = tabInfo.ClientSize; + //control.BackColor = SystemColors.Window; + } + private void UpdateTrayMenu(ToolStripMenuItem menu, IEnumerable presets, EventHandler eventHandler) { menu.DropDownItems.Clear(); @@ -1291,7 +1281,7 @@ Currently ColorControl is {(_winApiService.IsAdministrator() ? "" : "not ")}runn //InstallUpdate(""); //await Test(); - _serviceManager.NvService.TestResolution(); + //_serviceManager.NvService.TestResolution(); } private async Task Test() diff --git a/ColorControl/Program.cs b/ColorControl/Program.cs index f9d5ae5..35fb9e2 100644 --- a/ColorControl/Program.cs +++ b/ColorControl/Program.cs @@ -59,9 +59,6 @@ namespace ColorControl { DataDir = Utils.GetDataPath(); - //Utils.UpdateFiles(@"H:\temp\ColorControl\ColorControl", @"C:\Users\vinni\source\repos\ColorControl\ColorControl\bin\Debug\net6.0-windows10.0.20348.0"); - //Utils.UnZipFile(@"H:\temp\ColorControl\ColorControl.zip", @"H:\temp\ColorControl\temp"); - var runAsService = args.Contains("--service") || WinApiService.IsAdministratorStatic() && Process.GetCurrentProcess().Parent()?.ProcessName?.Equals("services", StringComparison.InvariantCultureIgnoreCase) == true; var runElevated = args.Contains("--elevated"); @@ -260,6 +257,7 @@ namespace ColorControl services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); }); } private static async Task RunService(string[] args) diff --git a/ColorControl/Services/Common/PresetBase.cs b/ColorControl/Services/Common/PresetBase.cs index 13a77de..4b86706 100644 --- a/ColorControl/Services/Common/PresetBase.cs +++ b/ColorControl/Services/Common/PresetBase.cs @@ -1,5 +1,6 @@ using ColorControl.Shared.Common; using ColorControl.Shared.Contracts; +using NStandard; using System; using System.Collections.Generic; using System.ComponentModel; @@ -124,6 +125,7 @@ namespace ColorControl.Services.Common public List Triggers { get; set; } public string Description { get; set; } public bool ShowInQuickAccess { get; set; } + public string IdOrName => name.IsNullOrEmpty() ? _id.ToString() : name; private int _id; diff --git a/ColorControl/Services/LG/LgPanel.Designer.cs b/ColorControl/Services/LG/LgPanel.Designer.cs index b04a24c..6a8f2e5 100644 --- a/ColorControl/Services/LG/LgPanel.Designer.cs +++ b/ColorControl/Services/LG/LgPanel.Designer.cs @@ -389,14 +389,14 @@ mnuLgExpert.ImageScalingSize = new System.Drawing.Size(20, 20); mnuLgExpert.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuLgOLEDMotionPro, mnuLgSetSvcMenuFlag, miLgExpertSeparator1 }); mnuLgExpert.Name = "mnuLgButtons"; - mnuLgExpert.Size = new System.Drawing.Size(321, 76); + mnuLgExpert.Size = new System.Drawing.Size(328, 76); mnuLgExpert.Opening += mnuLgExpert_Opening; // // mnuLgOLEDMotionPro // mnuLgOLEDMotionPro.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miLgEnableMotionPro, miLgDisableMotionPro }); mnuLgOLEDMotionPro.Name = "mnuLgOLEDMotionPro"; - mnuLgOLEDMotionPro.Size = new System.Drawing.Size(320, 22); + mnuLgOLEDMotionPro.Size = new System.Drawing.Size(327, 22); mnuLgOLEDMotionPro.Text = "Activate OLED Motion Pro (B9/C9/E9/W9 only)"; // // miLgEnableMotionPro @@ -417,8 +417,8 @@ // mnuLgSetSvcMenuFlag.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miLgFullServiceMenuEnable, miLgFullServiceMenuDisable }); mnuLgSetSvcMenuFlag.Name = "mnuLgSetSvcMenuFlag"; - mnuLgSetSvcMenuFlag.Size = new System.Drawing.Size(320, 22); - mnuLgSetSvcMenuFlag.Text = "Enable Full Service Menu (B3/C3/G3 only)"; + mnuLgSetSvcMenuFlag.Size = new System.Drawing.Size(327, 22); + mnuLgSetSvcMenuFlag.Text = "Enable Full Service Menu (2022/2023 OLED only)"; // // miLgFullServiceMenuEnable // @@ -437,7 +437,7 @@ // miLgExpertSeparator1 // miLgExpertSeparator1.Name = "miLgExpertSeparator1"; - miLgExpertSeparator1.Size = new System.Drawing.Size(317, 6); + miLgExpertSeparator1.Size = new System.Drawing.Size(324, 6); // // chkLgRemoteControlShow // diff --git a/ColorControl/Services/LG/LgPanel.cs b/ColorControl/Services/LG/LgPanel.cs index 41e5375..82dd916 100644 --- a/ColorControl/Services/LG/LgPanel.cs +++ b/ColorControl/Services/LG/LgPanel.cs @@ -829,7 +829,7 @@ Do you want to continue?" mnuLgOLEDMotionPro.Visible = visible; miLgEnableMotionPro.Visible = enableVisible; - var svcMenuFlagVisible = new[] { "B3", "C3", "G3" }.Any(m => device?.ModelName?.Contains(m) == true); + var svcMenuFlagVisible = new[] { "B2", "C2", "G2", "B3", "C3", "G3" }.Any(m => device?.ModelName?.Contains(m) == true); mnuLgSetSvcMenuFlag.Visible = svcMenuFlagVisible; diff --git a/ColorControl/Services/NVIDIA/NvPanel.cs b/ColorControl/Services/NVIDIA/NvPanel.cs index b46d86b..5793aca 100644 --- a/ColorControl/Services/NVIDIA/NvPanel.cs +++ b/ColorControl/Services/NVIDIA/NvPanel.cs @@ -1819,31 +1819,23 @@ namespace ColorControl.Services.NVIDIA var presetIdOrName = !string.IsNullOrEmpty(startUpParams.NvidiaPresetIdOrName) ? startUpParams.NvidiaPresetIdOrName : _config.NvPresetId_ApplyOnStartup.ToString(); - if (!string.IsNullOrEmpty(presetIdOrName)) + if (string.IsNullOrEmpty(presetIdOrName)) { - var preset = _nvService?.GetPresetByIdOrName(presetIdOrName); - if (preset == null) - { - if (string.IsNullOrEmpty(startUpParams.NvidiaPresetIdOrName)) - { - _config.NvPresetId_ApplyOnStartup = 0; - } - } - else if (_nvService != null) - { - if (_nvService.HasDisplaysAttached()) - { - await ApplyNvPreset(preset); - return; - } - attempts--; - if (attempts > 0) - { - await Task.Delay(2000); - await ApplyNvPresetOnStartup(attempts); - } - } + return; } + + var preset = _nvService?.GetPresetByIdOrName(presetIdOrName); + if (preset == null) + { + if (string.IsNullOrEmpty(startUpParams.NvidiaPresetIdOrName)) + { + _config.NvPresetId_ApplyOnStartup = 0; + } + return; + } + + preset.IsStartupPreset = true; + await ApplyNvPreset(preset); } private void miNvDithering6bit_Click(object sender, EventArgs e) diff --git a/ColorControl/Services/NVIDIA/NvPreset.cs b/ColorControl/Services/NVIDIA/NvPreset.cs index fb87d36..ad04060 100644 --- a/ColorControl/Services/NVIDIA/NvPreset.cs +++ b/ColorControl/Services/NVIDIA/NvPreset.cs @@ -53,6 +53,8 @@ namespace ColorControl.Services.NVIDIA [JsonIgnore] public string InfoLine { get; set; } public NvDitherState DitherState => ditheringEnabled.HasValue ? ditheringEnabled == true ? NvDitherState.Enabled : NvDitherState.Disabled : NvDitherState.Auto; + [JsonIgnore] + public bool IsStartupPreset { get; set; } public NvPreset() : base() { diff --git a/ColorControl/Services/NVIDIA/NvService.cs b/ColorControl/Services/NVIDIA/NvService.cs index c80da57..90c633c 100644 --- a/ColorControl/Services/NVIDIA/NvService.cs +++ b/ColorControl/Services/NVIDIA/NvService.cs @@ -241,9 +241,11 @@ namespace ColorControl.Services.NVIDIA Utils.WriteObject(_presetsFilename, _presets); } - private void SetCurrentDisplay(NvPreset preset) + private Display SetCurrentDisplay(NvPreset preset) { _currentDisplay = GetPresetDisplay(preset); + + return _currentDisplay; } private Display GetPresetDisplay(NvPreset preset) @@ -284,22 +286,48 @@ namespace ColorControl.Services.NVIDIA } } - public override Task ApplyPreset(NvPreset preset) + private async Task WaitForDisplayAsync(NvPreset preset) + { + var attempt = 0; + Display display = null; + + while (attempt < 20) + { + if (HasDisplaysAttached()) + { + display = SetCurrentDisplay(preset); + } + + if (display != null) + { + break; + } + + if (preset.IsStartupPreset) + { + await Task.Delay(1000); + attempt++; + } + else + { + break; + } + } + + return display; + } + + public override async Task ApplyPreset(NvPreset preset) { var result = true; - if (!HasDisplaysAttached()) - { - return Task.FromResult(false); - } - - SetCurrentDisplay(preset); - - var display = GetCurrentDisplay(); + var display = await WaitForDisplayAsync(preset); if (display == null) { - return Task.FromResult(false); + Logger.Warn($"Cannot apply preset {preset.IdOrName} because the associated display is not active/found"); + + return false; } if (preset.applyOther && preset.scaling.HasValue) @@ -382,9 +410,11 @@ namespace ColorControl.Services.NVIDIA _lastAppliedPreset = preset; + preset.IsStartupPreset = false; + PresetApplied(); - return Task.FromResult(result); + return result; } public bool ApplyOverclocking(List settings) @@ -761,8 +791,8 @@ namespace ColorControl.Services.NVIDIA } var displayDevice = display.DisplayDevice; - var hdr = displayDevice.HDRColorData; - return hdr?.HDRMode == ColorDataHDRMode.UHDA; + var hdr = Logger.Swallow(() => displayDevice.HDRColorData?.HDRMode == ColorDataHDRMode.UHDA); + return hdr; } public void SetHdmiSettings(Display display, NvHdmiInfoFrameSettings settings) @@ -779,7 +809,7 @@ namespace ColorControl.Services.NVIDIA var infoValue = info.Value; var newInfo = new InfoFrameVideo( - infoValue.VideoIdentificationCode.Value, + infoValue.VideoIdentificationCode ?? 0xFF, InfoFrameVideoPixelRepetition.None, settings.ColorFormat ?? infoValue.ColorFormat, settings.Colorimetry ?? infoValue.Colorimetry, diff --git a/novideo_srgb/DisplayConfigManager.cs b/novideo_srgb/DisplayConfigManager.cs index 082521b..d180460 100644 --- a/novideo_srgb/DisplayConfigManager.cs +++ b/novideo_srgb/DisplayConfigManager.cs @@ -35,6 +35,11 @@ namespace novideo_srgb check(GetDisplayConfigBufferSizes(QDC.QDC_ONLY_ACTIVE_PATHS, out var pathCount, out var modeCount)); + if (pathCount == 0 || modeCount == 0) + { + return new HashSet(); + } + var paths = new DISPLAYCONFIG_PATH_INFO[pathCount]; var modes = new DISPLAYCONFIG_MODE_INFO[modeCount];