diff --git a/ColorControl/MainForm.Designer.cs b/ColorControl/MainForm.Designer.cs index 50383c6..57eb1fb 100644 --- a/ColorControl/MainForm.Designer.cs +++ b/ColorControl/MainForm.Designer.cs @@ -28,7 +28,6 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.tcMain = new System.Windows.Forms.TabControl(); this.tabNVIDIA = new System.Windows.Forms.TabPage(); @@ -36,15 +35,6 @@ this.tabLG = new System.Windows.Forms.TabPage(); this.tabGameLauncher = new System.Windows.Forms.TabPage(); this.tabOptions = new System.Windows.Forms.TabPage(); - this.grpNvidiaOptions = new System.Windows.Forms.GroupBox(); - this.lblDitheringDisplay = new System.Windows.Forms.Label(); - this.cbxDitheringDisplay = new System.Windows.Forms.ComboBox(); - this.lblDitheringMode = new System.Windows.Forms.Label(); - this.cbxDitheringMode = new System.Windows.Forms.ComboBox(); - this.lblDitheringBitDepth = new System.Windows.Forms.Label(); - this.cbxDitheringBitDepth = new System.Windows.Forms.ComboBox(); - this.chkDitheringEnabled = new System.Windows.Forms.CheckBox(); - this.pbGradient = new System.Windows.Forms.PictureBox(); this.grpMiscellaneousOptions = new System.Windows.Forms.GroupBox(); this.btnSetShortcutScreenSaver = new System.Windows.Forms.Button(); this.label11 = new System.Windows.Forms.Label(); @@ -94,8 +84,6 @@ this.btnUpdate = new System.Windows.Forms.Button(); this.tcMain.SuspendLayout(); this.tabOptions.SuspendLayout(); - this.grpNvidiaOptions.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pbGradient)).BeginInit(); this.grpMiscellaneousOptions.SuspendLayout(); this.grpLGOptions.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.edtLgOptionShutdownDelay)).BeginInit(); @@ -172,7 +160,6 @@ // // tabOptions // - this.tabOptions.Controls.Add(this.grpNvidiaOptions); this.tabOptions.Controls.Add(this.grpMiscellaneousOptions); this.tabOptions.Controls.Add(this.grpLGOptions); this.tabOptions.Controls.Add(this.grpGeneralOptions); @@ -185,120 +172,6 @@ this.tabOptions.Text = "Options"; this.tabOptions.UseVisualStyleBackColor = true; // - // grpNvidiaOptions - // - this.grpNvidiaOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.grpNvidiaOptions.Controls.Add(this.lblDitheringDisplay); - this.grpNvidiaOptions.Controls.Add(this.cbxDitheringDisplay); - this.grpNvidiaOptions.Controls.Add(this.lblDitheringMode); - this.grpNvidiaOptions.Controls.Add(this.cbxDitheringMode); - this.grpNvidiaOptions.Controls.Add(this.lblDitheringBitDepth); - this.grpNvidiaOptions.Controls.Add(this.cbxDitheringBitDepth); - this.grpNvidiaOptions.Controls.Add(this.chkDitheringEnabled); - this.grpNvidiaOptions.Controls.Add(this.pbGradient); - this.grpNvidiaOptions.Location = new System.Drawing.Point(537, 7); - this.grpNvidiaOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.grpNvidiaOptions.Name = "grpNvidiaOptions"; - this.grpNvidiaOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.grpNvidiaOptions.Size = new System.Drawing.Size(569, 365); - this.grpNvidiaOptions.TabIndex = 6; - this.grpNvidiaOptions.TabStop = false; - this.grpNvidiaOptions.Text = "NVIDIA options - test dithering"; - // - // lblDitheringDisplay - // - this.lblDitheringDisplay.AutoSize = true; - this.lblDitheringDisplay.Location = new System.Drawing.Point(7, 23); - this.lblDitheringDisplay.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lblDitheringDisplay.Name = "lblDitheringDisplay"; - this.lblDitheringDisplay.Size = new System.Drawing.Size(48, 15); - this.lblDitheringDisplay.TabIndex = 9; - this.lblDitheringDisplay.Text = "Display:"; - // - // cbxDitheringDisplay - // - this.cbxDitheringDisplay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbxDitheringDisplay.FormattingEnabled = true; - this.cbxDitheringDisplay.Location = new System.Drawing.Point(75, 17); - this.cbxDitheringDisplay.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.cbxDitheringDisplay.Name = "cbxDitheringDisplay"; - this.cbxDitheringDisplay.Size = new System.Drawing.Size(212, 23); - this.cbxDitheringDisplay.TabIndex = 8; - this.cbxDitheringDisplay.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringDisplay_SelectedIndexChanged); - // - // lblDitheringMode - // - this.lblDitheringMode.AutoSize = true; - this.lblDitheringMode.Location = new System.Drawing.Point(7, 105); - this.lblDitheringMode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lblDitheringMode.Name = "lblDitheringMode"; - this.lblDitheringMode.Size = new System.Drawing.Size(41, 15); - this.lblDitheringMode.TabIndex = 7; - this.lblDitheringMode.Text = "Mode:"; - // - // cbxDitheringMode - // - this.cbxDitheringMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbxDitheringMode.FormattingEnabled = true; - this.cbxDitheringMode.Location = new System.Drawing.Point(75, 99); - this.cbxDitheringMode.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.cbxDitheringMode.Name = "cbxDitheringMode"; - this.cbxDitheringMode.Size = new System.Drawing.Size(136, 23); - this.cbxDitheringMode.TabIndex = 6; - this.cbxDitheringMode.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringMode_SelectedIndexChanged); - // - // lblDitheringBitDepth - // - this.lblDitheringBitDepth.AutoSize = true; - this.lblDitheringBitDepth.Location = new System.Drawing.Point(7, 74); - this.lblDitheringBitDepth.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lblDitheringBitDepth.Name = "lblDitheringBitDepth"; - this.lblDitheringBitDepth.Size = new System.Drawing.Size(60, 15); - this.lblDitheringBitDepth.TabIndex = 5; - this.lblDitheringBitDepth.Text = "Bit-depth:"; - // - // cbxDitheringBitDepth - // - this.cbxDitheringBitDepth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbxDitheringBitDepth.FormattingEnabled = true; - this.cbxDitheringBitDepth.Location = new System.Drawing.Point(75, 68); - this.cbxDitheringBitDepth.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.cbxDitheringBitDepth.Name = "cbxDitheringBitDepth"; - this.cbxDitheringBitDepth.Size = new System.Drawing.Size(136, 23); - this.cbxDitheringBitDepth.TabIndex = 4; - this.cbxDitheringBitDepth.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringBitDepth_SelectedIndexChanged); - // - // chkDitheringEnabled - // - this.chkDitheringEnabled.AutoSize = true; - this.chkDitheringEnabled.Checked = true; - this.chkDitheringEnabled.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkDitheringEnabled.Location = new System.Drawing.Point(7, 46); - this.chkDitheringEnabled.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.chkDitheringEnabled.Name = "chkDitheringEnabled"; - this.chkDitheringEnabled.Size = new System.Drawing.Size(120, 19); - this.chkDitheringEnabled.TabIndex = 3; - this.chkDitheringEnabled.Text = "Dithering enabled"; - this.chkDitheringEnabled.ThreeState = true; - this.chkDitheringEnabled.UseVisualStyleBackColor = true; - this.chkDitheringEnabled.CheckStateChanged += new System.EventHandler(this.chkDitheringEnabled_CheckStateChanged); - // - // pbGradient - // - this.pbGradient.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pbGradient.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pbGradient.Location = new System.Drawing.Point(7, 128); - this.pbGradient.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.pbGradient.Name = "pbGradient"; - this.pbGradient.Size = new System.Drawing.Size(555, 228); - this.pbGradient.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pbGradient.TabIndex = 0; - this.pbGradient.TabStop = false; - // // grpMiscellaneousOptions // this.grpMiscellaneousOptions.Controls.Add(this.btnSetShortcutScreenSaver); @@ -921,9 +794,6 @@ this.Resize += new System.EventHandler(this.MainForm_Resize); this.tcMain.ResumeLayout(false); this.tabOptions.ResumeLayout(false); - this.grpNvidiaOptions.ResumeLayout(false); - this.grpNvidiaOptions.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pbGradient)).EndInit(); this.grpMiscellaneousOptions.ResumeLayout(false); this.grpMiscellaneousOptions.PerformLayout(); this.grpLGOptions.ResumeLayout(false); @@ -960,7 +830,6 @@ private System.Windows.Forms.GroupBox grpNVIDIAInfo; private System.Windows.Forms.TreeView tvNVIDIAInfo; private System.Windows.Forms.Button btnRefreshNVIDIAInfo; - private System.Windows.Forms.ContextMenuStrip mnuLgButtons; private System.Windows.Forms.GroupBox grpLGOptions; private System.Windows.Forms.NumericUpDown edtLgMaxPowerOnRetries; private System.Windows.Forms.Label lblLgMaxPowerOnRetries; @@ -976,23 +845,7 @@ private System.Windows.Forms.TabPage tabNVIDIA; private System.Windows.Forms.TabPage tabAMD; private System.Windows.Forms.Button btnClearLog; - private System.Windows.Forms.GroupBox grpNvidiaOptions; - private System.Windows.Forms.PictureBox pbGradient; - private System.Windows.Forms.Label lblDitheringMode; - private System.Windows.Forms.ComboBox cbxDitheringMode; - private System.Windows.Forms.Label lblDitheringBitDepth; - private System.Windows.Forms.ComboBox cbxDitheringBitDepth; - private System.Windows.Forms.CheckBox chkDitheringEnabled; - private System.Windows.Forms.ToolStripMenuItem mnuLgRcButtons; - private System.Windows.Forms.ToolStripMenuItem mnuLgActions; private System.Windows.Forms.CheckBox chkMinimizeToSystemTray; - private System.Windows.Forms.ContextMenuStrip mnuLgExpert; - private System.Windows.Forms.ToolStripMenuItem mnuLgOLEDMotionPro; - private System.Windows.Forms.ToolStripMenuItem miLgEnableMotionPro; - private System.Windows.Forms.ToolStripMenuItem miLgDisableMotionPro; - private System.Windows.Forms.ToolStripSeparator miLgExpertSeparator1; - private System.Windows.Forms.ToolStripMenuItem mnuLgNvPresets; - private System.Windows.Forms.ToolStripMenuItem mnuLgAmdPresets; private System.Windows.Forms.CheckBox chkCheckForUpdates; private System.Windows.Forms.CheckBox chkLgShowAdvancedActions; private System.Windows.Forms.CheckBox chkGdiScaling; @@ -1001,7 +854,6 @@ private System.Windows.Forms.Label lblLgOptionShutdownDelay; private System.Windows.Forms.Label lblGameBarShortcut; private System.Windows.Forms.TextBox edtLgGameBarShortcut; - private System.Windows.Forms.ToolStripMenuItem mnuLgProgram; private System.Windows.Forms.TabPage tabGameLauncher; private System.Windows.Forms.RadioButton rbElevationService; private System.Windows.Forms.RadioButton rbElevationProcess; @@ -1015,8 +867,6 @@ private System.Windows.Forms.CheckBox chkAutoInstallUpdates; private System.Windows.Forms.CheckBox chkLgSetSelectedDeviceByPowerOn; private System.Windows.Forms.Button btnUpdate; - private System.Windows.Forms.Label lblDitheringDisplay; - private System.Windows.Forms.ComboBox cbxDitheringDisplay; } } diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs index 5a1de6a..826acb5 100644 --- a/ColorControl/MainForm.cs +++ b/ColorControl/MainForm.cs @@ -29,11 +29,6 @@ namespace ColorControl private static bool EndSession = false; private static bool UserExit = false; private static int SHORTCUTID_SCREENSAVER = -100; - private static int SHORTCUTID_GAMEBAR = -101; - private static int SHORTCUTID_NVQA = -200; - private static int SHORTCUTID_AMDQA = -201; - private static int SHORTCUTID_LGQA = -202; - private static int SHORTCUTID_GAMEQA = -203; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -41,10 +36,10 @@ namespace ColorControl private NvService _nvService; private NvPanel _nvPanel; + private NvDitherPanel _nvDitherPanel; private NotifyIcon _trayIcon; private bool _initialized = false; - private bool _disableEvents = false; private Config _config; private bool _setVisibleCalled = false; @@ -65,11 +60,8 @@ namespace ColorControl private FileVersionInfo _currentVersionInfo; private bool _checkedForUpdates = false; private string _updateHtmlUrl; - private bool _updatingDitherSettings; private string _downloadUrl; - private LgGameBar _gameBarForm; - private GameService _gameService; private GamePanel _gamePanel; @@ -195,7 +187,7 @@ namespace ColorControl tabNVIDIA.Controls.Add(_nvPanel); - InitShortcut(SHORTCUTID_NVQA, _config.NvQuickAccessShortcut, _nvService.ToggleQuickAccessForm); + InitShortcut(NvPanel.SHORTCUTID_NVQA, _config.NvQuickAccessShortcut, _nvService.ToggleQuickAccessForm); } catch (Exception ex) { @@ -217,7 +209,7 @@ namespace ColorControl tabAMD.Controls.Add(_amdPanel); - InitShortcut(SHORTCUTID_AMDQA, _config.AmdQuickAccessShortcut, _amdService.ToggleQuickAccessForm); + InitShortcut(AmdPanel.SHORTCUTID_AMDQA, _config.AmdQuickAccessShortcut, _amdService.ToggleQuickAccessForm); } catch (Exception) { @@ -239,7 +231,7 @@ namespace ColorControl tabGameLauncher.Controls.Add(_gamePanel); - InitShortcut(SHORTCUTID_GAMEQA, _config.GameQuickAccessShortcut, _gameService.ToggleQuickAccessForm); + InitShortcut(GamePanel.SHORTCUTID_GAMEQA, _config.GameQuickAccessShortcut, _gameService.ToggleQuickAccessForm); } catch (Exception e) { @@ -271,14 +263,16 @@ namespace ColorControl tabLG.Controls.Add(_lgPanel); + _lgPanel.Init(); + edtLgMaxPowerOnRetries.Value = _lgService.Config.PowerOnRetries; edtLgOptionShutdownDelay.Value = _lgService.Config.ShutdownDelay; chkLgShowAdvancedActions.Checked = _lgService.Config.ShowAdvancedActions; chkLgSetSelectedDeviceByPowerOn.Checked = _lgService.Config.SetSelectedDeviceByPowerOn; LgDevice.ExternalServiceHandler = HandleExternalServiceForLgDevice; - InitShortcut(SHORTCUTID_GAMEBAR, _lgService.Config.GameBarShortcut, _lgPanel.ToggleGameBar); - InitShortcut(SHORTCUTID_LGQA, _config.LgQuickAccessShortcut, _lgService.ToggleQuickAccessForm); + InitShortcut(LgPanel.SHORTCUTID_GAMEBAR, _lgService.Config.GameBarShortcut, _lgPanel.ToggleGameBar); + InitShortcut(LgPanel.SHORTCUTID_LGQA, _config.LgQuickAccessShortcut, _lgService.ToggleQuickAccessForm); if (!string.IsNullOrEmpty(_lgService.Config.GameBarShortcut)) { @@ -768,29 +762,17 @@ NOTE: installing the service may cause a User Account Control popup."); private void InitOptionsTab() { - grpNvidiaOptions.Visible = _nvService != null; - if (grpNvidiaOptions.Visible) + if (_nvService != null && _nvDitherPanel == null) { - if (cbxDitheringBitDepth.Items.Count == 0) - { - cbxDitheringBitDepth.Items.AddRange(Utils.GetDescriptions().ToArray()); - cbxDitheringMode.Items.AddRange(Utils.GetDescriptions().ToArray()); - FillGradient(); - } + _nvDitherPanel = new NvDitherPanel(_nvService); - if (cbxDitheringDisplay.Items.Count == 0) - { - var displays = _nvService.GetDisplayInfos(); - var primaryDisplay = _nvService.GetPrimaryDisplay(); - var primaryDisplayInfo = displays.FirstOrDefault(d => d.Display == primaryDisplay); - var index = primaryDisplayInfo != null ? displays.IndexOf(primaryDisplayInfo) : 0; + tabOptions.Controls.Add(_nvDitherPanel); - cbxDitheringDisplay.Items.AddRange(displays.ToArray()); + _nvDitherPanel.Top = grpGeneralOptions.Top; + _nvDitherPanel.Left = grpGeneralOptions.Left + grpGeneralOptions.Width + 4; + _nvDitherPanel.Width = tabOptions.Width - _nvDitherPanel.Left - 4; - cbxDitheringDisplay.SelectedIndex = index; - } - - UpdateDitherSettings(); + _nvDitherPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; } _initialized = false; @@ -813,35 +795,6 @@ NOTE: installing the service may cause a User Account Control popup."); UpdateServiceInfo(); } - private void UpdateDitherSettings() - { - var display = ((NvDisplayInfo)cbxDitheringDisplay.SelectedItem)?.Display; - var ditherInfo = _nvService.GetDithering(display); - - if (ditherInfo.state == -1) - { - MessageForms.ErrorOk("Error retrieving dithering settings. See log for details."); - return; - } - - var state = (NvDitherState)ditherInfo.state; - - _updatingDitherSettings = true; - try - { - chkDitheringEnabled.CheckState = state switch { NvDitherState.Enabled => CheckState.Checked, NvDitherState.Disabled => CheckState.Unchecked, _ => CheckState.Indeterminate }; - cbxDitheringBitDepth.SelectedIndex = ditherInfo.bits; - cbxDitheringMode.SelectedIndex = ditherInfo.mode; - - cbxDitheringBitDepth.Enabled = state == NvDitherState.Enabled; - cbxDitheringMode.Enabled = state == NvDitherState.Enabled; - } - finally - { - _updatingDitherSettings = false; - } - } - private void UpdateTrayMenu(ToolStripMenuItem menu, IEnumerable presets, EventHandler eventHandler) { menu.DropDownItems.Clear(); @@ -1083,42 +1036,6 @@ Do you want to continue?"; edtLog.Clear(); } - private void FillGradient() - { - if (pbGradient.Image == null) - { - pbGradient.Image = Utils.GenerateGradientBitmap(pbGradient.Width, pbGradient.Height); - } - } - - private void ApplyDitheringOptions() - { - if (_updatingDitherSettings) - { - return; - } - - var state = chkDitheringEnabled.CheckState switch { CheckState.Checked => NvDitherState.Enabled, CheckState.Unchecked => NvDitherState.Disabled, _ => NvDitherState.Auto }; - var bitDepth = cbxDitheringBitDepth.SelectedIndex; - var mode = cbxDitheringMode.SelectedIndex; - var display = ((NvDisplayInfo)cbxDitheringDisplay.SelectedItem)?.Display; - - if (_nvService.SetDithering(state, (uint)bitDepth, (uint)(mode > -1 ? mode : (int)NvDitherMode.Temporal), currentDisplay: display) && state == NvDitherState.Auto) - { - UpdateDitherSettings(); - } - } - - private void cbxDitheringBitDepth_SelectedIndexChanged(object sender, EventArgs e) - { - ApplyDitheringOptions(); - } - - private void cbxDitheringMode_SelectedIndexChanged(object sender, EventArgs e) - { - ApplyDitheringOptions(); - } - private void AfterInitialized() { _nvPanel?.AfterInitialized(); @@ -1305,25 +1222,6 @@ The InStart and Software Update items are now visible under the Expert-button." ResumeLayout(true); } - private void chkDitheringEnabled_CheckStateChanged(object sender, EventArgs e) - { - cbxDitheringBitDepth.Enabled = chkDitheringEnabled.CheckState == CheckState.Checked; - cbxDitheringMode.Enabled = chkDitheringEnabled.CheckState == CheckState.Checked; - - ApplyDitheringOptions(); - } - - private void btnLgDeviceOptionsHelp_Click(object sender, EventArgs e) - { - MessageForms.InfoOk( -@"Notes: -- power on after startup requires ""Automatically start after login"" - see Options -- power on after resume from standby may need some retries for waking TV - see Options -- power off on shutdown: because this app cannot detect a restart, restarting could also trigger this. Hold down Ctrl on restart to prevent power off. -- Use Windows power settings: powering on/off of TV will follow Windows settings. If activated, it's better to disable all other power options except power off on shutdown. -"); - } - private void edtLgOptionShutdownDelay_ValueChanged(object sender, EventArgs e) { _lgService.Config.ShutdownDelay = (int)edtLgOptionShutdownDelay.Value; @@ -1507,16 +1405,6 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad _trayIcon.Visible = false; } - private void cbxDitheringDisplay_SelectedIndexChanged(object sender, EventArgs e) - { - if (!_initialized) - { - return; - } - - UpdateDitherSettings(); - } - private void edtLgPowerOnAfterResumeDelay_ValueChanged(object sender, EventArgs e) { _lgService.Config.PowerOnRetries = (int)edtLgMaxPowerOnRetries.Value; @@ -1571,11 +1459,11 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad if (string.IsNullOrEmpty(text)) { - WinApi.UnregisterHotKey(Handle, SHORTCUTID_GAMEBAR); + WinApi.UnregisterHotKey(Handle, LgPanel.SHORTCUTID_GAMEBAR); } else { - Utils.RegisterShortcut(Handle, SHORTCUTID_GAMEBAR, text); + Utils.RegisterShortcut(Handle, LgPanel.SHORTCUTID_GAMEBAR, text); } } } diff --git a/ColorControl/MainForm.resx b/ColorControl/MainForm.resx index 83c5e62..dc5a7dd 100644 --- a/ColorControl/MainForm.resx +++ b/ColorControl/MainForm.resx @@ -57,12 +57,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 583, 17 - - - 147, 17 - diff --git a/ColorControl/Services/AMD/AmdPanel.cs b/ColorControl/Services/AMD/AmdPanel.cs index a18f7e9..f95af44 100644 --- a/ColorControl/Services/AMD/AmdPanel.cs +++ b/ColorControl/Services/AMD/AmdPanel.cs @@ -15,7 +15,7 @@ namespace ColorControl.Services.AMD { public partial class AmdPanel : UserControl { - private static int SHORTCUTID_AMDQA = -201; + public static readonly int SHORTCUTID_AMDQA = -201; private AmdService _amdService; private NotifyIcon _trayIcon; diff --git a/ColorControl/Services/GameLauncher/GamePanel.cs b/ColorControl/Services/GameLauncher/GamePanel.cs index 40e9e6e..0bac8b0 100644 --- a/ColorControl/Services/GameLauncher/GamePanel.cs +++ b/ColorControl/Services/GameLauncher/GamePanel.cs @@ -19,7 +19,7 @@ namespace ColorControl.Services.GameLauncher { public partial class GamePanel : UserControl { - private static int SHORTCUTID_GAMEQA = -203; + public static readonly int SHORTCUTID_GAMEQA = -203; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/ColorControl/Services/LG/LgPanel.cs b/ColorControl/Services/LG/LgPanel.cs index de688bc..0fa13ce 100644 --- a/ColorControl/Services/LG/LgPanel.cs +++ b/ColorControl/Services/LG/LgPanel.cs @@ -19,8 +19,8 @@ namespace ColorControl.Services.LG { public partial class LgPanel : UserControl { - private static int SHORTCUTID_LGQA = -202; - private static int SHORTCUTID_GAMEBAR = -101; + public static readonly int SHORTCUTID_LGQA = -202; + public static readonly int SHORTCUTID_GAMEBAR = -101; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -69,11 +69,9 @@ namespace ColorControl.Services.LG var item = mnuLgRcButtons.DropDownItems.Add(text); item.Click += miLgAddButton_Click; } - - Load += LgPanel_Load; } - private void LgPanel_Load(object sender, EventArgs e) + public void Init() { _lgService.RefreshDevices(afterStartUp: true).ContinueWith((_) => BeginInvoke(() => AfterLgServiceRefreshDevices())); @@ -1163,37 +1161,5 @@ Do you want to continue?" { FormUtils.ListViewItemChecked(lvLgPresets, e); } - - private void lvNvPresets_ItemCheck(object sender, ItemCheckEventArgs e) - { - var listView = sender as System.Windows.Forms.ListView; - - if (!listView.Focused) - { - return; - } - - - var point = listView.PointToClient(Cursor.Position); - - if (point.X >= 20) - { - return; - } - - var listItem = listView.Items[e.Index]; - - if (listItem.Tag == null) - { - MessageForms.WarningOk("Quick Access cannot be enabled for this item."); - e.NewValue = e.CurrentValue; - } - - if (e.NewValue == CheckState.Checked && string.IsNullOrEmpty(listItem.Text)) - { - MessageForms.WarningOk("A name must be entered before enabling Quick Access."); - e.NewValue = e.CurrentValue; - } - } } } diff --git a/ColorControl/Services/NVIDIA/NvDitherPanel.Designer.cs b/ColorControl/Services/NVIDIA/NvDitherPanel.Designer.cs new file mode 100644 index 0000000..2aafc39 --- /dev/null +++ b/ColorControl/Services/NVIDIA/NvDitherPanel.Designer.cs @@ -0,0 +1,184 @@ +namespace ColorControl.Services.NVIDIA +{ + partial class NvDitherPanel + { + /// + /// 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() + { + this.grpNvidiaOptions = new System.Windows.Forms.GroupBox(); + this.lblDitheringDisplay = new System.Windows.Forms.Label(); + this.cbxDitheringDisplay = new System.Windows.Forms.ComboBox(); + this.lblDitheringMode = new System.Windows.Forms.Label(); + this.cbxDitheringMode = new System.Windows.Forms.ComboBox(); + this.lblDitheringBitDepth = new System.Windows.Forms.Label(); + this.cbxDitheringBitDepth = new System.Windows.Forms.ComboBox(); + this.chkDitheringEnabled = new System.Windows.Forms.CheckBox(); + this.pbGradient = new System.Windows.Forms.PictureBox(); + this.grpNvidiaOptions.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbGradient)).BeginInit(); + this.SuspendLayout(); + // + // grpNvidiaOptions + // + this.grpNvidiaOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.grpNvidiaOptions.Controls.Add(this.lblDitheringDisplay); + this.grpNvidiaOptions.Controls.Add(this.cbxDitheringDisplay); + this.grpNvidiaOptions.Controls.Add(this.lblDitheringMode); + this.grpNvidiaOptions.Controls.Add(this.cbxDitheringMode); + this.grpNvidiaOptions.Controls.Add(this.lblDitheringBitDepth); + this.grpNvidiaOptions.Controls.Add(this.cbxDitheringBitDepth); + this.grpNvidiaOptions.Controls.Add(this.chkDitheringEnabled); + this.grpNvidiaOptions.Controls.Add(this.pbGradient); + this.grpNvidiaOptions.Location = new System.Drawing.Point(4, 3); + this.grpNvidiaOptions.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpNvidiaOptions.Name = "grpNvidiaOptions"; + this.grpNvidiaOptions.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.grpNvidiaOptions.Size = new System.Drawing.Size(856, 479); + this.grpNvidiaOptions.TabIndex = 6; + this.grpNvidiaOptions.TabStop = false; + this.grpNvidiaOptions.Text = "NVIDIA options - test dithering"; + // + // lblDitheringDisplay + // + this.lblDitheringDisplay.AutoSize = true; + this.lblDitheringDisplay.Location = new System.Drawing.Point(8, 23); + this.lblDitheringDisplay.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblDitheringDisplay.Name = "lblDitheringDisplay"; + this.lblDitheringDisplay.Size = new System.Drawing.Size(48, 15); + this.lblDitheringDisplay.TabIndex = 9; + this.lblDitheringDisplay.Text = "Display:"; + // + // cbxDitheringDisplay + // + this.cbxDitheringDisplay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbxDitheringDisplay.FormattingEnabled = true; + this.cbxDitheringDisplay.Location = new System.Drawing.Point(75, 17); + this.cbxDitheringDisplay.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.cbxDitheringDisplay.Name = "cbxDitheringDisplay"; + this.cbxDitheringDisplay.Size = new System.Drawing.Size(212, 23); + this.cbxDitheringDisplay.TabIndex = 8; + this.cbxDitheringDisplay.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringDisplay_SelectedIndexChanged); + // + // lblDitheringMode + // + this.lblDitheringMode.AutoSize = true; + this.lblDitheringMode.Location = new System.Drawing.Point(8, 105); + this.lblDitheringMode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblDitheringMode.Name = "lblDitheringMode"; + this.lblDitheringMode.Size = new System.Drawing.Size(41, 15); + this.lblDitheringMode.TabIndex = 7; + this.lblDitheringMode.Text = "Mode:"; + // + // cbxDitheringMode + // + this.cbxDitheringMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbxDitheringMode.FormattingEnabled = true; + this.cbxDitheringMode.Location = new System.Drawing.Point(75, 99); + this.cbxDitheringMode.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.cbxDitheringMode.Name = "cbxDitheringMode"; + this.cbxDitheringMode.Size = new System.Drawing.Size(136, 23); + this.cbxDitheringMode.TabIndex = 6; + this.cbxDitheringMode.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringMode_SelectedIndexChanged); + // + // lblDitheringBitDepth + // + this.lblDitheringBitDepth.AutoSize = true; + this.lblDitheringBitDepth.Location = new System.Drawing.Point(8, 74); + this.lblDitheringBitDepth.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblDitheringBitDepth.Name = "lblDitheringBitDepth"; + this.lblDitheringBitDepth.Size = new System.Drawing.Size(60, 15); + this.lblDitheringBitDepth.TabIndex = 5; + this.lblDitheringBitDepth.Text = "Bit-depth:"; + // + // cbxDitheringBitDepth + // + this.cbxDitheringBitDepth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbxDitheringBitDepth.FormattingEnabled = true; + this.cbxDitheringBitDepth.Location = new System.Drawing.Point(75, 68); + this.cbxDitheringBitDepth.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.cbxDitheringBitDepth.Name = "cbxDitheringBitDepth"; + this.cbxDitheringBitDepth.Size = new System.Drawing.Size(136, 23); + this.cbxDitheringBitDepth.TabIndex = 4; + this.cbxDitheringBitDepth.SelectedIndexChanged += new System.EventHandler(this.cbxDitheringBitDepth_SelectedIndexChanged); + // + // chkDitheringEnabled + // + this.chkDitheringEnabled.AutoSize = true; + this.chkDitheringEnabled.Checked = true; + this.chkDitheringEnabled.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkDitheringEnabled.Location = new System.Drawing.Point(8, 46); + this.chkDitheringEnabled.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.chkDitheringEnabled.Name = "chkDitheringEnabled"; + this.chkDitheringEnabled.Size = new System.Drawing.Size(120, 19); + this.chkDitheringEnabled.TabIndex = 3; + this.chkDitheringEnabled.Text = "Dithering enabled"; + this.chkDitheringEnabled.ThreeState = true; + this.chkDitheringEnabled.UseVisualStyleBackColor = true; + this.chkDitheringEnabled.CheckStateChanged += new System.EventHandler(this.chkDitheringEnabled_CheckStateChanged); + // + // pbGradient + // + this.pbGradient.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pbGradient.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pbGradient.Location = new System.Drawing.Point(8, 128); + this.pbGradient.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.pbGradient.Name = "pbGradient"; + this.pbGradient.Size = new System.Drawing.Size(840, 345); + this.pbGradient.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pbGradient.TabIndex = 0; + this.pbGradient.TabStop = false; + // + // NvDitherPanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.grpNvidiaOptions); + this.Name = "NvDitherPanel"; + this.Size = new System.Drawing.Size(864, 485); + this.grpNvidiaOptions.ResumeLayout(false); + this.grpNvidiaOptions.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbGradient)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox grpNvidiaOptions; + private System.Windows.Forms.PictureBox pbGradient; + private System.Windows.Forms.Label lblDitheringMode; + private System.Windows.Forms.ComboBox cbxDitheringMode; + private System.Windows.Forms.Label lblDitheringBitDepth; + private System.Windows.Forms.ComboBox cbxDitheringBitDepth; + private System.Windows.Forms.CheckBox chkDitheringEnabled; + private System.Windows.Forms.Label lblDitheringDisplay; + private System.Windows.Forms.ComboBox cbxDitheringDisplay; + } +} diff --git a/ColorControl/Services/NVIDIA/NvDitherPanel.cs b/ColorControl/Services/NVIDIA/NvDitherPanel.cs new file mode 100644 index 0000000..45258bd --- /dev/null +++ b/ColorControl/Services/NVIDIA/NvDitherPanel.cs @@ -0,0 +1,128 @@ +using ColorControl.Common; +using ColorControl.Forms; +using System; +using System.Linq; +using System.Windows.Forms; + +namespace ColorControl.Services.NVIDIA +{ + public partial class NvDitherPanel : UserControl + { + private NvService _nvService; + private bool _updatingDitherSettings; + private bool _initialized; + + internal NvDitherPanel(NvService nvService) + { + _nvService = nvService; + + InitializeComponent(); + + if (cbxDitheringBitDepth.Items.Count == 0) + { + cbxDitheringBitDepth.Items.AddRange(Utils.GetDescriptions().ToArray()); + cbxDitheringMode.Items.AddRange(Utils.GetDescriptions().ToArray()); + FillGradient(); + } + + if (cbxDitheringDisplay.Items.Count == 0) + { + var displays = _nvService.GetDisplayInfos(); + var primaryDisplay = _nvService.GetPrimaryDisplay(); + var primaryDisplayInfo = displays.FirstOrDefault(d => d.Display == primaryDisplay); + var index = primaryDisplayInfo != null ? displays.IndexOf(primaryDisplayInfo) : 0; + + cbxDitheringDisplay.Items.AddRange(displays.ToArray()); + + cbxDitheringDisplay.SelectedIndex = index; + } + + UpdateDitherSettings(); + + _initialized = true; + } + + private void UpdateDitherSettings() + { + var display = ((NvDisplayInfo)cbxDitheringDisplay.SelectedItem)?.Display; + var ditherInfo = _nvService.GetDithering(display); + + if (ditherInfo.state == -1) + { + MessageForms.ErrorOk("Error retrieving dithering settings. See log for details."); + return; + } + + var state = (NvDitherState)ditherInfo.state; + + _updatingDitherSettings = true; + try + { + chkDitheringEnabled.CheckState = state switch { NvDitherState.Enabled => CheckState.Checked, NvDitherState.Disabled => CheckState.Unchecked, _ => CheckState.Indeterminate }; + cbxDitheringBitDepth.SelectedIndex = ditherInfo.bits; + cbxDitheringMode.SelectedIndex = ditherInfo.mode; + + cbxDitheringBitDepth.Enabled = state == NvDitherState.Enabled; + cbxDitheringMode.Enabled = state == NvDitherState.Enabled; + } + finally + { + _updatingDitherSettings = false; + } + } + + private void FillGradient() + { + if (pbGradient.Image == null) + { + pbGradient.Image = Utils.GenerateGradientBitmap(pbGradient.Width, pbGradient.Height); + } + } + + private void ApplyDitheringOptions() + { + if (_updatingDitherSettings) + { + return; + } + + var state = chkDitheringEnabled.CheckState switch { CheckState.Checked => NvDitherState.Enabled, CheckState.Unchecked => NvDitherState.Disabled, _ => NvDitherState.Auto }; + var bitDepth = cbxDitheringBitDepth.SelectedIndex; + var mode = cbxDitheringMode.SelectedIndex; + var display = ((NvDisplayInfo)cbxDitheringDisplay.SelectedItem)?.Display; + + if (_nvService.SetDithering(state, (uint)bitDepth, (uint)(mode > -1 ? mode : (int)NvDitherMode.Temporal), currentDisplay: display) && state == NvDitherState.Auto) + { + UpdateDitherSettings(); + } + } + + private void cbxDitheringBitDepth_SelectedIndexChanged(object sender, EventArgs e) + { + ApplyDitheringOptions(); + } + + private void cbxDitheringMode_SelectedIndexChanged(object sender, EventArgs e) + { + ApplyDitheringOptions(); + } + + private void chkDitheringEnabled_CheckStateChanged(object sender, EventArgs e) + { + cbxDitheringBitDepth.Enabled = chkDitheringEnabled.CheckState == CheckState.Checked; + cbxDitheringMode.Enabled = chkDitheringEnabled.CheckState == CheckState.Checked; + + ApplyDitheringOptions(); + } + + private void cbxDitheringDisplay_SelectedIndexChanged(object sender, EventArgs e) + { + if (!_initialized) + { + return; + } + + UpdateDitherSettings(); + } + } +} diff --git a/ColorControl/Services/NVIDIA/NvDitherPanel.resx b/ColorControl/Services/NVIDIA/NvDitherPanel.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ColorControl/Services/NVIDIA/NvDitherPanel.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/Services/NVIDIA/NvPanel.cs b/ColorControl/Services/NVIDIA/NvPanel.cs index 810bbea..4a8e6e5 100644 --- a/ColorControl/Services/NVIDIA/NvPanel.cs +++ b/ColorControl/Services/NVIDIA/NvPanel.cs @@ -22,7 +22,7 @@ namespace ColorControl.Services.NVIDIA { partial class NvPanel : UserControl { - private static int SHORTCUTID_NVQA = -200; + public static readonly int SHORTCUTID_NVQA = -200; private static readonly Logger Logger = LogManager.GetCurrentClassLogger();