fix amd/nvidia refresh rate and resolution issues

This commit is contained in:
Vincent Maas committed 2024-04-14 17:12:03 +02:00
1 parent b9db10262b
commit 4f4ce54ade
24 files changed
+1193 -742

No files matched your search

+2 -2
View File
@@ -18,8 +18,8 @@
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>9.8.2.1</ApplicationVersion>
<Version>9.8.2.1</Version>
<ApplicationVersion>9.9.0.0</ApplicationVersion>
<Version>9.9.0.0</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
+14 -32
View File
@@ -38,7 +38,6 @@ namespace ColorControl
private readonly KeyboardShortcutDispatcher _keyboardShortcutDispatcher;
private readonly UpdateManager _updateManager;
private Config _config;
private bool _setVisibleCalled = false;
private LgPanel _lgPanel;
private SamsungPanel _samsungPanel;
@@ -48,8 +47,8 @@ namespace ColorControl
private GamePanel _gamePanel;
public MainForm(GlobalContext globalContext, ServiceManager serviceManager,
IServiceProvider serviceProvider, ElevationService elevationService, NotifyIconManager notifyIconManager, KeyboardShortcutDispatcher keyboardShortcutDispatcher, UpdateManager updateManager)
public MainForm(GlobalContext globalContext, ServiceManager serviceManager, IServiceProvider serviceProvider, ElevationService elevationService,
NotifyIconManager notifyIconManager, KeyboardShortcutDispatcher keyboardShortcutDispatcher, UpdateManager updateManager)
{
InitializeComponent();
@@ -117,6 +116,8 @@ namespace ColorControl
panel.Size = tabPage.ClientSize;
panel.BackColor = SystemColors.Window;
//Logger.Debug($"Panel {panel.GetType().Name}, size: {panel.Size.Width}x{panel.Size.Height}");
return panel;
}
catch (Exception ex)
@@ -136,7 +137,12 @@ namespace ColorControl
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!(SystemShutdown || EndSession || Program.UserExit) && _config.MinimizeOnClose)
if (Program.UserExit)
{
return;
}
if (!(SystemShutdown || EndSession) && _config.MinimizeOnClose)
{
e.Cancel = true;
WindowState = FormWindowState.Minimized;
@@ -149,9 +155,9 @@ namespace ColorControl
if (SystemShutdown)
{
Logger.Debug($"MainForm_FormClosing: SystemShutdown");
//_powerEventDispatcher.SendEvent(PowerEventDispatcher.Event_Shutdown);
}
Program.Exit();
}
private void GlobalSave()
@@ -232,33 +238,13 @@ namespace ColorControl
Utils.WriteObject(Program.ConfigFilename, _config);
}
private async void MainForm_Shown(object sender, EventArgs e)
private void MainForm_Shown(object sender, EventArgs e)
{
InitSelectedTab();
_elevationService.CheckElevationMethod();
}
protected override void SetVisibleCore(bool value)
{
//if (!_setVisibleCalled && _config.StartMinimized && !Debugger.IsAttached)
//{
// _setVisibleCalled = true;
// if (_config.MinimizeToTray)
// {
// value = false;
// }
// else
// {
// WindowState = FormWindowState.Minimized;
// }
//}
if (!IsDisposed)
{
base.SetVisibleCore(value);
}
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
InitSelectedTab();
@@ -282,7 +268,7 @@ namespace ColorControl
private void InitOptionsTab()
{
if (tabInfo.Controls.Count > 0)
if (tabOptions.Controls.Count > 0)
{
return;
}
@@ -328,10 +314,6 @@ namespace ColorControl
{
await _amdPanel.AfterInitialized();
}
//if (_trayIcon.Visible)
//{
// await CheckForUpdates();
//}
}
private void MainForm_Deactivate(object sender, EventArgs e)
+11 -20
View File
@@ -30,7 +30,6 @@ internal class MainWorker
private readonly WinApiService _winApiService;
private readonly WinApiAdminService _winApiAdminService;
private readonly UpdateManager _updateManager;
private bool _isInitialized;
private bool _queryEndSession;
private nint _screenStateNotify;
@@ -62,28 +61,22 @@ internal class MainWorker
public async Task DoWork()
{
while (!_backgroundWorker.CancellationPending)
if (_backgroundWorker.CancellationPending)
{
return;
}
if (!_isInitialized)
{
await Init();
}
await Init();
//await Task.Delay(1000);
System.Windows.Forms.Application.Run(_windowMessageDispatcher.MessageForm);
System.Windows.Forms.Application.Run(_windowMessageDispatcher.MessageForm);
_serviceManager.Save();
_notifyIconManager.HideIcon();
_serviceManager.Save();
_notifyIconManager.HideIcon();
if (_screenStateNotify != 0)
{
WinApi.UnregisterPowerSettingNotification(_screenStateNotify);
_screenStateNotify = 0;
}
break;
if (_screenStateNotify != 0)
{
WinApi.UnregisterPowerSettingNotification(_screenStateNotify);
_screenStateNotify = 0;
}
}
@@ -116,8 +109,6 @@ internal class MainWorker
_keyboardShortcutDispatcher.RegisterShortcut(SHORTCUTID_SCREENSAVER, _config.ScreenSaverShortcut);
_keyboardShortcutDispatcher.RegisterEventHandler(KeyboardShortcutDispatcher.Event_HotKey, HandleHotKeyEvent);
_isInitialized = true;
}
private bool _startupSent = false;
+297 -283
View File
@@ -28,384 +28,395 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.btnAmdSettings = new System.Windows.Forms.Button();
this.chkAmdQuickAccess = new System.Windows.Forms.CheckBox();
this.lblAmdPresetName = new System.Windows.Forms.Label();
this.edtAmdPresetName = new System.Windows.Forms.TextBox();
this.btnAddAmd = new System.Windows.Forms.Button();
this.lblErrorAMD = new System.Windows.Forms.Label();
this.btnDeleteAmd = new System.Windows.Forms.Button();
this.btnCloneAmd = new System.Windows.Forms.Button();
this.btnAmdPresetSave = new System.Windows.Forms.Button();
this.lblAmdShortcut = new System.Windows.Forms.Label();
this.edtAmdShortcut = new System.Windows.Forms.TextBox();
this.btnChangeAmd = new System.Windows.Forms.Button();
this.mnuAmdPresets = new System.Windows.Forms.ContextMenuStrip(this.components);
this.miAmdApply = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdPresetApplyOnStartup = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.mnuAmdDisplay = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdPrimaryDisplay = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAmdColorSettings = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdColorSettingsIncluded = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAmdRefreshRate = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdRefreshRateIncluded = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAmdDithering = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdDitheringIncluded = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAmdHDR = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdHDRIncluded = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdHDRToggle = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdHDREnabled = new System.Windows.Forms.ToolStripMenuItem();
this.miAmdCopyId = new System.Windows.Forms.ToolStripMenuItem();
this.btnApplyAmd = new System.Windows.Forms.Button();
this.lvAmdPresets = new System.Windows.Forms.ListView();
this.mnuAmdPresets.SuspendLayout();
this.SuspendLayout();
components = new System.ComponentModel.Container();
btnAmdSettings = new System.Windows.Forms.Button();
chkAmdQuickAccess = new System.Windows.Forms.CheckBox();
lblAmdPresetName = new System.Windows.Forms.Label();
edtAmdPresetName = new System.Windows.Forms.TextBox();
btnAddAmd = new System.Windows.Forms.Button();
lblErrorAMD = new System.Windows.Forms.Label();
btnDeleteAmd = new System.Windows.Forms.Button();
btnCloneAmd = new System.Windows.Forms.Button();
btnAmdPresetSave = new System.Windows.Forms.Button();
lblAmdShortcut = new System.Windows.Forms.Label();
edtAmdShortcut = new System.Windows.Forms.TextBox();
btnChangeAmd = new System.Windows.Forms.Button();
mnuAmdPresets = new System.Windows.Forms.ContextMenuStrip(components);
miAmdApply = new System.Windows.Forms.ToolStripMenuItem();
miAmdPresetApplyOnStartup = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
mnuAmdDisplay = new System.Windows.Forms.ToolStripMenuItem();
miAmdPrimaryDisplay = new System.Windows.Forms.ToolStripMenuItem();
mnuAmdColorSettings = new System.Windows.Forms.ToolStripMenuItem();
miAmdColorSettingsIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuAmdRefreshRate = new System.Windows.Forms.ToolStripMenuItem();
miAmdRefreshRateIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuAmdResolution = new System.Windows.Forms.ToolStripMenuItem();
miAmdResolutionIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuAmdDithering = new System.Windows.Forms.ToolStripMenuItem();
miAmdDitheringIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuAmdHDR = new System.Windows.Forms.ToolStripMenuItem();
miAmdHDRIncluded = new System.Windows.Forms.ToolStripMenuItem();
miAmdHDRToggle = new System.Windows.Forms.ToolStripMenuItem();
miAmdHDREnabled = new System.Windows.Forms.ToolStripMenuItem();
miAmdCopyId = new System.Windows.Forms.ToolStripMenuItem();
btnApplyAmd = new System.Windows.Forms.Button();
lvAmdPresets = new System.Windows.Forms.ListView();
miAmdActiveResolution = new System.Windows.Forms.ToolStripMenuItem();
miAmdVirtualResolution = new System.Windows.Forms.ToolStripMenuItem();
mnuAmdPresets.SuspendLayout();
SuspendLayout();
//
// btnAmdSettings
//
this.btnAmdSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnAmdSettings.Location = new System.Drawing.Point(1017, 429);
this.btnAmdSettings.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnAmdSettings.Name = "btnAmdSettings";
this.btnAmdSettings.Size = new System.Drawing.Size(88, 27);
this.btnAmdSettings.TabIndex = 60;
this.btnAmdSettings.Text = "Settings...";
this.btnAmdSettings.UseVisualStyleBackColor = true;
this.btnAmdSettings.Click += new System.EventHandler(this.btnAmdSettings_Click);
btnAmdSettings.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
btnAmdSettings.Location = new System.Drawing.Point(1017, 429);
btnAmdSettings.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnAmdSettings.Name = "btnAmdSettings";
btnAmdSettings.Size = new System.Drawing.Size(88, 27);
btnAmdSettings.TabIndex = 60;
btnAmdSettings.Text = "Settings...";
btnAmdSettings.UseVisualStyleBackColor = true;
btnAmdSettings.Click += btnAmdSettings_Click;
//
// chkAmdQuickAccess
//
this.chkAmdQuickAccess.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chkAmdQuickAccess.AutoSize = true;
this.chkAmdQuickAccess.Enabled = false;
this.chkAmdQuickAccess.Location = new System.Drawing.Point(343, 465);
this.chkAmdQuickAccess.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.chkAmdQuickAccess.Name = "chkAmdQuickAccess";
this.chkAmdQuickAccess.Size = new System.Drawing.Size(141, 19);
this.chkAmdQuickAccess.TabIndex = 46;
this.chkAmdQuickAccess.Text = "Show in Quick Access";
this.chkAmdQuickAccess.UseVisualStyleBackColor = true;
chkAmdQuickAccess.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
chkAmdQuickAccess.AutoSize = true;
chkAmdQuickAccess.Enabled = false;
chkAmdQuickAccess.Location = new System.Drawing.Point(343, 465);
chkAmdQuickAccess.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
chkAmdQuickAccess.Name = "chkAmdQuickAccess";
chkAmdQuickAccess.Size = new System.Drawing.Size(141, 19);
chkAmdQuickAccess.TabIndex = 46;
chkAmdQuickAccess.Text = "Show in Quick Access";
chkAmdQuickAccess.UseVisualStyleBackColor = true;
//
// lblAmdPresetName
//
this.lblAmdPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblAmdPresetName.AutoSize = true;
this.lblAmdPresetName.Location = new System.Drawing.Point(7, 466);
this.lblAmdPresetName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblAmdPresetName.Name = "lblAmdPresetName";
this.lblAmdPresetName.Size = new System.Drawing.Size(42, 15);
this.lblAmdPresetName.TabIndex = 24;
this.lblAmdPresetName.Text = "Name:";
lblAmdPresetName.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
lblAmdPresetName.AutoSize = true;
lblAmdPresetName.Location = new System.Drawing.Point(7, 466);
lblAmdPresetName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lblAmdPresetName.Name = "lblAmdPresetName";
lblAmdPresetName.Size = new System.Drawing.Size(42, 15);
lblAmdPresetName.TabIndex = 24;
lblAmdPresetName.Text = "Name:";
//
// edtAmdPresetName
//
this.edtAmdPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.edtAmdPresetName.Enabled = false;
this.edtAmdPresetName.Location = new System.Drawing.Point(102, 463);
this.edtAmdPresetName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.edtAmdPresetName.Name = "edtAmdPresetName";
this.edtAmdPresetName.Size = new System.Drawing.Size(233, 23);
this.edtAmdPresetName.TabIndex = 23;
edtAmdPresetName.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
edtAmdPresetName.Enabled = false;
edtAmdPresetName.Location = new System.Drawing.Point(102, 463);
edtAmdPresetName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
edtAmdPresetName.Name = "edtAmdPresetName";
edtAmdPresetName.Size = new System.Drawing.Size(233, 23);
edtAmdPresetName.TabIndex = 23;
//
// btnAddAmd
//
this.btnAddAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnAddAmd.Location = new System.Drawing.Point(385, 429);
this.btnAddAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnAddAmd.Name = "btnAddAmd";
this.btnAddAmd.Size = new System.Drawing.Size(88, 27);
this.btnAddAmd.TabIndex = 18;
this.btnAddAmd.Text = "Add";
this.btnAddAmd.UseVisualStyleBackColor = true;
this.btnAddAmd.Click += new System.EventHandler(this.btnAddAmd_Click);
btnAddAmd.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
btnAddAmd.Location = new System.Drawing.Point(385, 429);
btnAddAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnAddAmd.Name = "btnAddAmd";
btnAddAmd.Size = new System.Drawing.Size(88, 27);
btnAddAmd.TabIndex = 18;
btnAddAmd.Text = "Add";
btnAddAmd.UseVisualStyleBackColor = true;
btnAddAmd.Click += btnAddAmd_Click;
//
// lblErrorAMD
//
this.lblErrorAMD.AutoSize = true;
this.lblErrorAMD.Location = new System.Drawing.Point(7, 7);
this.lblErrorAMD.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblErrorAMD.Name = "lblErrorAMD";
this.lblErrorAMD.Size = new System.Drawing.Size(53, 15);
this.lblErrorAMD.TabIndex = 8;
this.lblErrorAMD.Text = "ErrorText";
this.lblErrorAMD.Visible = false;
lblErrorAMD.AutoSize = true;
lblErrorAMD.Location = new System.Drawing.Point(7, 7);
lblErrorAMD.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lblErrorAMD.Name = "lblErrorAMD";
lblErrorAMD.Size = new System.Drawing.Size(53, 15);
lblErrorAMD.TabIndex = 8;
lblErrorAMD.Text = "ErrorText";
lblErrorAMD.Visible = false;
//
// btnDeleteAmd
//
this.btnDeleteAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnDeleteAmd.Enabled = false;
this.btnDeleteAmd.Location = new System.Drawing.Point(290, 429);
this.btnDeleteAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnDeleteAmd.Name = "btnDeleteAmd";
this.btnDeleteAmd.Size = new System.Drawing.Size(88, 27);
this.btnDeleteAmd.TabIndex = 17;
this.btnDeleteAmd.Text = "Delete";
this.btnDeleteAmd.UseVisualStyleBackColor = true;
this.btnDeleteAmd.Click += new System.EventHandler(this.btnDeleteAmd_Click);
btnDeleteAmd.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
btnDeleteAmd.Enabled = false;
btnDeleteAmd.Location = new System.Drawing.Point(290, 429);
btnDeleteAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnDeleteAmd.Name = "btnDeleteAmd";
btnDeleteAmd.Size = new System.Drawing.Size(88, 27);
btnDeleteAmd.TabIndex = 17;
btnDeleteAmd.Text = "Delete";
btnDeleteAmd.UseVisualStyleBackColor = true;
btnDeleteAmd.Click += btnDeleteAmd_Click;
//
// btnCloneAmd
//
this.btnCloneAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCloneAmd.Enabled = false;
this.btnCloneAmd.Location = new System.Drawing.Point(196, 429);
this.btnCloneAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnCloneAmd.Name = "btnCloneAmd";
this.btnCloneAmd.Size = new System.Drawing.Size(88, 27);
this.btnCloneAmd.TabIndex = 16;
this.btnCloneAmd.Text = "Clone";
this.btnCloneAmd.UseVisualStyleBackColor = true;
this.btnCloneAmd.Click += new System.EventHandler(this.btnCloneAmd_Click);
btnCloneAmd.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
btnCloneAmd.Enabled = false;
btnCloneAmd.Location = new System.Drawing.Point(196, 429);
btnCloneAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnCloneAmd.Name = "btnCloneAmd";
btnCloneAmd.Size = new System.Drawing.Size(88, 27);
btnCloneAmd.TabIndex = 16;
btnCloneAmd.Text = "Clone";
btnCloneAmd.UseVisualStyleBackColor = true;
btnCloneAmd.Click += btnCloneAmd_Click;
//
// btnAmdPresetSave
//
this.btnAmdPresetSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnAmdPresetSave.Enabled = false;
this.btnAmdPresetSave.Location = new System.Drawing.Point(479, 429);
this.btnAmdPresetSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnAmdPresetSave.Name = "btnAmdPresetSave";
this.btnAmdPresetSave.Size = new System.Drawing.Size(88, 27);
this.btnAmdPresetSave.TabIndex = 15;
this.btnAmdPresetSave.Text = "Save";
this.btnAmdPresetSave.UseVisualStyleBackColor = true;
this.btnAmdPresetSave.Click += new System.EventHandler(this.btnSetAmdShortcut_Click);
btnAmdPresetSave.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
btnAmdPresetSave.Enabled = false;
btnAmdPresetSave.Location = new System.Drawing.Point(479, 429);
btnAmdPresetSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnAmdPresetSave.Name = "btnAmdPresetSave";
btnAmdPresetSave.Size = new System.Drawing.Size(88, 27);
btnAmdPresetSave.TabIndex = 15;
btnAmdPresetSave.Text = "Save";
btnAmdPresetSave.UseVisualStyleBackColor = true;
btnAmdPresetSave.Click += btnSetAmdShortcut_Click;
//
// lblAmdShortcut
//
this.lblAmdShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblAmdShortcut.AutoSize = true;
this.lblAmdShortcut.Location = new System.Drawing.Point(7, 496);
this.lblAmdShortcut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblAmdShortcut.Name = "lblAmdShortcut";
this.lblAmdShortcut.Size = new System.Drawing.Size(55, 15);
this.lblAmdShortcut.TabIndex = 14;
this.lblAmdShortcut.Text = "Shortcut:";
lblAmdShortcut.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
lblAmdShortcut.AutoSize = true;
lblAmdShortcut.Location = new System.Drawing.Point(7, 496);
lblAmdShortcut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lblAmdShortcut.Name = "lblAmdShortcut";
lblAmdShortcut.Size = new System.Drawing.Size(55, 15);
lblAmdShortcut.TabIndex = 14;
lblAmdShortcut.Text = "Shortcut:";
//
// edtAmdShortcut
//
this.edtAmdShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.edtAmdShortcut.Enabled = false;
this.edtAmdShortcut.Location = new System.Drawing.Point(102, 493);
this.edtAmdShortcut.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.edtAmdShortcut.Name = "edtAmdShortcut";
this.edtAmdShortcut.ReadOnly = true;
this.edtAmdShortcut.Size = new System.Drawing.Size(233, 23);
this.edtAmdShortcut.TabIndex = 13;
this.edtAmdShortcut.TextChanged += new System.EventHandler(this.edtAmdShortcut_TextChanged);
this.edtAmdShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown);
this.edtAmdShortcut.KeyUp += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyUp);
edtAmdShortcut.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
edtAmdShortcut.Enabled = false;
edtAmdShortcut.Location = new System.Drawing.Point(102, 493);
edtAmdShortcut.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
edtAmdShortcut.Name = "edtAmdShortcut";
edtAmdShortcut.ReadOnly = true;
edtAmdShortcut.Size = new System.Drawing.Size(233, 23);
edtAmdShortcut.TabIndex = 13;
edtAmdShortcut.TextChanged += edtAmdShortcut_TextChanged;
edtAmdShortcut.KeyDown += edtShortcut_KeyDown;
edtAmdShortcut.KeyUp += edtShortcut_KeyUp;
//
// btnChangeAmd
//
this.btnChangeAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnChangeAmd.ContextMenuStrip = this.mnuAmdPresets;
this.btnChangeAmd.Enabled = false;
this.btnChangeAmd.Location = new System.Drawing.Point(102, 429);
this.btnChangeAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnChangeAmd.Name = "btnChangeAmd";
this.btnChangeAmd.Size = new System.Drawing.Size(88, 27);
this.btnChangeAmd.TabIndex = 12;
this.btnChangeAmd.Text = "Change...";
this.btnChangeAmd.UseVisualStyleBackColor = true;
this.btnChangeAmd.Click += new System.EventHandler(this.btnChangeAmd_Click);
btnChangeAmd.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
btnChangeAmd.ContextMenuStrip = mnuAmdPresets;
btnChangeAmd.Enabled = false;
btnChangeAmd.Location = new System.Drawing.Point(102, 429);
btnChangeAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnChangeAmd.Name = "btnChangeAmd";
btnChangeAmd.Size = new System.Drawing.Size(88, 27);
btnChangeAmd.TabIndex = 12;
btnChangeAmd.Text = "Change...";
btnChangeAmd.UseVisualStyleBackColor = true;
btnChangeAmd.Click += btnChangeAmd_Click;
//
// mnuAmdPresets
//
this.mnuAmdPresets.ImageScalingSize = new System.Drawing.Size(20, 20);
this.mnuAmdPresets.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdApply,
this.miAmdPresetApplyOnStartup,
this.toolStripSeparator2,
this.mnuAmdDisplay,
this.mnuAmdColorSettings,
this.mnuAmdRefreshRate,
this.mnuAmdDithering,
this.mnuAmdHDR,
this.miAmdCopyId});
this.mnuAmdPresets.Name = "mnuNvPresets";
this.mnuAmdPresets.Size = new System.Drawing.Size(185, 186);
this.mnuAmdPresets.Opening += new System.ComponentModel.CancelEventHandler(this.mnuAmdPresets_Opening);
mnuAmdPresets.ImageScalingSize = new System.Drawing.Size(20, 20);
mnuAmdPresets.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdApply, miAmdPresetApplyOnStartup, toolStripSeparator2, mnuAmdDisplay, mnuAmdColorSettings, mnuAmdRefreshRate, mnuAmdResolution, mnuAmdDithering, mnuAmdHDR, miAmdCopyId });
mnuAmdPresets.Name = "mnuNvPresets";
mnuAmdPresets.Size = new System.Drawing.Size(185, 208);
mnuAmdPresets.Opening += mnuAmdPresets_Opening;
//
// miAmdApply
//
this.miAmdApply.Name = "miAmdApply";
this.miAmdApply.Size = new System.Drawing.Size(184, 22);
this.miAmdApply.Text = "Apply";
this.miAmdApply.Click += new System.EventHandler(this.btnApplyAmd_Click);
miAmdApply.Name = "miAmdApply";
miAmdApply.Size = new System.Drawing.Size(184, 22);
miAmdApply.Text = "Apply";
miAmdApply.Click += btnApplyAmd_Click;
//
// miAmdPresetApplyOnStartup
//
this.miAmdPresetApplyOnStartup.CheckOnClick = true;
this.miAmdPresetApplyOnStartup.Name = "miAmdPresetApplyOnStartup";
this.miAmdPresetApplyOnStartup.Size = new System.Drawing.Size(184, 22);
this.miAmdPresetApplyOnStartup.Text = "Apply on startup";
this.miAmdPresetApplyOnStartup.Click += new System.EventHandler(this.miAmdPresetApplyOnStartup_Click);
miAmdPresetApplyOnStartup.CheckOnClick = true;
miAmdPresetApplyOnStartup.Name = "miAmdPresetApplyOnStartup";
miAmdPresetApplyOnStartup.Size = new System.Drawing.Size(184, 22);
miAmdPresetApplyOnStartup.Text = "Apply on startup";
miAmdPresetApplyOnStartup.Click += miAmdPresetApplyOnStartup_Click;
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(181, 6);
toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new System.Drawing.Size(181, 6);
//
// mnuAmdDisplay
//
this.mnuAmdDisplay.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdPrimaryDisplay});
this.mnuAmdDisplay.Name = "mnuAmdDisplay";
this.mnuAmdDisplay.Size = new System.Drawing.Size(184, 22);
this.mnuAmdDisplay.Text = "Display";
mnuAmdDisplay.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdPrimaryDisplay });
mnuAmdDisplay.Name = "mnuAmdDisplay";
mnuAmdDisplay.Size = new System.Drawing.Size(184, 22);
mnuAmdDisplay.Text = "Display";
//
// miAmdPrimaryDisplay
//
this.miAmdPrimaryDisplay.Name = "miAmdPrimaryDisplay";
this.miAmdPrimaryDisplay.Size = new System.Drawing.Size(155, 22);
this.miAmdPrimaryDisplay.Text = "Primary display";
this.miAmdPrimaryDisplay.Click += new System.EventHandler(this.displayMenuItemAmd_Click);
miAmdPrimaryDisplay.Name = "miAmdPrimaryDisplay";
miAmdPrimaryDisplay.Size = new System.Drawing.Size(155, 22);
miAmdPrimaryDisplay.Text = "Primary display";
miAmdPrimaryDisplay.Click += displayMenuItemAmd_Click;
//
// mnuAmdColorSettings
//
this.mnuAmdColorSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdColorSettingsIncluded});
this.mnuAmdColorSettings.Name = "mnuAmdColorSettings";
this.mnuAmdColorSettings.Size = new System.Drawing.Size(184, 22);
this.mnuAmdColorSettings.Text = "Color settings";
mnuAmdColorSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdColorSettingsIncluded });
mnuAmdColorSettings.Name = "mnuAmdColorSettings";
mnuAmdColorSettings.Size = new System.Drawing.Size(184, 22);
mnuAmdColorSettings.Text = "Color settings";
//
// miAmdColorSettingsIncluded
//
this.miAmdColorSettingsIncluded.Name = "miAmdColorSettingsIncluded";
this.miAmdColorSettingsIncluded.Size = new System.Drawing.Size(120, 22);
this.miAmdColorSettingsIncluded.Text = "Included";
this.miAmdColorSettingsIncluded.Click += new System.EventHandler(this.miAmdColorSettingsIncluded_Click);
miAmdColorSettingsIncluded.Name = "miAmdColorSettingsIncluded";
miAmdColorSettingsIncluded.Size = new System.Drawing.Size(120, 22);
miAmdColorSettingsIncluded.Text = "Included";
miAmdColorSettingsIncluded.Click += miAmdColorSettingsIncluded_Click;
//
// mnuAmdRefreshRate
//
this.mnuAmdRefreshRate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdRefreshRateIncluded});
this.mnuAmdRefreshRate.Name = "mnuAmdRefreshRate";
this.mnuAmdRefreshRate.Size = new System.Drawing.Size(184, 22);
this.mnuAmdRefreshRate.Text = "Refresh Rate";
mnuAmdRefreshRate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdRefreshRateIncluded });
mnuAmdRefreshRate.Name = "mnuAmdRefreshRate";
mnuAmdRefreshRate.Size = new System.Drawing.Size(184, 22);
mnuAmdRefreshRate.Text = "Refresh Rate";
//
// miAmdRefreshRateIncluded
//
this.miAmdRefreshRateIncluded.Name = "miAmdRefreshRateIncluded";
this.miAmdRefreshRateIncluded.Size = new System.Drawing.Size(120, 22);
this.miAmdRefreshRateIncluded.Text = "Included";
this.miAmdRefreshRateIncluded.Click += new System.EventHandler(this.miAmdRefreshRateIncluded_Click);
miAmdRefreshRateIncluded.Name = "miAmdRefreshRateIncluded";
miAmdRefreshRateIncluded.Size = new System.Drawing.Size(180, 22);
miAmdRefreshRateIncluded.Text = "Included";
miAmdRefreshRateIncluded.Click += miAmdRefreshRateIncluded_Click;
//
// mnuAmdResolution
//
mnuAmdResolution.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdResolutionIncluded, miAmdActiveResolution, miAmdVirtualResolution });
mnuAmdResolution.Name = "mnuAmdResolution";
mnuAmdResolution.Size = new System.Drawing.Size(184, 22);
mnuAmdResolution.Text = "Resolution";
//
// miAmdResolutionIncluded
//
miAmdResolutionIncluded.Name = "miAmdResolutionIncluded";
miAmdResolutionIncluded.Size = new System.Drawing.Size(180, 22);
miAmdResolutionIncluded.Text = "Included";
miAmdResolutionIncluded.Click += miAmdResolutionIncluded_Click;
//
// mnuAmdDithering
//
this.mnuAmdDithering.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdDitheringIncluded});
this.mnuAmdDithering.Name = "mnuAmdDithering";
this.mnuAmdDithering.Size = new System.Drawing.Size(184, 22);
this.mnuAmdDithering.Text = "Dithering";
mnuAmdDithering.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdDitheringIncluded });
mnuAmdDithering.Name = "mnuAmdDithering";
mnuAmdDithering.Size = new System.Drawing.Size(184, 22);
mnuAmdDithering.Text = "Dithering";
//
// miAmdDitheringIncluded
//
this.miAmdDitheringIncluded.Name = "miAmdDitheringIncluded";
this.miAmdDitheringIncluded.Size = new System.Drawing.Size(120, 22);
this.miAmdDitheringIncluded.Text = "Included";
this.miAmdDitheringIncluded.Click += new System.EventHandler(this.miAmdDitheringIncluded_Click);
miAmdDitheringIncluded.Name = "miAmdDitheringIncluded";
miAmdDitheringIncluded.Size = new System.Drawing.Size(120, 22);
miAmdDitheringIncluded.Text = "Included";
miAmdDitheringIncluded.Click += miAmdDitheringIncluded_Click;
//
// mnuAmdHDR
//
this.mnuAmdHDR.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdHDRIncluded,
this.miAmdHDRToggle,
this.miAmdHDREnabled});
this.mnuAmdHDR.Name = "mnuAmdHDR";
this.mnuAmdHDR.Size = new System.Drawing.Size(184, 22);
this.mnuAmdHDR.Text = "HDR";
mnuAmdHDR.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miAmdHDRIncluded, miAmdHDRToggle, miAmdHDREnabled });
mnuAmdHDR.Name = "mnuAmdHDR";
mnuAmdHDR.Size = new System.Drawing.Size(184, 22);
mnuAmdHDR.Text = "HDR";
//
// miAmdHDRIncluded
//
this.miAmdHDRIncluded.Name = "miAmdHDRIncluded";
this.miAmdHDRIncluded.Size = new System.Drawing.Size(136, 22);
this.miAmdHDRIncluded.Text = "Included";
this.miAmdHDRIncluded.Click += new System.EventHandler(this.miAmdHDRIncluded_Click);
miAmdHDRIncluded.Name = "miAmdHDRIncluded";
miAmdHDRIncluded.Size = new System.Drawing.Size(136, 22);
miAmdHDRIncluded.Text = "Included";
miAmdHDRIncluded.Click += miAmdHDRIncluded_Click;
//
// miAmdHDRToggle
//
this.miAmdHDRToggle.Name = "miAmdHDRToggle";
this.miAmdHDRToggle.Size = new System.Drawing.Size(136, 22);
this.miAmdHDRToggle.Text = "Toggle HDR";
this.miAmdHDRToggle.Click += new System.EventHandler(this.miAmdHDRToggle_Click);
miAmdHDRToggle.Name = "miAmdHDRToggle";
miAmdHDRToggle.Size = new System.Drawing.Size(136, 22);
miAmdHDRToggle.Text = "Toggle HDR";
miAmdHDRToggle.Click += miAmdHDRToggle_Click;
//
// miAmdHDREnabled
//
this.miAmdHDREnabled.Name = "miAmdHDREnabled";
this.miAmdHDREnabled.Size = new System.Drawing.Size(136, 22);
this.miAmdHDREnabled.Text = "Enabled";
this.miAmdHDREnabled.Click += new System.EventHandler(this.miAmdHDREnabled_Click);
miAmdHDREnabled.Name = "miAmdHDREnabled";
miAmdHDREnabled.Size = new System.Drawing.Size(136, 22);
miAmdHDREnabled.Text = "Enabled";
miAmdHDREnabled.Click += miAmdHDREnabled_Click;
//
// miAmdCopyId
//
this.miAmdCopyId.Name = "miAmdCopyId";
this.miAmdCopyId.Size = new System.Drawing.Size(184, 22);
this.miAmdCopyId.Text = "Copy Id to Clipboard";
this.miAmdCopyId.Click += new System.EventHandler(this.miAmdCopyId_Click);
miAmdCopyId.Name = "miAmdCopyId";
miAmdCopyId.Size = new System.Drawing.Size(184, 22);
miAmdCopyId.Text = "Copy Id to Clipboard";
miAmdCopyId.Click += miAmdCopyId_Click;
//
// btnApplyAmd
//
this.btnApplyAmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnApplyAmd.Enabled = false;
this.btnApplyAmd.Location = new System.Drawing.Point(7, 429);
this.btnApplyAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.btnApplyAmd.Name = "btnApplyAmd";
this.btnApplyAmd.Size = new System.Drawing.Size(88, 27);
this.btnApplyAmd.TabIndex = 11;
this.btnApplyAmd.Text = "Apply";
this.btnApplyAmd.UseVisualStyleBackColor = true;
this.btnApplyAmd.Click += new System.EventHandler(this.btnApplyAmd_Click);
btnApplyAmd.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
btnApplyAmd.Enabled = false;
btnApplyAmd.Location = new System.Drawing.Point(7, 429);
btnApplyAmd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
btnApplyAmd.Name = "btnApplyAmd";
btnApplyAmd.Size = new System.Drawing.Size(88, 27);
btnApplyAmd.TabIndex = 11;
btnApplyAmd.Text = "Apply";
btnApplyAmd.UseVisualStyleBackColor = true;
btnApplyAmd.Click += btnApplyAmd_Click;
//
// lvAmdPresets
//
this.lvAmdPresets.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.lvAmdPresets.CheckBoxes = true;
this.lvAmdPresets.ContextMenuStrip = this.mnuAmdPresets;
this.lvAmdPresets.FullRowSelect = true;
this.lvAmdPresets.Location = new System.Drawing.Point(7, 7);
this.lvAmdPresets.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.lvAmdPresets.MultiSelect = false;
this.lvAmdPresets.Name = "lvAmdPresets";
this.lvAmdPresets.ShowItemToolTips = true;
this.lvAmdPresets.Size = new System.Drawing.Size(1098, 415);
this.lvAmdPresets.TabIndex = 10;
this.lvAmdPresets.UseCompatibleStateImageBehavior = false;
this.lvAmdPresets.View = System.Windows.Forms.View.Details;
this.lvAmdPresets.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvLgPresets_ColumnClick);
this.lvAmdPresets.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.lvNvPresets_ItemCheck);
this.lvAmdPresets.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.lvAmdPresets_ItemChecked);
this.lvAmdPresets.SelectedIndexChanged += new System.EventHandler(this.lvAmdPresets_SelectedIndexChanged);
this.lvAmdPresets.DoubleClick += new System.EventHandler(this.btnApplyAmd_Click);
lvAmdPresets.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
lvAmdPresets.CheckBoxes = true;
lvAmdPresets.ContextMenuStrip = mnuAmdPresets;
lvAmdPresets.FullRowSelect = true;
lvAmdPresets.Location = new System.Drawing.Point(7, 7);
lvAmdPresets.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
lvAmdPresets.MultiSelect = false;
lvAmdPresets.Name = "lvAmdPresets";
lvAmdPresets.ShowItemToolTips = true;
lvAmdPresets.Size = new System.Drawing.Size(1098, 415);
lvAmdPresets.TabIndex = 10;
lvAmdPresets.UseCompatibleStateImageBehavior = false;
lvAmdPresets.View = System.Windows.Forms.View.Details;
lvAmdPresets.ColumnClick += lvLgPresets_ColumnClick;
lvAmdPresets.ItemCheck += lvNvPresets_ItemCheck;
lvAmdPresets.ItemChecked += lvAmdPresets_ItemChecked;
lvAmdPresets.SelectedIndexChanged += lvAmdPresets_SelectedIndexChanged;
lvAmdPresets.DoubleClick += btnApplyAmd_Click;
//
// miAmdActiveResolution
//
miAmdActiveResolution.Name = "miAmdActiveResolution";
miAmdActiveResolution.Size = new System.Drawing.Size(180, 22);
miAmdActiveResolution.Text = "Active";
//
// miAmdVirtualResolution
//
miAmdVirtualResolution.Name = "miAmdVirtualResolution";
miAmdVirtualResolution.Size = new System.Drawing.Size(180, 22);
miAmdVirtualResolution.Text = "Virtual";
//
// AmdPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnAmdSettings);
this.Controls.Add(this.chkAmdQuickAccess);
this.Controls.Add(this.lblAmdPresetName);
this.Controls.Add(this.edtAmdPresetName);
this.Controls.Add(this.btnAddAmd);
this.Controls.Add(this.lblErrorAMD);
this.Controls.Add(this.btnDeleteAmd);
this.Controls.Add(this.btnCloneAmd);
this.Controls.Add(this.btnAmdPresetSave);
this.Controls.Add(this.lblAmdShortcut);
this.Controls.Add(this.edtAmdShortcut);
this.Controls.Add(this.btnChangeAmd);
this.Controls.Add(this.btnApplyAmd);
this.Controls.Add(this.lvAmdPresets);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "AmdPanel";
this.Size = new System.Drawing.Size(1114, 539);
this.mnuAmdPresets.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
Controls.Add(btnAmdSettings);
Controls.Add(chkAmdQuickAccess);
Controls.Add(lblAmdPresetName);
Controls.Add(edtAmdPresetName);
Controls.Add(btnAddAmd);
Controls.Add(lblErrorAMD);
Controls.Add(btnDeleteAmd);
Controls.Add(btnCloneAmd);
Controls.Add(btnAmdPresetSave);
Controls.Add(lblAmdShortcut);
Controls.Add(edtAmdShortcut);
Controls.Add(btnChangeAmd);
Controls.Add(btnApplyAmd);
Controls.Add(lvAmdPresets);
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Name = "AmdPanel";
Size = new System.Drawing.Size(1114, 539);
mnuAmdPresets.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
@@ -441,6 +452,9 @@
private System.Windows.Forms.ToolStripMenuItem miAmdCopyId;
private System.Windows.Forms.CheckBox chkAmdQuickAccess;
private System.Windows.Forms.Button btnAmdSettings;
private System.Windows.Forms.ToolStripMenuItem mnuAmdResolution;
private System.Windows.Forms.ToolStripMenuItem miAmdResolutionIncluded;
private System.Windows.Forms.ToolStripMenuItem miAmdActiveResolution;
private System.Windows.Forms.ToolStripMenuItem miAmdVirtualResolution;
}
}
+123 -8
View File
@@ -16,7 +16,7 @@ using System.Windows.Forms;
namespace ColorControl.Services.AMD
{
public partial class AmdPanel : UserControl, IModulePanel
partial class AmdPanel : UserControl, IModulePanel
{
private readonly AmdService _amdService;
private readonly NotifyIconManager _notifyIconManager;
@@ -25,7 +25,7 @@ namespace ColorControl.Services.AMD
private Config _config;
private string _lastDisplayRefreshRates = string.Empty;
internal AmdPanel(AmdService amdService, NotifyIconManager notifyIconManager, GlobalContext globalContext, KeyboardShortcutDispatcher keyboardShortcutDispatcher)
public AmdPanel(AmdService amdService, NotifyIconManager notifyIconManager, GlobalContext globalContext, KeyboardShortcutDispatcher keyboardShortcutDispatcher)
{
_amdService = amdService;
_notifyIconManager = notifyIconManager;
@@ -195,11 +195,64 @@ namespace ColorControl.Services.AMD
private void refreshRateMenuItemAmd_Click(object sender, EventArgs e)
{
var refreshRate = (uint)((ToolStripItem)sender).Tag;
var refreshRate = (Rational)((ToolStripItem)sender).Tag;
var preset = GetSelectedAmdPreset();
preset.refreshRate = refreshRate;
preset.DisplayConfig.RefreshRate = refreshRate;
AddOrUpdateItemAmd();
}
private void resolutionAmdMenuItem_Click(object sender, EventArgs e)
{
var mode = (VirtualResolution)((ToolStripItem)sender).Tag;
var preset = GetSelectedAmdPreset();
preset.DisplayConfig.Resolution.ActiveWidth = mode.ActiveWidth;
preset.DisplayConfig.Resolution.ActiveHeight = mode.ActiveHeight;
AddOrUpdateItemAmd();
}
private void virtualResolutionAmdMenuItem_Click(object sender, EventArgs e)
{
var mode = (VirtualResolution)((ToolStripItem)sender).Tag;
var preset = GetSelectedAmdPreset();
var virtualMode = new VirtualResolution(mode);
virtualMode.ActiveWidth = preset.DisplayConfig.Resolution.ActiveWidth;
virtualMode.ActiveHeight = preset.DisplayConfig.Resolution.ActiveHeight;
preset.DisplayConfig.Resolution.VirtualWidth = virtualMode.VirtualWidth;
preset.DisplayConfig.Resolution.VirtualHeight = virtualMode.VirtualHeight;
AddOrUpdateItemAmd();
}
private void UpdateDisplayConfigScaling(object sender, EventArgs e)
{
var menuItem = (ToolStripMenuItem)sender;
var value = (CCD.DisplayConfigScaling)menuItem.Tag;
var preset = GetSelectedAmdPreset();
preset.DisplayConfig.Scaling = value;
AddOrUpdateItemAmd();
}
private void UpdateDisplayConfigRotation(object sender, EventArgs e)
{
var menuItem = (ToolStripMenuItem)sender;
var value = (CCD.DisplayConfigRotation)menuItem.Tag;
var preset = GetSelectedAmdPreset();
var settings = preset.DisplayConfig;
preset.DisplayConfig.Rotation = value;
AddOrUpdateItemAmd();
}
@@ -321,6 +374,7 @@ namespace ColorControl.Services.AMD
mnuAmdDisplay.Enabled = preset != null;
mnuAmdColorSettings.Enabled = preset != null;
mnuAmdRefreshRate.Enabled = preset != null;
mnuAmdResolution.Enabled = preset != null;
mnuAmdDithering.Enabled = preset != null;
mnuAmdHDR.Enabled = preset != null;
@@ -351,6 +405,8 @@ namespace ColorControl.Services.AMD
{
mnuAmdRefreshRate.DropDownItems.RemoveAt(mnuAmdRefreshRate.DropDownItems.Count - 1);
}
miAmdActiveResolution.DropDownItems.Clear();
miAmdVirtualResolution.DropDownItems.Clear();
}
if (mnuAmdRefreshRate.DropDownItems.Count == 1)
@@ -360,12 +416,38 @@ namespace ColorControl.Services.AMD
foreach (var refreshRate in refreshRates)
{
var item = mnuAmdRefreshRate.DropDownItems.AddCustom(refreshRate.ToString() + "Hz");
var item = mnuAmdRefreshRate.DropDownItems.AddCustom(refreshRate + "Hz");
item.Tag = refreshRate;
item.Click += refreshRateMenuItemAmd_Click;
}
}
var modes = default(List<VirtualResolution>);
if (miAmdActiveResolution.DropDownItems.Count == 0)
{
modes = _amdService.GetAvailableResolutionsV2(preset);
foreach (var mode in modes)
{
var item = miAmdActiveResolution.DropDownItems.AddCustom(mode.ToString());
item.Tag = mode;
item.Click += resolutionAmdMenuItem_Click;
}
}
if (miAmdVirtualResolution.DropDownItems.Count == 0)
{
modes ??= _amdService.GetAvailableResolutionsV2(preset);
foreach (var mode in modes)
{
var item = miAmdVirtualResolution.DropDownItems.AddCustom(mode.ToString());
item.Tag = mode;
item.Click += virtualResolutionAmdMenuItem_Click;
}
}
miAmdPrimaryDisplay.Checked = preset.primaryDisplay;
foreach (var item in mnuAmdDisplay.DropDownItems)
{
@@ -381,7 +463,7 @@ namespace ColorControl.Services.AMD
miAmdColorSettingsIncluded.Checked = preset.applyColorData;
miAmdRefreshRateIncluded.Checked = preset.applyRefreshRate;
miAmdRefreshRateIncluded.Checked = preset.DisplayConfig.ApplyRefreshRate;
foreach (var item in mnuAmdRefreshRate.DropDownItems)
{
if (item is ToolStripMenuItem)
@@ -389,11 +471,30 @@ namespace ColorControl.Services.AMD
var menuItem = (ToolStripMenuItem)item;
if (menuItem.Tag != null)
{
menuItem.Checked = (uint)menuItem.Tag == preset.refreshRate;
menuItem.Checked = ((Rational)menuItem.Tag).Equals(preset.DisplayConfig.RefreshRate);
}
}
}
miAmdResolutionIncluded.Checked = preset.DisplayConfig.ApplyResolution;
foreach (var item in miAmdActiveResolution.DropDownItems)
{
if (item is ToolStripMenuItem menuItem && menuItem.Tag != null)
{
var mode = (VirtualResolution)menuItem.Tag;
menuItem.Checked = mode.ActiveWidth == preset.DisplayConfig.Resolution.ActiveWidth && mode.ActiveHeight == preset.DisplayConfig.Resolution.ActiveHeight;
}
}
foreach (var item in miAmdVirtualResolution.DropDownItems)
{
if (item is ToolStripMenuItem menuItem && menuItem.Tag != null)
{
var mode = (VirtualResolution)menuItem.Tag;
menuItem.Checked = mode.VirtualWidth == preset.DisplayConfig.Resolution.VirtualWidth && mode.VirtualHeight == preset.DisplayConfig.Resolution.VirtualHeight;
}
}
miAmdDitheringIncluded.Checked = preset.applyDithering;
FormUtils.BuildDropDownMenu(mnuAmdDithering, "Mode", typeof(ADLDitherState), preset, "ditherState", amdPresetColorDataMenuItem_Click);
@@ -401,6 +502,11 @@ namespace ColorControl.Services.AMD
miAmdHDRIncluded.Checked = preset.applyHDR;
miAmdHDREnabled.Checked = preset.HDREnabled;
miAmdHDRToggle.Checked = preset.toggleHDR;
FormUtils.BuildDropDownMenu(mnuAmdResolution, "Scaling/Aspect Ratio", typeof(CCD.DisplayConfigScaling), preset.DisplayConfig, "Scaling", UpdateDisplayConfigScaling, unchanged: false,
skipValues: [CCD.DisplayConfigScaling.Zero, CCD.DisplayConfigScaling.Custom, CCD.DisplayConfigScaling.ForceUint32]);
FormUtils.BuildDropDownMenu(mnuAmdResolution, "Rotation", typeof(CCD.DisplayConfigRotation), preset.DisplayConfig, "Rotation", UpdateDisplayConfigRotation, unchanged: false,
skipValues: [CCD.DisplayConfigRotation.Zero, CCD.DisplayConfigRotation.ForceUint32]);
}
}
@@ -460,7 +566,16 @@ namespace ColorControl.Services.AMD
{
var preset = GetSelectedAmdPreset();
preset.applyRefreshRate = !preset.applyRefreshRate;
preset.DisplayConfig.ApplyRefreshRate = !preset.DisplayConfig.ApplyRefreshRate;
AddOrUpdateItemAmd();
}
private void miAmdResolutionIncluded_Click(object sender, EventArgs e)
{
var preset = GetSelectedAmdPreset();
preset.DisplayConfig.ApplyResolution = !preset.DisplayConfig.ApplyResolution;
AddOrUpdateItemAmd();
}
+61 -1
View File
@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
+13 -11
View File
@@ -16,8 +16,7 @@ namespace ColorControl.Services.AMD
public bool toggleHDR { get; set; }
public bool applyDithering { get; set; }
public ADLDitherState ditherState { get; set; }
public bool applyRefreshRate { get; set; }
public uint refreshRate { get; set; }
public DisplayConfig DisplayConfig { get; set; }
public bool primaryDisplay { get; set; }
public string displayName { get; set; }
@@ -29,9 +28,8 @@ namespace ColorControl.Services.AMD
applyHDR = false;
HDREnabled = false;
toggleHDR = false;
applyRefreshRate = false;
refreshRate = 60;
primaryDisplay = true;
DisplayConfig = new DisplayConfig();
}
public AmdPreset(AmdPreset preset) : this()
@@ -50,8 +48,7 @@ namespace ColorControl.Services.AMD
toggleHDR = preset.toggleHDR;
applyDithering = preset.applyDithering;
ditherState = preset.ditherState;
applyRefreshRate = preset.applyRefreshRate;
refreshRate = preset.refreshRate;
DisplayConfig = new DisplayConfig(DisplayConfig);
}
public AmdPreset Clone()
@@ -63,8 +60,7 @@ namespace ColorControl.Services.AMD
public static string[] GetColumnNames()
{
//return new[] { "BPC", "Format", "Dynamic range", "Toggle HDR", "Shortcut" };
return new[] { "Name", "Display|140", "Color settings (BPC, format)|260", "Refresh rate|100", "Dithering", "HDR", "Shortcut", "Apply on startup" };
return new[] { "Name", "Display|140", "Color settings (BPC, format)|260", "Refresh rate|100", "Resolution|120", "Dithering", "HDR", "Shortcut", "Apply on startup" };
}
public override List<string> GetDisplayValues(Config config = null)
@@ -79,7 +75,8 @@ namespace ColorControl.Services.AMD
var colorSettings = string.Format("{0}: {1}, {2}", applyColorData ? "Included" : "Excluded", colorDepth, pixelFormat);
values.Add(colorSettings);
values.Add(string.Format("{0}: {1}Hz", applyRefreshRate ? "Included" : "Excluded", refreshRate));
values.Add(string.Format("{0}: {1}Hz", DisplayConfig.ApplyRefreshRate ? "Included" : "Excluded", DisplayConfig.RefreshRate));
values.Add(string.Format("{0}{1}", DisplayConfig.ApplyResolution ? "Included" : "Excluded", DisplayConfig.ApplyResolution ? ": " + DisplayConfig.GetResolutionDesc() : ""));
values.Add(string.Format("{0}: {1}", applyDithering ? "Included" : "Excluded", ditherState));
values.Add(string.Format("{0}: {1}", applyHDR ? "Included" : "Excluded", toggleHDR ? "Toggle" : HDREnabled ? "Enabled" : "Disabled"));
values.Add(shortcut);
@@ -121,9 +118,14 @@ namespace ColorControl.Services.AMD
sb.Append(colorSettings);
sb.Append(" / ");
}
if (applyRefreshRate)
if (DisplayConfig.ApplyRefreshRate)
{
sb.AppendFormat("{0}Hz", refreshRate);
sb.AppendFormat("{0}Hz", DisplayConfig.RefreshRate);
sb.Append(" / ");
}
if (DisplayConfig.ApplyResolution)
{
sb.AppendFormat("{0}", DisplayConfig.GetResolutionDesc());
sb.Append(" / ");
}
if (applyDithering)
+30 -18
View File
@@ -1,8 +1,8 @@
using ATI.ADL;
using ColorControl.Services.Common;
using ColorControl.Shared.Common;
using ColorControl.Shared.Contracts;
using ColorControl.Shared.Native;
using ColorControl.Shared.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
@@ -153,11 +153,11 @@ namespace ColorControl.Services.AMD
//}
}
if (preset.applyRefreshRate)
if (preset.DisplayConfig.ApplyRefreshRate || preset.DisplayConfig.ApplyResolution)
{
if (!SetMode(preset.DisplayConfig, true))
{
if (!SetRefreshRate(preset.refreshRate))
result = false;
result = false;
}
}
@@ -219,20 +219,14 @@ namespace ColorControl.Services.AMD
return Screen.PrimaryScreen.DeviceName;
}
public bool SetRefreshRate(uint refreshRate)
public bool SetMode(DisplayConfig displayConfig, bool updateRegistry = false)
{
var horizontal = 3840;
var vertical = 2160;
var display = GetCurrentDisplay();
ADLWrapper.GetDisplayResolution(display, ref horizontal, ref vertical);
var portrait = vertical > horizontal;
return SetRefreshRateInternal(GetDisplayDeviceName(display), (int)refreshRate, portrait, horizontal, vertical);
return SetMode(GetDisplayDeviceName(display), displayConfig, updateRegistry);
}
public List<uint> GetAvailableRefreshRates(AmdPreset preset = null)
public List<Rational> GetAvailableRefreshRates(AmdPreset preset = null)
{
if (preset != null)
{
@@ -245,9 +239,24 @@ namespace ColorControl.Services.AMD
ADLWrapper.GetDisplayResolution(display, ref horizontal, ref vertical);
var portrait = vertical > horizontal;
return GetAvailableRefreshRatesV2(GetDisplayDeviceName(display), horizontal, vertical);
}
return GetAvailableRefreshRatesInternal(GetDisplayDeviceName(display), portrait, horizontal, vertical);
public List<VirtualResolution> GetAvailableResolutionsV2(AmdPreset preset = null)
{
if (preset != null)
{
SetCurrentDisplay(preset);
}
var display = GetCurrentDisplay();
var deviceName = GetDisplayDeviceName(display);
if (deviceName == null)
{
return [];
}
return GetAvailableResolutionsInternalV2(deviceName);
}
public bool IsHDREnabled()
@@ -337,8 +346,11 @@ namespace ColorControl.Services.AMD
var colorSettings = $"{colorDepth.GetDescription()}, {pixelFormat.GetDescription()}";
values.Add(colorSettings);
var refreshRate = GetCurrentRefreshRate(screen?.DeviceName);
values.Add($"{refreshRate}Hz");
var displayConfig = CCD.GetDisplayConfig(screen?.DeviceName);
values.Add($"{displayConfig.RefreshRate}Hz");
values.Add($"{displayConfig.GetResolutionDesc()}");
var ditherState = GetDithering(display);
values.Add(ditherState.GetDescription());
@@ -346,7 +358,7 @@ namespace ColorControl.Services.AMD
var hdrEnabled = IsHDREnabled();
values.Add(hdrEnabled ? "Yes" : "No");
var infoLine = string.Format("{0}: {1}, {2}Hz, HDR: {3}", name, colorSettings, refreshRate, hdrEnabled ? "Yes" : "No");
var infoLine = string.Format("{0}: {1}, {2}Hz, {3}, HDR: {4}", name, colorSettings, displayConfig.RefreshRate, displayConfig.GetResolutionDesc(), hdrEnabled ? "Yes" : "No");
var displayInfo = new AmdDisplayInfo(display, values, infoLine);
+44 -111
View File
@@ -1,15 +1,9 @@
using ColorControl.Shared.Common;
using ColorControl.Shared.Contracts;
using ColorControl.Shared.Native;
using NWin32;
using NWin32.NativeTypes;
using Shared.Native;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
namespace ColorControl.Services.Common
{
@@ -28,80 +22,53 @@ namespace ColorControl.Services.Common
public abstract bool HasDisplaysAttached(bool reinitialize = false);
protected void ToggleHDR(int delay = 1000)
public bool SetMode(string displayName, VirtualResolution resolution = null, Rational refreshRate = null, bool updateRegistry = false)
{
Process.Start("ms-settings:display");
Thread.Sleep(delay);
var displayConfig = CCD.GetDisplayConfig(displayName);
var process = Process.GetProcessesByName("SystemSettings").FirstOrDefault();
if (process != null)
if (refreshRate != null)
{
System.Windows.Forms.SendKeys.SendWait("{TAB}");
System.Windows.Forms.SendKeys.SendWait("{TAB}");
System.Windows.Forms.SendKeys.SendWait(" ");
System.Windows.Forms.SendKeys.SendWait("%{F4}");
displayConfig.ApplyRefreshRate = true;
displayConfig.RefreshRate = refreshRate;
}
if (resolution != null)
{
displayConfig.ApplyResolution = true;
displayConfig.Resolution = resolution;
}
return SetMode(displayName, displayConfig, updateRegistry);
}
protected void OpenDisplaySettings(int delay = 1000)
public bool SetMode(string displayName, DisplayConfig displayConfig, bool updateRegistry = false)
{
Process.Start("ms-settings:display");
Thread.Sleep(delay);
var currentDisplayConfig = CCD.GetDisplayConfig(displayName);
var process = Process.GetProcessesByName("SystemSettings").FirstOrDefault();
if (process != null)
if (displayConfig.ApplyRefreshRate)
{
System.Windows.Forms.SendKeys.SendWait("%{F4}");
currentDisplayConfig.RefreshRate = displayConfig.RefreshRate;
}
if (displayConfig.ApplyResolution)
{
currentDisplayConfig.Resolution = displayConfig.Resolution;
}
if (displayConfig.Scaling != CCD.DisplayConfigScaling.Zero)
{
currentDisplayConfig.Scaling = displayConfig.Scaling;
}
if (displayConfig.Rotation != CCD.DisplayConfigRotation.Zero)
{
currentDisplayConfig.Rotation = displayConfig.Rotation;
}
return CCD.SetDisplayConfig(displayName, currentDisplayConfig, updateRegistry);
}
protected bool SetRefreshRateInternal(string displayName, int refreshRate, bool portrait, int horizontal, int vertical, bool updateRegistry = false)
{
uint i = 0;
DEVMODEA devMode;
while (NativeMethods.EnumDisplaySettingsA(displayName, i, out devMode))
{
// Also compare width with vertical and height with horizontal in case of portrait mode
if (((!portrait && devMode.dmPelsWidth == horizontal && devMode.dmPelsHeight == vertical) ||
(portrait && devMode.dmPelsWidth == vertical && devMode.dmPelsHeight == horizontal))
&& devMode.dmBitsPerPel == 32 && devMode.dmDisplayFrequency == refreshRate)
{
IntPtr bla = Marshal.AllocHGlobal(Marshal.SizeOf(devMode));
Marshal.StructureToPtr(devMode, bla, false);
var result = NativeMethods.ChangeDisplaySettingsExA(displayName, bla, IntPtr.Zero, updateRegistry ? (uint)NativeConstants.CDS_UPDATEREGISTRY : 0, IntPtr.Zero);
if (result != NativeConstants.DISP_CHANGE_SUCCESSFUL)
{
Logger.Error($"Could not set refreshrate {refreshRate} on display {displayName} because ChangeDisplaySettingsExA returned a non-zero return code: {result}");
}
return result == NativeConstants.DISP_CHANGE_SUCCESSFUL;
}
i++;
}
Logger.Info($"Could not set refreshrate {refreshRate} on display {displayName} because EnumDisplaySettings did not report it as a valid refreshrate");
return false;
}
protected List<uint> GetAvailableRefreshRatesInternal(string displayName, bool portrait, int horizontal, int vertical)
{
var list = new List<uint>();
uint i = 0;
DEVMODEA devMode;
while (NativeMethods.EnumDisplaySettingsA(displayName, i, out devMode))
{
if (((!portrait && devMode.dmPelsWidth == horizontal && devMode.dmPelsHeight == vertical) ||
(portrait && devMode.dmPelsWidth == vertical && devMode.dmPelsHeight == horizontal)) &&
!list.Contains(devMode.dmDisplayFrequency))
{
list.Add(devMode.dmDisplayFrequency);
}
i++;
}
return list;
}
protected List<Rational> GetAvailableRefreshRatesV2(string displayName, bool portrait, int horizontal, int vertical)
protected List<Rational> GetAvailableRefreshRatesV2(string displayName, int horizontal, int vertical)
{
var dxWrapper = new DXWrapper();
@@ -113,50 +80,16 @@ namespace ColorControl.Services.Common
return refreshRates.ToList();
}
protected uint GetCurrentRefreshRate(string displayName)
protected List<VirtualResolution> GetAvailableResolutionsInternalV2(string displayName, Rational refreshRate = null)
{
DEVMODEA devMode;
// NativeMethods defines modeNum as an 'uint' but we need to pass '-1'
if (WinApi.EnumDisplaySettingsA(displayName, WinApi.ENUM_CURRENT_SETTINGS, out devMode))
{
return devMode.dmDisplayFrequency;
}
return 0;
var dxWrapper = new DXWrapper();
var modes = dxWrapper.GetModes(displayName);
var refreshRates = modes.DistinctBy(m => $"{m.Resolution.width}x{m.Resolution.height}")
.Select(m => new VirtualResolution(m.Resolution.width, m.Resolution.height));
return refreshRates.ToList();
}
protected DEVMODEA GetCurrentMode(string displayName)
{
DEVMODEA devMode;
// NativeMethods defines modeNum as an 'uint' but we need to pass '-1'
if (WinApi.EnumDisplaySettingsA(displayName, WinApi.ENUM_CURRENT_SETTINGS, out devMode))
{
return devMode;
}
return devMode;
}
protected List<DEVMODEA> GetAvailableResolutionsInternal(string displayName, bool portrait, uint refreshRate = 0)
{
var list = new List<DEVMODEA>();
uint i = 0;
DEVMODEA devMode;
while (NativeMethods.EnumDisplaySettingsA(displayName, i, out devMode))
{
if ((portrait ? devMode.dmPelsWidth < devMode.dmPelsHeight : devMode.dmPelsWidth > devMode.dmPelsHeight) &&
(refreshRate == 0 || devMode.dmDisplayFrequency == refreshRate) &&
!list.Any(m => m.dmPelsWidth == devMode.dmPelsWidth && m.dmPelsHeight == devMode.dmPelsHeight))
{
list.Add(devMode);
}
i++;
}
list.Sort((a, b) => (int)(a.dmPelsWidth - b.dmPelsWidth));
return list;
}
}
}
@@ -75,7 +75,6 @@ public class NotifyIconManager
NotifyIcon.MouseDoubleClick += trayIcon_MouseDoubleClick;
NotifyIcon.ContextMenuStrip.Opened += trayIconContextMenu_Popup;
NotifyIcon.BalloonTipClicked += trayIconBalloonTip_Clicked;
}
public void HideIcon()
@@ -106,20 +105,12 @@ public class NotifyIconManager
Program.OpenMainForm();
}
private void trayIconBalloonTip_Clicked(object sender, EventArgs e)
{
//if (_updateHtmlUrl != null)
//{
// _winApiAdminService.StartProcess(_updateHtmlUrl);
//}
}
private void trayIconContextMenu_Popup(object sender, EventArgs e)
{
_nvTrayMenu.Visible = _serviceManager.NvService != null;
if (_nvTrayMenu.Visible)
{
var presets = _serviceManager.NvService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.applyRefreshRate || x.applyResolution || x.applyDriverSettings || x.applyOther || x.applyOverclocking || x.ApplyColorEnhancements || x.applyHdmiSettings);
var presets = _serviceManager.NvService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.DisplayConfig.ApplyRefreshRate || x.DisplayConfig.ApplyResolution || x.applyDriverSettings || x.applyOther || x.applyOverclocking || x.ApplyColorEnhancements || x.applyHdmiSettings);
UpdateTrayMenu(_nvTrayMenu, presets, TrayMenuItemNv_Click);
}
@@ -133,7 +124,7 @@ public class NotifyIconManager
_amdTrayMenu.Visible = _serviceManager.AmdService != null;
if (_amdTrayMenu.Visible)
{
var presets = _serviceManager.AmdService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.applyRefreshRate);
var presets = _serviceManager.AmdService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.DisplayConfig.ApplyRefreshRate || x.DisplayConfig.ApplyResolution);
UpdateTrayMenu(_amdTrayMenu, presets, TrayMenuItemAmd_Click);
}
@@ -181,7 +172,7 @@ public class NotifyIconManager
if (!string.IsNullOrEmpty(preset.shortcut))
{
name += " " + preset.shortcut;
//keys = Utils.ShortcutToKeys(preset.shortcut);
//keys = KeyboardShortcutDispatcher.ShortcutToKeys(preset.shortcut);
}
var item = new ToolStripMenuItem(name, null, null, keys);
@@ -56,8 +56,6 @@ public class UpdateManager
private void InitHandleCheckForUpdates(dynamic latest)
{
HandleCheckForUpdates(latest);
//FormUtils.BeginInvokeCheck(() => HandleCheckForUpdates(latest));
}
private void HandleCheckForUpdates(dynamic latest)
+2 -2
View File
@@ -18,7 +18,7 @@ using System.Windows.Forms;
namespace ColorControl.Services.LG
{
public partial class LgPanel : UserControl, IModulePanel
partial class LgPanel : UserControl, IModulePanel
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@@ -31,7 +31,7 @@ namespace ColorControl.Services.LG
private string _lgTabMessage;
private bool _disableEvents = false;
internal LgPanel(LgService lgService, ServiceManager serviceManager, GlobalContext globalContext, KeyboardShortcutDispatcher keyboardShortcutDispatcher)
public LgPanel(LgService lgService, ServiceManager serviceManager, GlobalContext globalContext, KeyboardShortcutDispatcher keyboardShortcutDispatcher)
{
_lgService = lgService;
_serviceManager = serviceManager;
+7 -7
View File
@@ -204,8 +204,8 @@ namespace ColorControl.Services.NVIDIA
var bla = GPUApi.GetClockBoostMask(GPU.Handle);
var masks = bla._Masks;
Logger.Debug("MASKS: " + masks[0]);
Logger.Debug("MASK: " + bla._Unknown1[0]);
//Logger.Debug("MASKS: " + masks[0]);
//Logger.Debug("MASK: " + bla._Unknown1[0]);
CurveV1 = GPUApi.GetVFPCurve(GPU.Handle, masks);
@@ -215,12 +215,12 @@ namespace ColorControl.Services.NVIDIA
var minV = CurveV1.GPUCurveEntries.Min(e => e.VoltageInMicroV);
var maxV = CurveV1.GPUCurveEntries.Max(e => e.VoltageInMicroV);
Logger.Debug($"CurveV1: L: {length}, MinF: {minFreq}, MaxF: {maxFreq}, MinV: {minV}, MaxV: {maxV}");
//Logger.Debug($"CurveV1: L: {length}, MinF: {minFreq}, MaxF: {maxFreq}, MinV: {minV}, MaxV: {maxV}");
foreach (var entry in CurveV1.GPUCurveEntries)
{
Logger.Debug($"CurveV1: Freq: {entry.FrequencyInkHz}, Volt: {entry.VoltageInMicroV}");
}
//foreach (var entry in CurveV1.GPUCurveEntries)
//{
// Logger.Debug($"CurveV1: Freq: {entry.FrequencyInkHz}, Volt: {entry.VoltageInMicroV}");
//}
return true;
}
+56 -41
View File
@@ -61,8 +61,6 @@ namespace ColorControl.Services.NVIDIA
miNvPresetColorEnhancementsIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuRefreshRate = new System.Windows.Forms.ToolStripMenuItem();
miRefreshRateIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuNvResolution = new System.Windows.Forms.ToolStripMenuItem();
miNvResolutionIncluded = new System.Windows.Forms.ToolStripMenuItem();
miNvPresetDithering = new System.Windows.Forms.ToolStripMenuItem();
miNvPresetApplyDithering = new System.Windows.Forms.ToolStripMenuItem();
miNvPresetDitheringEnabled = new System.Windows.Forms.ToolStripMenuItem();
@@ -92,6 +90,8 @@ namespace ColorControl.Services.NVIDIA
miNvHdmiIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuNvOverclocking = new System.Windows.Forms.ToolStripMenuItem();
miNvOverclockingIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuNvTriggers = new System.Windows.Forms.ToolStripMenuItem();
miNvTrigger1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
miNvCopyId = new System.Windows.Forms.ToolStripMenuItem();
btnApply = new System.Windows.Forms.Button();
lvNvPresets = new System.Windows.Forms.ListView();
@@ -102,8 +102,10 @@ namespace ColorControl.Services.NVIDIA
miNvTestDithering = new System.Windows.Forms.ToolStripMenuItem();
miNVIDIAInfo = new System.Windows.Forms.ToolStripMenuItem();
lvNvPresetsToolTip = new System.Windows.Forms.ToolTip(components);
mnuNvTriggers = new System.Windows.Forms.ToolStripMenuItem();
miNvTrigger1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
mnuNvResolution = new System.Windows.Forms.ToolStripMenuItem();
miNvResolutionIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuNvActiveResolution = new System.Windows.Forms.ToolStripMenuItem();
mnuNvVirtualResolution = new System.Windows.Forms.ToolStripMenuItem();
mnuNvPresets.SuspendLayout();
mnuNvSettings.SuspendLayout();
SuspendLayout();
@@ -383,7 +385,7 @@ namespace ColorControl.Services.NVIDIA
// miNvPresetColorSettings
//
miNvPresetColorSettings.Name = "miNvPresetColorSettings";
miNvPresetColorSettings.Size = new System.Drawing.Size(120, 22);
miNvPresetColorSettings.Size = new System.Drawing.Size(180, 22);
miNvPresetColorSettings.Text = "Included";
miNvPresetColorSettings.Click += miNvPresetColorSettings_Click;
//
@@ -397,7 +399,7 @@ namespace ColorControl.Services.NVIDIA
// miNvPresetColorEnhancementsIncluded
//
miNvPresetColorEnhancementsIncluded.Name = "miNvPresetColorEnhancementsIncluded";
miNvPresetColorEnhancementsIncluded.Size = new System.Drawing.Size(120, 22);
miNvPresetColorEnhancementsIncluded.Size = new System.Drawing.Size(180, 22);
miNvPresetColorEnhancementsIncluded.Text = "Included";
miNvPresetColorEnhancementsIncluded.Click += miNvPresetColorEnhancementsIncluded_Click;
//
@@ -411,25 +413,10 @@ namespace ColorControl.Services.NVIDIA
// miRefreshRateIncluded
//
miRefreshRateIncluded.Name = "miRefreshRateIncluded";
miRefreshRateIncluded.Size = new System.Drawing.Size(120, 22);
miRefreshRateIncluded.Size = new System.Drawing.Size(180, 22);
miRefreshRateIncluded.Text = "Included";
miRefreshRateIncluded.Click += includedToolStripMenuItem_Click;
//
// mnuNvResolution
//
mnuNvResolution.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvResolutionIncluded });
mnuNvResolution.Name = "mnuNvResolution";
mnuNvResolution.Size = new System.Drawing.Size(184, 22);
mnuNvResolution.Text = "Resolution";
//
// miNvResolutionIncluded
//
miNvResolutionIncluded.CheckOnClick = true;
miNvResolutionIncluded.Name = "miNvResolutionIncluded";
miNvResolutionIncluded.Size = new System.Drawing.Size(120, 22);
miNvResolutionIncluded.Text = "Included";
miNvResolutionIncluded.Click += miNvResolutionIncluded_Click;
//
// miNvPresetDithering
//
miNvPresetDithering.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvPresetApplyDithering, miNvPresetDitheringEnabled, mnuNvDitheringBitDepth, mnuNvDitheringMode });
@@ -440,14 +427,14 @@ namespace ColorControl.Services.NVIDIA
// miNvPresetApplyDithering
//
miNvPresetApplyDithering.Name = "miNvPresetApplyDithering";
miNvPresetApplyDithering.Size = new System.Drawing.Size(122, 22);
miNvPresetApplyDithering.Size = new System.Drawing.Size(180, 22);
miNvPresetApplyDithering.Text = "Included";
miNvPresetApplyDithering.Click += miNvPresetApplyDithering_Click;
//
// miNvPresetDitheringEnabled
//
miNvPresetDitheringEnabled.Name = "miNvPresetDitheringEnabled";
miNvPresetDitheringEnabled.Size = new System.Drawing.Size(122, 22);
miNvPresetDitheringEnabled.Size = new System.Drawing.Size(180, 22);
miNvPresetDitheringEnabled.Text = "Enabled";
miNvPresetDitheringEnabled.Click += miNvPresetDitheringEnabled_Click;
//
@@ -455,7 +442,7 @@ namespace ColorControl.Services.NVIDIA
//
mnuNvDitheringBitDepth.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvDithering6bit, miNvDithering8bit, miNvDithering10bit });
mnuNvDitheringBitDepth.Name = "mnuNvDitheringBitDepth";
mnuNvDitheringBitDepth.Size = new System.Drawing.Size(122, 22);
mnuNvDitheringBitDepth.Size = new System.Drawing.Size(180, 22);
mnuNvDitheringBitDepth.Text = "Bit depth";
//
// miNvDithering6bit
@@ -486,7 +473,7 @@ namespace ColorControl.Services.NVIDIA
//
mnuNvDitheringMode.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { spatial1ToolStripMenuItem, spatial2ToolStripMenuItem, spatialDynamic2x2ToolStripMenuItem, spatialStatic2x2ToolStripMenuItem, temporalToolStripMenuItem });
mnuNvDitheringMode.Name = "mnuNvDitheringMode";
mnuNvDitheringMode.Size = new System.Drawing.Size(122, 22);
mnuNvDitheringMode.Size = new System.Drawing.Size(180, 22);
mnuNvDitheringMode.Text = "Mode";
//
// spatial1ToolStripMenuItem
@@ -597,7 +584,7 @@ namespace ColorControl.Services.NVIDIA
// miNvDriverSettingsIncluded
//
miNvDriverSettingsIncluded.Name = "miNvDriverSettingsIncluded";
miNvDriverSettingsIncluded.Size = new System.Drawing.Size(120, 22);
miNvDriverSettingsIncluded.Size = new System.Drawing.Size(180, 22);
miNvDriverSettingsIncluded.Text = "Included";
miNvDriverSettingsIncluded.Click += miNvDriverSettingsIncluded_Click;
//
@@ -611,7 +598,7 @@ namespace ColorControl.Services.NVIDIA
// miNvOtherIncluded
//
miNvOtherIncluded.Name = "miNvOtherIncluded";
miNvOtherIncluded.Size = new System.Drawing.Size(120, 22);
miNvOtherIncluded.Size = new System.Drawing.Size(180, 22);
miNvOtherIncluded.Text = "Included";
miNvOtherIncluded.Click += miNvOtherIncluded_Click;
//
@@ -625,7 +612,7 @@ namespace ColorControl.Services.NVIDIA
// miNvHdmiIncluded
//
miNvHdmiIncluded.Name = "miNvHdmiIncluded";
miNvHdmiIncluded.Size = new System.Drawing.Size(120, 22);
miNvHdmiIncluded.Size = new System.Drawing.Size(180, 22);
miNvHdmiIncluded.Text = "Included";
miNvHdmiIncluded.Click += miNvHdmiIncluded_Click;
//
@@ -643,6 +630,20 @@ namespace ColorControl.Services.NVIDIA
miNvOverclockingIncluded.Text = "Included";
miNvOverclockingIncluded.Click += miNvOverclockingIncluded_Click;
//
// mnuNvTriggers
//
mnuNvTriggers.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvTrigger1ToolStripMenuItem });
mnuNvTriggers.Name = "mnuNvTriggers";
mnuNvTriggers.Size = new System.Drawing.Size(184, 22);
mnuNvTriggers.Text = "Triggers";
//
// miNvTrigger1ToolStripMenuItem
//
miNvTrigger1ToolStripMenuItem.Name = "miNvTrigger1ToolStripMenuItem";
miNvTrigger1ToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
miNvTrigger1ToolStripMenuItem.Text = "Trigger 1";
miNvTrigger1ToolStripMenuItem.Click += miNvTrigger1ToolStripMenuItem_Click;
//
// miNvCopyId
//
miNvCopyId.Name = "miNvCopyId";
@@ -727,19 +728,31 @@ namespace ColorControl.Services.NVIDIA
miNVIDIAInfo.Text = "NVIDIA Info";
miNVIDIAInfo.Click += miNVIDIAInfo_Click;
//
// mnuNvTriggers
// mnuNvResolution
//
mnuNvTriggers.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvTrigger1ToolStripMenuItem });
mnuNvTriggers.Name = "mnuNvTriggers";
mnuNvTriggers.Size = new System.Drawing.Size(184, 22);
mnuNvTriggers.Text = "Triggers";
mnuNvResolution.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvResolutionIncluded, mnuNvActiveResolution, mnuNvVirtualResolution });
mnuNvResolution.Name = "mnuNvResolution";
mnuNvResolution.Size = new System.Drawing.Size(184, 22);
mnuNvResolution.Text = "Resolution";
//
// miNvTrigger1ToolStripMenuItem
// miNvResolutionIncluded
//
miNvTrigger1ToolStripMenuItem.Name = "miNvTrigger1ToolStripMenuItem";
miNvTrigger1ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
miNvTrigger1ToolStripMenuItem.Text = "Trigger 1";
miNvTrigger1ToolStripMenuItem.Click += miNvTrigger1ToolStripMenuItem_Click;
miNvResolutionIncluded.Name = "miNvResolutionIncluded";
miNvResolutionIncluded.Size = new System.Drawing.Size(180, 22);
miNvResolutionIncluded.Text = "Included";
miNvResolutionIncluded.Click += miNvResolutionIncluded_Click;
//
// mnuNvActiveResolution
//
mnuNvActiveResolution.Name = "mnuNvActiveResolution";
mnuNvActiveResolution.Size = new System.Drawing.Size(180, 22);
mnuNvActiveResolution.Text = "Active";
//
// mnuNvVirtualResolution
//
mnuNvVirtualResolution.Name = "mnuNvVirtualResolution";
mnuNvVirtualResolution.Size = new System.Drawing.Size(180, 22);
mnuNvVirtualResolution.Text = "Virtual";
//
// NvPanel
//
@@ -817,8 +830,6 @@ namespace ColorControl.Services.NVIDIA
private System.Windows.Forms.ToolStripMenuItem miNvCopyId;
private System.Windows.Forms.Label lblNvPresetName;
private System.Windows.Forms.TextBox edtNvPresetName;
private System.Windows.Forms.ToolStripMenuItem mnuNvResolution;
private System.Windows.Forms.ToolStripMenuItem miNvResolutionIncluded;
private System.Windows.Forms.ToolStripMenuItem mnuNvDriverSettings;
private System.Windows.Forms.ToolStripMenuItem miNvDriverSettingsIncluded;
private System.Windows.Forms.CheckBox chkNvShowInQuickAccess;
@@ -852,5 +863,9 @@ namespace ColorControl.Services.NVIDIA
private System.Windows.Forms.ToolStripMenuItem miHDROutputModeHDR10Plus;
private System.Windows.Forms.ToolStripMenuItem mnuNvTriggers;
private System.Windows.Forms.ToolStripMenuItem miNvTrigger1ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuNvResolution;
private System.Windows.Forms.ToolStripMenuItem miNvResolutionIncluded;
private System.Windows.Forms.ToolStripMenuItem mnuNvActiveResolution;
private System.Windows.Forms.ToolStripMenuItem mnuNvVirtualResolution;
}
}
+143 -40
View File
@@ -15,7 +15,6 @@ using NStandard;
using NvAPIWrapper.Display;
using NvAPIWrapper.GPU;
using NvAPIWrapper.Native.Display;
using NWin32.NativeTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -316,7 +315,7 @@ namespace ColorControl.Services.NVIDIA
{
var preset = GetSelectedNvPreset();
preset.applyRefreshRate = !preset.applyRefreshRate;
preset.DisplayConfig.ApplyRefreshRate = !preset.DisplayConfig.ApplyRefreshRate;
AddOrUpdateItem();
}
@@ -342,6 +341,7 @@ namespace ColorControl.Services.NVIDIA
mnuNvPresetsColorEnhancements.Enabled = preset != null;
mnuRefreshRate.Enabled = preset != null;
mnuNvResolution.Enabled = preset != null;
mnuNvActiveResolution.Enabled = preset != null;
miNvPresetDithering.Enabled = preset != null;
miNvHDR.Enabled = preset != null;
miNvCopyId.Visible = presetItemsVisible;
@@ -435,8 +435,8 @@ namespace ColorControl.Services.NVIDIA
mnuNvPresetsColorSettings.Font = _menuItemFonts[preset.applyColorData];
mnuNvPresetsColorEnhancements.Font = _menuItemFonts[preset.ApplyColorEnhancements];
mnuRefreshRate.Font = _menuItemFonts[preset.applyRefreshRate];
mnuNvResolution.Font = _menuItemFonts[preset.applyResolution];
mnuRefreshRate.Font = _menuItemFonts[preset.DisplayConfig.ApplyRefreshRate];
mnuNvResolution.Font = _menuItemFonts[preset.DisplayConfig.ApplyResolution];
miNvPresetDithering.Font = _menuItemFonts[preset.applyDithering];
miNvHDR.Font = _menuItemFonts[preset.applyHDR];
mnuNvOverclocking.Font = _menuItemFonts[preset.applyOverclocking];
@@ -538,17 +538,14 @@ namespace ColorControl.Services.NVIDIA
{
mnuRefreshRate.DropDownItems.RemoveAt(mnuRefreshRate.DropDownItems.Count - 1);
}
while (mnuNvResolution.DropDownItems.Count > 1)
{
mnuNvResolution.DropDownItems.RemoveAt(mnuNvResolution.DropDownItems.Count - 1);
}
mnuNvActiveResolution.DropDownItems.Clear();
mnuNvVirtualResolution.DropDownItems.Clear();
}
if (mnuRefreshRate.DropDownItems.Count == 1)
{
var refreshRates = _nvService.GetAvailableRefreshRates(preset);
//var v2 = _nvService.GetAvailableRefreshRatesV2(preset);
var refreshRates = _nvService.GetAvailableRefreshRatesV2(preset);
_lastDisplayRefreshRates = displayName;
@@ -560,36 +557,64 @@ namespace ColorControl.Services.NVIDIA
}
}
if (mnuNvResolution.DropDownItems.Count == 1)
var modes = default(List<VirtualResolution>);
if (mnuNvActiveResolution.DropDownItems.Count == 0)
{
var modes = _nvService.GetAvailableResolutions(preset);
modes = _nvService.GetAvailableResolutionsV2(preset);
foreach (var mode in modes)
{
var item = mnuNvResolution.DropDownItems.AddCustom($"{mode.dmPelsWidth}x{mode.dmPelsHeight}");
var item = mnuNvActiveResolution.DropDownItems.AddCustom(mode.ToString());
item.Tag = mode;
item.Click += resolutionNvMenuItem_Click;
}
}
miRefreshRateIncluded.Checked = preset.applyRefreshRate;
if (mnuNvVirtualResolution.DropDownItems.Count == 0)
{
modes ??= _nvService.GetAvailableResolutionsV2(preset);
foreach (var mode in modes)
{
var item = mnuNvVirtualResolution.DropDownItems.AddCustom(mode.ToString());
item.Tag = mode;
item.Click += virtualResolutionNvMenuItem_Click;
}
}
miRefreshRateIncluded.Checked = preset.DisplayConfig.ApplyRefreshRate;
foreach (var item in mnuRefreshRate.DropDownItems)
{
if (item is ToolStripMenuItem menuItem && menuItem.Tag != null)
{
menuItem.Checked = (uint)menuItem.Tag == preset.refreshRate;
menuItem.Checked = ((Rational)menuItem.Tag).Equals(preset.DisplayConfig.RefreshRate);
}
}
miNvResolutionIncluded.Checked = preset.applyResolution;
foreach (var item in mnuNvResolution.DropDownItems)
miNvResolutionIncluded.Checked = preset.DisplayConfig.ApplyResolution;
foreach (var item in mnuNvActiveResolution.DropDownItems)
{
if (item is ToolStripMenuItem menuItem && menuItem.Tag != null)
{
var mode = (DEVMODEA)menuItem.Tag;
menuItem.Checked = mode.dmPelsWidth == preset.resolutionWidth && mode.dmPelsHeight == preset.resolutionHeight;
var mode = (VirtualResolution)menuItem.Tag;
menuItem.Checked = mode.ActiveWidth == preset.DisplayConfig.Resolution.ActiveWidth && mode.ActiveHeight == preset.DisplayConfig.Resolution.ActiveHeight;
}
}
foreach (var item in mnuNvVirtualResolution.DropDownItems)
{
if (item is ToolStripMenuItem menuItem && menuItem.Tag != null)
{
var mode = (VirtualResolution)menuItem.Tag;
menuItem.Checked = mode.VirtualWidth == preset.DisplayConfig.Resolution.VirtualWidth && mode.VirtualHeight == preset.DisplayConfig.Resolution.VirtualHeight;
}
}
FormUtils.BuildDropDownMenu(mnuNvResolution, "Scaling/Aspect Ratio", typeof(CCD.DisplayConfigScaling), preset.DisplayConfig, "Scaling", UpdateDisplayConfigScaling, unchanged: false,
skipValues: [CCD.DisplayConfigScaling.Zero, CCD.DisplayConfigScaling.Custom, CCD.DisplayConfigScaling.ForceUint32]);
FormUtils.BuildDropDownMenu(mnuNvResolution, "Rotation", typeof(CCD.DisplayConfigRotation), preset.DisplayConfig, "Rotation", UpdateDisplayConfigRotation, unchanged: false,
skipValues: [CCD.DisplayConfigRotation.Zero, CCD.DisplayConfigRotation.ForceUint32]);
}
private void UpdateNvPresetMenuFont(bool updateTopItems = false)
@@ -809,6 +834,54 @@ namespace ColorControl.Services.NVIDIA
AddOrUpdateItem();
}
private void UpdateDisplayConfigScaling(object sender, EventArgs e)
{
var menuItem = (ToolStripMenuItem)sender;
var value = (CCD.DisplayConfigScaling)menuItem.Tag;
var preset = GetSelectedNvPreset(true);
var settings = preset.DisplayConfig;
if (preset.IsDisplayPreset)
{
var updatedSettings = new DisplayConfig(settings);
updatedSettings.Scaling = value;
_nvService.SetMode(preset.Display.Name, updatedSettings);
UpdateDisplayInfoItems();
return;
}
preset.DisplayConfig.Scaling = value;
AddOrUpdateItem();
}
private void UpdateDisplayConfigRotation(object sender, EventArgs e)
{
var menuItem = (ToolStripMenuItem)sender;
var value = (CCD.DisplayConfigRotation)menuItem.Tag;
var preset = GetSelectedNvPreset(true);
var settings = preset.DisplayConfig;
if (preset.IsDisplayPreset)
{
var updatedSettings = new DisplayConfig(settings);
updatedSettings.Rotation = value;
_nvService.SetMode(preset.Display.Name, updatedSettings);
UpdateDisplayInfoItems();
return;
}
preset.DisplayConfig.Rotation = value;
AddOrUpdateItem();
}
private void nvPresetBrightnessMenuItem_Click(object sender, EventArgs e)
{
var preset = GetSelectedNvPreset(true);
@@ -994,39 +1067,63 @@ namespace ColorControl.Services.NVIDIA
private void refreshRateMenuItem_Click(object sender, EventArgs e)
{
var refreshRate = (uint)((ToolStripItem)sender).Tag;
var refreshRate = (Rational)((ToolStripItem)sender).Tag;
var preset = GetSelectedNvPreset(true);
if (preset.IsDisplayPreset)
{
_nvService.SetMode(refreshRate: refreshRate);
_nvService.SetMode(refreshRate: refreshRate, preset: preset);
UpdateDisplayInfoItems();
return;
}
preset.refreshRate = refreshRate;
preset.DisplayConfig.RefreshRate = refreshRate;
AddOrUpdateItem();
}
private void resolutionNvMenuItem_Click(object sender, EventArgs e)
{
var mode = (DEVMODEA)((ToolStripItem)sender).Tag;
var mode = (VirtualResolution)((ToolStripItem)sender).Tag;
var preset = GetSelectedNvPreset(true);
if (preset.IsDisplayPreset)
{
_nvService.SetMode(mode.dmPelsWidth, mode.dmPelsHeight);
_nvService.SetMode(mode, preset: preset);
UpdateDisplayInfoItems();
return;
}
preset.resolutionWidth = mode.dmPelsWidth;
preset.resolutionHeight = mode.dmPelsHeight;
preset.DisplayConfig.Resolution.ActiveWidth = mode.ActiveWidth;
preset.DisplayConfig.Resolution.ActiveHeight = mode.ActiveHeight;
AddOrUpdateItem();
}
private void virtualResolutionNvMenuItem_Click(object sender, EventArgs e)
{
var mode = (VirtualResolution)((ToolStripItem)sender).Tag;
var preset = GetSelectedNvPreset(true);
var virtualMode = new VirtualResolution(mode);
virtualMode.ActiveWidth = preset.DisplayConfig.Resolution.ActiveWidth;
virtualMode.ActiveHeight = preset.DisplayConfig.Resolution.ActiveHeight;
if (preset.IsDisplayPreset)
{
_nvService.SetMode(virtualMode, preset: preset);
UpdateDisplayInfoItems();
return;
}
preset.DisplayConfig.Resolution.VirtualWidth = virtualMode.VirtualWidth;
preset.DisplayConfig.Resolution.VirtualHeight = virtualMode.VirtualHeight;
AddOrUpdateItem();
}
@@ -1155,7 +1252,9 @@ namespace ColorControl.Services.NVIDIA
return;
}
var modes = _nvService.GetAvailableResolutions(preset).Select(d => $"{d.dmPelsWidth}x{d.dmPelsHeight}").ToList();
var resolutions = _nvService.GetAvailableResolutionsV2(preset);
var modes = resolutions.Select(r => r.ToString()).ToList();
var modesField = FieldDefinition.CreateDropDownField("Resolution", modes);
@@ -1166,12 +1265,12 @@ namespace ColorControl.Services.NVIDIA
return;
}
var values = modesField.Value.ToString().Split('x').Select(s => Utils.ParseUInt(s)).ToArray();
var value = modesField.Value.ToString();
var resolution = resolutions.First(r => r.ToString() == value);
preset.resolutionWidth = values[0];
preset.resolutionHeight = values[1];
preset.DisplayConfig.Resolution = resolution;
preset.applyResolution = true;
preset.DisplayConfig.ApplyResolution = true;
}
private void AskRefreshRate(NvPreset preset, bool ask = true)
@@ -1181,9 +1280,11 @@ namespace ColorControl.Services.NVIDIA
return;
}
var modes = _nvService.GetAvailableRefreshRates(preset).Select(d => d.ToString()).ToList();
var modes = _nvService.GetAvailableRefreshRatesV2(preset).ToList();
var modesField = FieldDefinition.CreateDropDownField("Refresh rate", modes);
var stringModes = modes.Select(m => m.ToString()).ToList();
var modesField = FieldDefinition.CreateDropDownField("Refresh rate", stringModes);
var result = MessageForms.ShowDialog("Refresh rate", new[] { modesField });
@@ -1192,10 +1293,14 @@ namespace ColorControl.Services.NVIDIA
return;
}
var value = modesField.ValueAsUInt;
var value = modesField.Value.ToString();
var refreshRate = modes.FirstOrDefault(m => m.ToString() == value);
preset.refreshRate = value;
preset.applyRefreshRate = true;
if (refreshRate != null)
{
preset.DisplayConfig.RefreshRate = refreshRate;
preset.DisplayConfig.ApplyRefreshRate = true;
}
}
private void miHDRIncluded_Click(object sender, EventArgs e)
@@ -1320,8 +1425,6 @@ namespace ColorControl.Services.NVIDIA
private void edtShortcut_TextChanged(object sender, EventArgs e)
{
var text = edtShortcut.Text;
var preset = GetSelectedNvPreset();
ServiceFormUtils.UpdateShortcutTextBox(edtShortcut, preset);
@@ -1331,7 +1434,7 @@ namespace ColorControl.Services.NVIDIA
{
var preset = GetSelectedNvPreset();
preset.applyResolution = !preset.applyResolution;
preset.DisplayConfig.ApplyResolution = !preset.DisplayConfig.ApplyResolution;
AddOrUpdateItem();
}
+14 -24
View File
@@ -27,11 +27,7 @@ namespace ColorControl.Services.NVIDIA
public bool toggleHDR { get; set; }
public bool applyDithering { get; set; }
public bool? ditheringEnabled { get; set; }
public bool applyRefreshRate { get; set; }
public uint refreshRate { get; set; }
public bool applyResolution { get; set; }
public uint resolutionWidth { get; set; }
public uint resolutionHeight { get; set; }
public DisplayConfig DisplayConfig { get; set; }
public bool primaryDisplay { get; set; }
public string displayName { get; set; }
public uint ditheringBits { get; set; }
@@ -67,11 +63,7 @@ namespace ColorControl.Services.NVIDIA
applyHDR = false;
HDREnabled = false;
toggleHDR = false;
applyRefreshRate = false;
refreshRate = 60;
applyResolution = false;
resolutionWidth = 0;
resolutionHeight = 0;
DisplayConfig = new DisplayConfig();
primaryDisplay = true;
ditheringBits = 1;
ditheringMode = 4;
@@ -108,11 +100,9 @@ namespace ColorControl.Services.NVIDIA
applyDithering = preset.applyDithering;
ditheringEnabled = preset.ditheringEnabled;
applyRefreshRate = preset.applyRefreshRate;
refreshRate = preset.refreshRate;
applyResolution = preset.applyResolution;
resolutionWidth = preset.resolutionWidth;
resolutionHeight = preset.resolutionHeight;
DisplayConfig = new DisplayConfig(DisplayConfig);
applyDriverSettings = preset.applyDriverSettings;
driverSettings = new Dictionary<uint, uint>(preset.driverSettings);
@@ -137,7 +127,7 @@ namespace ColorControl.Services.NVIDIA
public static string[] GetColumnNames()
{
return new[] { "Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Color enhancements", "Refresh rate|100", "Resolution|120", "Dithering", "HDR", "Driver settings|300", "HDMI settings|200", "Other|200", "Overclocking|300", "Shortcut", "Apply on startup" };
return new[] { "Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Color enhancements", "Refresh rate|120", "Resolution|150", "Dithering", "HDR", "Driver settings|300", "HDMI settings|200", "Other|200", "Overclocking|300", "Shortcut", "Apply on startup" };
}
public override List<string> GetDisplayValues(Config config = null)
@@ -158,11 +148,11 @@ namespace ColorControl.Services.NVIDIA
values.Add(FormatDisplaySetting(GetColorEnhancementsDescription(), isCurrent, ApplyColorEnhancements));
values.Add(FormatDisplaySetting(string.Format("{0}Hz", refreshRate), isCurrent, applyRefreshRate));
values.Add(FormatDisplaySetting(string.Format("{0}Hz", DisplayConfig.RefreshRate), isCurrent, DisplayConfig.ApplyRefreshRate));
if (applyResolution || resolutionWidth > 0)
if (DisplayConfig.ApplyResolution || DisplayConfig.Resolution.ActiveWidth > 0)
{
values.Add(FormatDisplaySetting(string.Format("{0}x{1}", resolutionWidth, resolutionHeight), isCurrent, applyResolution));
values.Add(FormatDisplaySetting(string.Format("{0}", DisplayConfig.GetResolutionDesc()), isCurrent, DisplayConfig.ApplyResolution));
}
else
{
@@ -190,7 +180,7 @@ namespace ColorControl.Services.NVIDIA
if (isCurrent)
{
InfoLine = string.Format("{0}: {1}, {2}Hz, HDR: {3}", displayName, colorSettings, refreshRate, HDREnabled ? "Yes" : "No");
InfoLine = string.Format("{0}: {1}, {2}Hz, {3}, HDR: {4}", displayName, colorSettings, DisplayConfig.RefreshRate, DisplayConfig.GetResolutionDesc(), HDREnabled ? "Yes" : "No");
}
return values;
@@ -380,14 +370,14 @@ namespace ColorControl.Services.NVIDIA
sb.Append(colorSettings);
sb.Append(" / ");
}
if (applyRefreshRate)
if (DisplayConfig.ApplyRefreshRate)
{
sb.AppendFormat("{0}Hz", refreshRate);
sb.AppendFormat("{0}Hz", DisplayConfig.RefreshRate);
sb.Append(" / ");
}
if (applyResolution)
if (DisplayConfig.ApplyResolution)
{
sb.AppendFormat("{0}x{1}", resolutionWidth, resolutionHeight);
sb.AppendFormat("{0}", DisplayConfig.GetResolutionDesc());
sb.Append(" / ");
}
if (applyDithering)
+36 -68
View File
@@ -23,7 +23,6 @@ using NvAPIWrapper.Native.GPU.Structures;
using NvAPIWrapper.Native.Helpers;
using NvAPIWrapper.Native.Interfaces.Display;
using NWin32;
using NWin32.NativeTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -422,11 +421,6 @@ namespace ColorControl.Services.NVIDIA
return false;
}
if (preset.applyOther && preset.scaling.HasValue)
{
SetScaling(display, preset.scaling.Value);
}
var hdrEnabled = IsHDREnabled();
var newHdrEnabled = preset.applyHDR && (preset.HDREnabled || (preset.toggleHDR && !hdrEnabled));
@@ -434,12 +428,13 @@ namespace ColorControl.Services.NVIDIA
if (preset.applyColorData && (ColorDataDiffers(preset.colorData) || (!newHdrEnabled && preset.applyColorData && preset.colorData.Colorimetry != ColorDataColorimetry.Auto)))
{
if (preset.applyRefreshRate || preset.applyResolution)
if (preset.DisplayConfig.ApplyRefreshRate || preset.DisplayConfig.ApplyResolution)
{
var timing = display.DisplayDevice.CurrentTiming;
if ((preset.applyRefreshRate && preset.refreshRate < timing.Extra.RefreshRate) || (preset.applyResolution && preset.resolutionWidth < timing.HorizontalVisible))
if ((preset.DisplayConfig.ApplyRefreshRate && preset.DisplayConfig.RefreshRate.MilliValue < timing.Extra.FrequencyInMillihertz) ||
(preset.DisplayConfig.ApplyResolution && preset.DisplayConfig.Resolution.ActiveWidth < timing.HorizontalVisible))
{
SetMode(preset.applyResolution ? preset.resolutionWidth : 0, preset.applyResolution ? preset.resolutionHeight : 0, preset.applyRefreshRate ? preset.refreshRate : 0, true);
SetMode(preset.DisplayConfig, true);
}
}
@@ -464,9 +459,9 @@ namespace ColorControl.Services.NVIDIA
}
}
if (preset.applyRefreshRate || preset.applyResolution)
if (preset.DisplayConfig.ApplyRefreshRate || preset.DisplayConfig.ApplyResolution)
{
if (!SetMode(preset.applyResolution ? preset.resolutionWidth : 0, preset.applyResolution ? preset.resolutionHeight : 0, preset.applyRefreshRate ? preset.refreshRate : 0, true))
if (!SetMode(preset.DisplayConfig, true))
{
result = false;
}
@@ -483,6 +478,11 @@ namespace ColorControl.Services.NVIDIA
{
CCD.SetDisplayDefaultColorProfile(display.Name, preset.ColorProfileSettings.ProfileName, _globalContext.Config.SetMinTmlAndMaxTml);
}
if (preset.scaling.HasValue)
{
SetScaling(display, preset.scaling.Value);
}
}
if (preset.applyHdmiSettings)
@@ -1035,50 +1035,26 @@ namespace ColorControl.Services.NVIDIA
return dither;
}
public bool SetMode(uint resolutionWidth = 0, uint resolutionHeight = 0, uint refreshRate = 0, bool updateRegistry = false)
public bool SetMode(VirtualResolution resolution = null, Rational refreshRate = null, bool updateRegistry = false, NvPreset preset = null)
{
var display = GetCurrentDisplay();
var display = preset == null ? GetCurrentDisplay() : GetPresetDisplay(preset);
if (display == null)
{
return false;
}
var desktopRect = GetDesktopRect(display);
if (refreshRate == 0)
{
var timing = display.DisplayDevice.CurrentTiming;
refreshRate = (uint)timing.Extra.RefreshRate;
}
if (resolutionWidth == 0)
{
resolutionWidth = (uint)desktopRect.Width;
resolutionHeight = (uint)desktopRect.Height;
}
var portrait = IsDisplayInPortraitMode(display);
return SetRefreshRateInternal(display.Name, (int)refreshRate, portrait, (int)resolutionWidth, (int)resolutionHeight, updateRegistry);
return SetMode(display.Name, resolution, refreshRate, updateRegistry);
}
public List<uint> GetAvailableRefreshRates(NvPreset preset = null)
public bool SetMode(DisplayConfig displayConfig, bool updateRegistry = false, NvPreset preset = null)
{
if (preset != null)
{
SetCurrentDisplay(preset);
}
var display = GetCurrentDisplay();
var display = preset == null ? GetCurrentDisplay() : GetPresetDisplay(preset);
if (display == null)
{
return new List<uint>();
return false;
}
var portrait = IsDisplayInPortraitMode(display);
var desktopRect = GetDesktopRect(display);
return GetAvailableRefreshRatesInternal(display.Name, portrait, desktopRect.Width, desktopRect.Height);
return SetMode(display.Name, displayConfig, updateRegistry);
}
public List<Rational> GetAvailableRefreshRatesV2(NvPreset preset = null)
@@ -1094,10 +1070,25 @@ namespace ColorControl.Services.NVIDIA
return [];
}
var portrait = IsDisplayInPortraitMode(display);
var desktopRect = GetDesktopRect(display);
return GetAvailableRefreshRatesV2(display.Name, portrait, desktopRect.Width, desktopRect.Height);
return GetAvailableRefreshRatesV2(display.Name, desktopRect.Width, desktopRect.Height);
}
public List<VirtualResolution> GetAvailableResolutionsV2(NvPreset preset = null)
{
if (preset != null)
{
SetCurrentDisplay(preset);
}
var display = GetCurrentDisplay();
if (display == null)
{
return [];
}
return GetAvailableResolutionsInternalV2(display.Name);
}
private Rectangle GetDesktopRect(Display display)
@@ -1126,25 +1117,6 @@ namespace ColorControl.Services.NVIDIA
}
}
public List<DEVMODEA> GetAvailableResolutions(NvPreset preset = null)
{
if (preset != null)
{
SetCurrentDisplay(preset);
}
var display = GetCurrentDisplay();
if (display == null)
{
return new List<DEVMODEA>();
}
var portrait = IsDisplayInPortraitMode(display);
var timing = display.DisplayDevice.CurrentTiming;
return GetAvailableResolutionsInternal(display.Name, portrait, (uint)(timing.Extra.RefreshRate));
}
public bool IsHDREnabled(Display currentDisplay = null)
{
var display = currentDisplay ?? GetCurrentDisplay();
@@ -1537,11 +1509,7 @@ namespace ColorControl.Services.NVIDIA
preset.scaling = GetScaling(display);
preset.ColorProfileSettings.ProfileName = CCD.GetDisplayDefaultColorProfile(display.Name, preset.HDREnabled ? COLORPROFILESUBTYPE.CPST_EXTENDED_DISPLAY_COLOR_MODE : COLORPROFILESUBTYPE.CPST_STANDARD_DISPLAY_COLOR_MODE);
var mode = GetCurrentMode(display.Name);
preset.refreshRate = mode.dmDisplayFrequency;
preset.resolutionHeight = mode.dmPelsHeight;
preset.resolutionWidth = mode.dmPelsWidth;
preset.DisplayConfig = CCD.GetDisplayConfig(display.Name);
var ditherInfo = GetDithering(display);
@@ -43,8 +43,8 @@ namespace ColorControl.Services.Samsung
public enum ServiceMenuType
{
HospitalityMenu,
FactoryMenu2024,
FactoryMenu,
HospitalityMenu
}
public delegate void GenericDelegate(object sender);
@@ -702,12 +702,12 @@ namespace ColorControl.Services.Samsung
private async Task<bool> ServiceMenuAction(Dictionary<string, object> _)
{
var serviceMenuTypes = new[] { ServiceMenuType.HospitalityMenu, ServiceMenuType.FactoryMenu2024 }.Select(t => Utils.GetDescription(t));
var serviceMenuTypes = new[] { ServiceMenuType.FactoryMenu, ServiceMenuType.HospitalityMenu }.Select(t => Utils.GetDescription(t));
var serviceMenuTypeField = new FieldDefinition
{
Label = "Service Menu Access Type",
SubLabel = "Both types will not reset your settings. 'Factory Menu 2024' is recommended for 2024 series. Click 'Next >' to continue or 'X' to stop",
SubLabel = "Both types will not reset your settings. 'FactoryMenu' is recommended for 2024 series but will also work for older ones. Click 'Next >' to continue or 'X' to stop",
FieldType = FieldType.DropDown,
Values = serviceMenuTypes,
Value = ServiceMenuType.HospitalityMenu
@@ -720,8 +720,8 @@ namespace ColorControl.Services.Samsung
return serviceMenuTypeField.ValueAsEnum<ServiceMenuType>() switch
{
ServiceMenuType.HospitalityMenu => await OpenHospitalityMenu(),
ServiceMenuType.FactoryMenu2024 => await OpenFactoryMenu2024()
ServiceMenuType.FactoryMenu => await OpenFactoryMenu(),
ServiceMenuType.HospitalityMenu => await OpenHospitalityMenu()
};
}
@@ -776,7 +776,7 @@ namespace ColorControl.Services.Samsung
return true;
}
private async Task<bool> OpenFactoryMenu2024()
private async Task<bool> OpenFactoryMenu()
{
var preset1 = new SamsungPreset("ServiceMenuStep1", null, ["KEY_INFO", "KEY_FACTORY:2000"]);
var preset2 = new SamsungPreset("ServiceMenuStep2", null, ["KEY_UP", "KEY_0", "KEY_0", "KEY_9", "KEY_8"]);
+49
View File
@@ -0,0 +1,49 @@
using ColorControl.Shared.Common;
using static ColorControl.Shared.Native.CCD;
namespace ColorControl.Shared.Contracts;
public class DisplayConfig
{
public bool ApplyResolution { get; set; }
public VirtualResolution Resolution { get; set; }
public bool ApplyRefreshRate { get; set; }
public Rational RefreshRate { get; set; }
public DisplayConfigScaling Scaling { get; set; }
public DisplayConfigRotation Rotation { get; set; }
public DisplayConfig()
{
RefreshRate = new Rational(60000, 1000);
Resolution = new VirtualResolution(0, 0);
Scaling = DisplayConfigScaling.Identity;
Rotation = DisplayConfigRotation.Identity;
}
public DisplayConfig(DisplayConfig displayConfig)
{
ApplyResolution = displayConfig.ApplyResolution;
Resolution = new VirtualResolution(displayConfig.Resolution);
ApplyRefreshRate = displayConfig.ApplyRefreshRate;
RefreshRate = new Rational(displayConfig.RefreshRate.Numerator, displayConfig.RefreshRate.Denominator);
Scaling = displayConfig.Scaling;
Rotation = displayConfig.Rotation;
}
public string GetResolutionDesc()
{
var text = Resolution.ToString();
if (Rotation is not DisplayConfigRotation.Identity or DisplayConfigRotation.Zero)
{
text += $" - {Rotation.GetDescription()}";
}
if (Scaling is not DisplayConfigScaling.Identity or DisplayConfigScaling.Zero)
{
text += $" - {Scaling.GetDescription()}";
}
return text;
}
}
+13 -3
View File
@@ -1,9 +1,11 @@
namespace ColorControl.Shared.Contracts;
using Newtonsoft.Json;
namespace ColorControl.Shared.Contracts;
public class Rational
{
public uint Numerator { get; }
public uint Denominator { get; }
public uint Numerator { get; set; }
public uint Denominator { get; set; }
public Rational(uint numerator, uint denominator)
{
@@ -17,4 +19,12 @@ public class Rational
return $"{value:0.000}";
}
[JsonIgnore]
public uint MilliValue => (uint)(Numerator / (double)Denominator * 1000);
public bool Equals(Rational other)
{
return MilliValue == other.MilliValue;
}
}
+43
View File
@@ -0,0 +1,43 @@
namespace ColorControl.Shared.Contracts;
public class VirtualResolution
{
public uint ActiveWidth { get; set; }
public uint ActiveHeight { get; set; }
public uint VirtualWidth { get; set; }
public uint VirtualHeight { get; set; }
public VirtualResolution(uint activeWidth, uint activeHeight)
{
ActiveWidth = activeWidth;
ActiveHeight = activeHeight;
VirtualWidth = activeWidth;
VirtualHeight = activeHeight;
}
public VirtualResolution(VirtualResolution resolution)
{
ActiveWidth = resolution.ActiveWidth;
ActiveHeight = resolution.ActiveHeight;
VirtualWidth = resolution.VirtualWidth;
VirtualHeight = resolution.VirtualHeight;
}
public override string ToString()
{
if (ActiveWidth == 0 && ActiveHeight == 0)
{
return "Not set";
}
if (VirtualWidth == 0 && VirtualHeight == 0)
{
return $"{ActiveWidth}x{ActiveHeight}";
}
return ActiveWidth == VirtualWidth && ActiveHeight == VirtualHeight ?
$"{ActiveWidth}x{ActiveHeight}" :
$"{VirtualWidth}x{VirtualHeight} ({ActiveWidth}x{ActiveHeight})";
}
}
@@ -313,7 +313,7 @@ public class KeyboardShortcutDispatcher : EventDispatcher<KeyboardShortcutEventA
}
if (((uint)mods & (uint)ModKeys.Win) > 0)
{
keys |= Keys.Control;
keys |= Keys.LWin;
}
keys |= (Keys)key;
+212 -37
View File
@@ -1,4 +1,5 @@
using ColorControl.Shared.Forms;
using ColorControl.Shared.Contracts;
using ColorControl.Shared.Forms;
using MHC2Gen;
using NWin32;
using System.ComponentModel;
@@ -12,6 +13,9 @@ namespace ColorControl.Shared.Native
public static class CCD
{
delegate (T, bool) DisplayConfigModeInfoDelegate<T>(DisplayConfigModeInfo modeInfo);
delegate (T, bool) DisplayConfigModeInfosDelegate<T>(DisplayConfigPathInfo pathInfo, DisplayConfigModeInfo sourceMode, DisplayConfigModeInfo targetMode);
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
public enum DisplayTopology
{
@@ -21,6 +25,13 @@ namespace ColorControl.Shared.Native
Clone
}
public static double GetDpiForSystem()
{
var dpi = NativeMethods.GetDpiForSystem();
return dpi / 96.0;
}
public static DisplayTopology GetDisplayTopology()
{
uint numPathArrayElements;
@@ -64,40 +75,100 @@ namespace ColorControl.Shared.Native
}
}
public static void GetAllPaths()
public static DisplayConfig GetDisplayConfig(string displayName)
{
uint numPathArrayElements;
uint numModeInfoArrayElements;
var config = new DisplayConfig();
NativeMethods.GetDisplayConfigBufferSizes(QueryDisplayFlags.AllPaths, out numPathArrayElements, out numModeInfoArrayElements);
ExecuteForModeConfigs((pathInfo, sourceMode, targetMode) =>
{
config.RefreshRate.Numerator = targetMode.targetMode.targetVideoSignalInfo.vSyncFreq.numerator;
config.RefreshRate.Denominator = targetMode.targetMode.targetVideoSignalInfo.vSyncFreq.denominator;
config.Resolution.ActiveWidth = targetMode.targetMode.targetVideoSignalInfo.activeSize.cx;
config.Resolution.ActiveHeight = targetMode.targetMode.targetVideoSignalInfo.activeSize.cy;
var pathArray = new DisplayConfigPathInfo[numPathArrayElements];
var modeArray = new DisplayConfigModeInfo[numModeInfoArrayElements];
config.Resolution.VirtualWidth = sourceMode.sourceMode.width;
config.Resolution.VirtualHeight = sourceMode.sourceMode.height;
var result = NativeMethods.QueryDisplayConfig(QueryDisplayFlags.AllPaths, ref numPathArrayElements, pathArray, ref numModeInfoArrayElements, modeArray, out Unsafe.NullRef<DisplayConfigTopologyId>());
config.Scaling = pathInfo.targetInfo.scaling;
config.Rotation = pathInfo.targetInfo.rotation;
return (default(DisplayConfigModeInfo), true);
}, displayName
);
return config;
}
public static void SetDisplayConfig()
public static bool SetDisplayConfig(string displayName, DisplayConfig displayConfig, bool updateRegistry)
{
uint numPathArrayElements;
uint numModeInfoArrayElements;
uint pathCount, modeCount;
NativeMethods.GetDisplayConfigBufferSizes(QueryDisplayFlags.AllPaths, out numPathArrayElements, out numModeInfoArrayElements);
var err = NativeMethods.GetDisplayConfigBufferSizes(QueryDisplayFlags.OnlyActivePaths, out pathCount, out modeCount);
try
{
if (err != NativeConstants.ERROR_SUCCESS)
{
return false;
}
var pathsArray = new DisplayConfigPathInfo[pathCount];
var modesArray = new DisplayConfigModeInfo[modeCount];
var pathArray = new DisplayConfigPathInfo[numPathArrayElements];
var modeArray = new DisplayConfigModeInfo[numModeInfoArrayElements];
err = NativeMethods.QueryDisplayConfig(QueryDisplayFlags.OnlyActivePaths, ref pathCount, pathsArray, ref modeCount, modesArray, out Unsafe.NullRef<DisplayConfigTopologyId>());
if (err != NativeConstants.ERROR_SUCCESS)
{
return false;
}
var result = NativeMethods.QueryDisplayConfig(QueryDisplayFlags.AllPaths, ref numPathArrayElements, pathArray, ref numModeInfoArrayElements, modeArray, out Unsafe.NullRef<DisplayConfigTopologyId>());
var resolution = displayConfig.Resolution;
var refreshRate = displayConfig.RefreshRate;
var sourceIndex = pathArray[0].sourceInfo.modeInfoIdx;
var targetIndex = pathArray[0].targetInfo.modeInfoIdx;
foreach (var path in pathsArray)
{
if (!MatchDisplayNames(path, displayName))
{
continue;
}
modeArray[targetIndex].targetMode.targetVideoSignalInfo.vSyncFreq = new DisplayConfigRational { denominator = 1000, numerator = 145000 };
var sourceIndex = path.sourceInfo.modeInfoIdx;
var targetIndex = path.targetInfo.modeInfoIdx;
var sourceMode = modesArray[sourceIndex];
var targetMode = modesArray[targetIndex];
result = NativeMethods.SetDisplayConfig(1, pathArray, 2, modeArray, SdcFlags.Apply | SdcFlags.UseSuppliedDisplayConfig | SdcFlags.AllowChanges);
targetMode.targetMode.targetVideoSignalInfo.vSyncFreq = new DisplayConfigRational { denominator = refreshRate.Denominator, numerator = refreshRate.Numerator };
targetMode.targetMode.targetVideoSignalInfo.activeSize.cx = resolution.ActiveWidth;
targetMode.targetMode.targetVideoSignalInfo.activeSize.cy = resolution.ActiveHeight;
sourceMode.sourceMode.width = resolution.VirtualWidth;
sourceMode.sourceMode.height = resolution.VirtualHeight;
var flags = SdcFlags.Apply | SdcFlags.UseSuppliedDisplayConfig | SdcFlags.AllowChanges;
if (updateRegistry)
{
flags |= SdcFlags.SaveToDatabase;
}
var path2 = path;
path2.targetInfo.scaling = displayConfig.Scaling == DisplayConfigScaling.Zero ? DisplayConfigScaling.Identity : displayConfig.Scaling;
path2.targetInfo.rotation = displayConfig.Rotation == DisplayConfigRotation.Zero ? DisplayConfigRotation.Identity : displayConfig.Rotation;
path2.targetInfo.refreshRate = new DisplayConfigRational { numerator = displayConfig.RefreshRate.Numerator, denominator = displayConfig.RefreshRate.Denominator };
err = NativeMethods.SetDisplayConfig(1, [path2], 2, [targetMode, sourceMode], flags);
return err == 0;
}
return false;
}
finally
{
if (err != 0)
{
Logger.Warn($"Could not set display config {displayConfig.Resolution}@{displayConfig.RefreshRate} on display {displayName} because: error code {err}");
}
}
}
public static LUID GetAdapterId(string displayName = null)
{
return ExecuteForModeConfig((modeInfo) =>
@@ -437,7 +508,7 @@ namespace ColorControl.Shared.Native
);
}
private static T ExecuteForModeConfig<T>(DisplayConfigModeInfoDelegate<T> infoDelegate, string displayName = null)
private static T ExecuteForModeConfig<T>(DisplayConfigModeInfoDelegate<T> infoDelegate, string displayName = null, QueryDisplayFlags queryDisplayFlags = QueryDisplayFlags.OnlyActivePaths)
{
uint pathCount, modeCount;
@@ -447,7 +518,14 @@ namespace ColorControl.Shared.Native
var pathsArray = new DisplayConfigPathInfo[pathCount];
var modesArray = new DisplayConfigModeInfo[modeCount];
err = NativeMethods.QueryDisplayConfig(QueryDisplayFlags.DatabaseCurrent, ref pathCount, pathsArray, ref modeCount, modesArray, out _);
if (queryDisplayFlags == QueryDisplayFlags.OnlyActivePaths)
{
err = NativeMethods.QueryDisplayConfig(queryDisplayFlags, ref pathCount, pathsArray, ref modeCount, modesArray, out Unsafe.NullRef<DisplayConfigTopologyId>());
}
else
{
err = NativeMethods.QueryDisplayConfig(queryDisplayFlags, ref pathCount, pathsArray, ref modeCount, modesArray, out _);
}
if (err == NativeConstants.ERROR_SUCCESS)
{
foreach (var path in pathsArray)
@@ -480,6 +558,56 @@ namespace ColorControl.Shared.Native
return default;
}
private static T ExecuteForModeConfigs<T>(DisplayConfigModeInfosDelegate<T> infoDelegate, string displayName = null, QueryDisplayFlags queryDisplayFlags = QueryDisplayFlags.OnlyActivePaths)
{
uint pathCount, modeCount;
var err = NativeMethods.GetDisplayConfigBufferSizes(QueryDisplayFlags.OnlyActivePaths, out pathCount, out modeCount);
if (err == NativeConstants.ERROR_SUCCESS)
{
var pathsArray = new DisplayConfigPathInfo[pathCount];
var modesArray = new DisplayConfigModeInfo[modeCount];
if (queryDisplayFlags == QueryDisplayFlags.OnlyActivePaths)
{
err = NativeMethods.QueryDisplayConfig(queryDisplayFlags, ref pathCount, pathsArray, ref modeCount, modesArray, out Unsafe.NullRef<DisplayConfigTopologyId>());
}
else
{
err = NativeMethods.QueryDisplayConfig(queryDisplayFlags, ref pathCount, pathsArray, ref modeCount, modesArray, out _);
}
if (err == NativeConstants.ERROR_SUCCESS)
{
foreach (var path in pathsArray)
{
if (!MatchDisplayNames(path, displayName))
{
continue;
}
var sourceIndex = path.sourceInfo.modeInfoIdx;
var targetIndex = path.targetInfo.modeInfoIdx;
var sourceMode = modesArray[sourceIndex];
var targetMode = modesArray[targetIndex];
var result = infoDelegate(path, sourceMode, targetMode);
if (!result.Item2)
{
return result.Item1;
}
}
}
}
if (err != NativeConstants.ERROR_SUCCESS)
{
throw new Win32Exception(err);
}
return default;
}
public static void SetHDRState(bool enabled, string displayName = null)
{
ExecuteForModeConfig((modeInfo) =>
@@ -658,6 +786,8 @@ namespace ColorControl.Shared.Native
private enum DISPLAYCONFIG_DEVICE_INFO_TYPE
{
DISPLAYCONFIG_DEVICE_INFO_GET_DPI_SCALE = -3,
DISPLAYCONFIG_DEVICE_INFO_SET_DPI_SCALE = -4,
DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1,
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2,
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3,
@@ -766,19 +896,23 @@ namespace ColorControl.Shared.Native
}
[Flags]
enum DisplayConfigRotation : uint
public enum DisplayConfigRotation : uint
{
Zero = 0x0,
[Description("Landscape")]
Identity = 1,
[Description("Portrait")]
Rotate90 = 2,
[Description("Landscape (flipped)")]
Rotate180 = 3,
[Description("Portrait (flipped)")]
Rotate270 = 4,
ForceUint32 = 0xFFFFFFFF
}
[Flags]
enum DisplayConfigPixelFormat : uint
public enum DisplayConfigPixelFormat : uint
{
Zero = 0x0,
@@ -791,13 +925,17 @@ namespace ColorControl.Shared.Native
}
[Flags]
enum DisplayConfigScaling : uint
public enum DisplayConfigScaling : uint
{
Zero = 0x0,
[Description("Default")]
Identity = 1,
[Description("Centered")]
Centered = 2,
[Description("Stretched")]
Stretched = 3,
[Description("Aspect Ratio Centered Max")]
Aspectratiocenteredmax = 4,
Custom = 5,
Preferred = 128,
@@ -805,14 +943,14 @@ namespace ColorControl.Shared.Native
}
[StructLayout(LayoutKind.Sequential)]
struct DisplayConfigRational
public struct DisplayConfigRational
{
public uint numerator;
public uint denominator;
}
[Flags]
enum DisplayConfigScanLineOrdering : uint
public enum DisplayConfigScanLineOrdering : uint
{
Unspecified = 0,
Progressive = 1,
@@ -831,7 +969,7 @@ namespace ColorControl.Shared.Native
}
[Flags]
enum DisplayConfigModeInfoType : uint
public enum DisplayConfigModeInfoType : uint
{
Zero = 0,
@@ -841,7 +979,7 @@ namespace ColorControl.Shared.Native
}
[StructLayout(LayoutKind.Explicit)]
struct DisplayConfigModeInfo
public struct DisplayConfigModeInfo
{
[FieldOffset(0)]
public DisplayConfigModeInfoType infoType;
@@ -860,14 +998,14 @@ namespace ColorControl.Shared.Native
}
[StructLayout(LayoutKind.Sequential)]
struct DisplayConfig2DRegion
public struct DisplayConfig2DRegion
{
uint cx;
uint cy;
public uint cx;
public uint cy;
}
[Flags]
enum D3DmdtVideoSignalStandard : uint
public enum D3DmdtVideoSignalStandard : uint
{
Uninitialized = 0,
VesaDmt = 1,
@@ -905,7 +1043,7 @@ namespace ColorControl.Shared.Native
}
[StructLayout(LayoutKind.Sequential)]
struct DisplayConfigVideoSignalInfo
public struct DisplayConfigVideoSignalInfo
{
public long pixelRate;
public DisplayConfigRational hSyncFreq;
@@ -918,20 +1056,20 @@ namespace ColorControl.Shared.Native
}
[StructLayout(LayoutKind.Sequential)]
struct DisplayConfigTargetMode
public struct DisplayConfigTargetMode
{
public DisplayConfigVideoSignalInfo targetVideoSignalInfo;
}
[StructLayout(LayoutKind.Sequential)]
struct PointL
public struct PointL
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential)]
struct DisplayConfigSourceMode
public struct DisplayConfigSourceMode
{
public uint width;
public uint height;
@@ -1119,6 +1257,38 @@ namespace ColorControl.Shared.Native
CPST_EXTENDED_DISPLAY_COLOR_MODE
};
[StructLayout(LayoutKind.Sequential)]
private struct DISPLAYCONFIG_SOURCE_DPI_SCALE_GET
{
public DISPLAYCONFIG_DEVICE_INFO_HEADER header;
/*
* @brief min value of DPI scaling is always 100, minScaleRel gives no. of steps down from recommended scaling
* eg. if minScaleRel is -3 => 100 is 3 steps down from recommended scaling => recommended scaling is 175%
*/
public int minScaleRel;
/*
* @brief currently applied DPI scaling value wrt the recommended value. eg. if recommended value is 175%,
* => if curScaleRel == 0 the current scaling is 175%, if curScaleRel == -1, then current scale is 150%
*/
public int curScaleRel;
/*
* @brief maximum supported DPI scaling wrt recommended value
*/
public int maxScaleRel;
};
private struct DISPLAYCONFIG_SOURCE_DPI_SCALE_SET
{
public DISPLAYCONFIG_DEVICE_INFO_HEADER header;
/*
* @brief The value we want to set. The value should be relative to the recommended DPI scaling value of source.
* eg. if scaleRel == 1, and recommended value is 175% => we are trying to set 200% scaling for the source
*/
public int scaleRel;
};
enum DeviceClassFlags : UInt32
{
// from: c:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\um\Icm.h
@@ -1205,6 +1375,11 @@ namespace ColorControl.Shared.Native
public static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_GET_DISPLAY_INFO requestPacket);
[DllImport("user32")]
public static extern int DisplayConfigSetDeviceInfo(ref DISPLAYCONFIG_SET_ADVANCED_COLOR_PARAM setPacket);
[DllImport("user32")]
public static extern uint GetDpiForSystem();
[DllImport("mscms", CharSet = CharSet.Unicode)]
public static extern bool InstallColorProfileW(string machineName, string profilename);
+12 -12
View File
@@ -3799,18 +3799,18 @@ public class SafeNativeMethods
public class DXWrapper : DXNativeMethods
{
private IDXGIFactory2 @interface;
private IDXGIFactory1 @interface;
//private readonly IList<Adapter> adapters = new List<Adapter>(1);
public IEnumerable<MODE_DESC1> GetModes(string displayName, uint width = 0, uint height = 0)
{
int hr = CreateDXGIFactory2(
#if DEBUG
CREATE_FACTORY.DEBUG,
#else
CREATE_FACTORY.NONE,
#endif
typeof(IDXGIFactory4).GUID,
int hr = CreateDXGIFactory1(
//#if DEBUG
// CREATE_FACTORY.DEBUG,
//#else
// CREATE_FACTORY.NONE,
//#endif
typeof(IDXGIFactory1).GUID,
out var result);
if (Failed(hr))
@@ -3819,15 +3819,15 @@ public class DXWrapper : DXNativeMethods
}
else
{
@interface = result as IDXGIFactory4;
@interface = result as IDXGIFactory1;
}
if (@interface == null)
{
throw new NotImplementedException("IDXGIFactory4");
throw new NotImplementedException("IDXGIFactory2");
}
else
{
SetPrivateString(@interface, "Factory4");
SetPrivateString(@interface, "Factory2");
}
return GetModesFromAdapter(displayName, width, height);
@@ -3865,7 +3865,7 @@ public class DXWrapper : DXNativeMethods
continue;
}
OUTPUT_DESC outputDesc = new OUTPUT_DESC();
var outputDesc = new OUTPUT_DESC();
output1.GetDesc(out outputDesc);
if (outputDesc.DeviceName == displayName)