add name to NVIDIA/AMD presets, add CLI

This commit is contained in:
Vincent Maas committed 2021-04-18 15:15:55 +02:00
1 parent 0c877623c0
commit cac5180c76
19 files changed
+899 -306

No files matched your search

+31 -21
View File
@@ -62,13 +62,15 @@ namespace ColorControl
public static string[] GetColumnNames()
{
//return new[] { "BPC", "Format", "Dynamic range", "Toggle HDR", "Shortcut" };
return new[] { "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", "Dithering", "HDR", "Shortcut", "Apply on startup" };
}
public override List<string> GetDisplayValues(Config config = null)
{
var values = new List<string>();
values.Add(name);
var display = string.Format("{0}", primaryDisplay ? "Primary" : displayName);
values.Add(display);
@@ -100,30 +102,38 @@ namespace ColorControl
public string GetTextForMenuItem()
{
var sb = new StringBuilder();
if (displayName != null)
if (!string.IsNullOrEmpty(name))
{
sb.AppendFormat("Display: {0} / ", displayName);
}
if (applyColorData)
{
var colorSettings = string.Format("Format: {0}, {1}", colorDepth, pixelFormat);
sb.Append(colorSettings);
sb.Append(name);
sb.Append(" / ");
}
if (applyRefreshRate)
else
{
sb.AppendFormat("{0}Hz", refreshRate);
sb.Append(" / ");
}
if (applyDithering)
{
sb.AppendFormat("Dithering: {0}", ditherState);
sb.Append(" / ");
}
if (applyHDR)
{
sb.AppendFormat("HDR: {0}", toggleHDR ? "Toggle" : HDREnabled ? "Enabled" : "Disabled");
sb.Append(" / ");
if (displayName != null)
{
sb.AppendFormat("Display: {0} / ", displayName);
}
if (applyColorData)
{
var colorSettings = string.Format("Format: {0}, {1}", colorDepth, pixelFormat);
sb.Append(colorSettings);
sb.Append(" / ");
}
if (applyRefreshRate)
{
sb.AppendFormat("{0}Hz", refreshRate);
sb.Append(" / ");
}
if (applyDithering)
{
sb.AppendFormat("Dithering: {0}", ditherState);
sb.Append(" / ");
}
if (applyHDR)
{
sb.AppendFormat("HDR: {0}", toggleHDR ? "Toggle" : HDREnabled ? "Enabled" : "Disabled");
sb.Append(" / ");
}
}
return sb.ToString(0, Math.Max(0, sb.Length - 3));
+42 -10
View File
@@ -7,11 +7,11 @@ using System.Windows.Forms;
namespace ColorControl
{
class AmdService : GraphicsService
class AmdService : GraphicsService<AmdPreset>
{
private ADLDisplayInfo _currentDisplay;
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
private List<AmdPreset> _presets;
private ADLDisplayInfo _currentDisplay;
private AmdPreset _lastAppliedPreset;
@@ -20,16 +20,33 @@ namespace ColorControl
LoadPresets();
}
public List<AmdPreset> GetPresets()
{
return _presets;
}
public AmdPreset GetLastAppliedPreset()
{
return _lastAppliedPreset;
}
public static bool ExecutePresetAsync(string idOrName)
{
try
{
var service = new AmdService(Program.DataDir);
var result = service.ApplyPreset(idOrName);
if (!result)
{
Console.WriteLine("Preset not found or error while executing.");
}
return result;
}
catch (Exception ex)
{
Console.WriteLine("Error executing preset: " + ex.ToLogString());
return false;
}
}
private void LoadPresets()
{
_presetsFilename = Path.Combine(_dataPath, "AmdPresets.json");
@@ -64,7 +81,7 @@ namespace ColorControl
SavePresets();
}
public bool HasDisplaysAttached()
public override bool HasDisplaysAttached()
{
try
{
@@ -99,7 +116,20 @@ namespace ColorControl
return _currentDisplay;
}
public bool ApplyPreset(AmdPreset preset, Config config)
public bool ApplyPreset(string idOrName)
{
var preset = GetPresetByIdOrName(idOrName);
if (preset != null)
{
return ApplyPreset(preset, Program.AppContext);
}
else
{
return false;
}
}
public bool ApplyPreset(AmdPreset preset, AppContext appContext)
{
SetCurrentDisplay(preset);
@@ -295,6 +325,8 @@ namespace ColorControl
{
var values = new List<string>();
values.Add("Current settings");
var screen = GetScreenForDisplay(display);
var name = GetFullDisplayName(display);
+15
View File
@@ -0,0 +1,15 @@
namespace ColorControl
{
public class AppContext
{
public Config Config { get; private set; }
public StartUpParams StartUpParams { get; private set; }
public AppContext(Config config, StartUpParams startUpParams)
{
Config = config;
StartUpParams = startUpParams;
}
}
}
+2 -1
View File
@@ -27,7 +27,7 @@
<ProductName>ColorControl</ProductName>
<PublisherName>Maassoft</PublisherName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>2.0.0.0</ApplicationVersion>
<ApplicationVersion>2.2.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
@@ -176,6 +176,7 @@
<Compile Include="ADL.cs" />
<Compile Include="ADLWrapper.cs" />
<Compile Include="AmdDisplayInfo.cs" />
<Compile Include="AppContext.cs" />
<Compile Include="UserSessionInfo.cs" />
<Compile Include="ServiceBase.cs" />
<Compile Include="NvDisplayInfo.cs" />
+1 -1
View File
@@ -1,6 +1,6 @@
namespace ColorControl
{
class Config
public class Config
{
public bool StartMinimized { get; set; }
+5 -7
View File
@@ -9,13 +9,9 @@ using System.Threading;
namespace ColorControl
{
class GraphicsService : ServiceBase
abstract class GraphicsService<T> : ServiceBase<T> where T : PresetBase
{
[DllImport("user32.dll")]
public static extern bool EnumDisplaySettingsA(string deviceName, int modeNum, out DEVMODEA devMode);
const int ENUM_CURRENT_SETTINGS = -1;
const int ENUM_REGISTRY_SETTINGS = -2;
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
public GraphicsService(string dataPath) : base(dataPath)
{
@@ -27,6 +23,8 @@ namespace ColorControl
Uninitialize();
}
public abstract bool HasDisplaysAttached();
protected void ToggleHDR(int delay = 1000)
{
Process.Start("ms-settings:display");
@@ -103,7 +101,7 @@ namespace ColorControl
{
DEVMODEA devMode;
// NativeMethods defines modeNum as an 'uint' but we need to pass '-1'
if (EnumDisplaySettingsA(displayName, ENUM_CURRENT_SETTINGS, out devMode))
if (Utils.EnumDisplaySettingsA(displayName, Utils.ENUM_CURRENT_SETTINGS, out devMode))
{
return devMode.dmDisplayFrequency;
}
-1
View File
@@ -6,7 +6,6 @@ namespace ColorControl
{
class LgPreset : PresetBase
{
public string name { get; set; }
public string appId { get; set; }
public List<string> steps { get; set; }
+148 -88
View File
@@ -9,16 +9,17 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace ColorControl
{
class LgService
class LgService : ServiceBase<LgPreset>
{
protected static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
public static string LgListAppsJson = "listApps.json";
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
//private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
//public string FriendlyScreenName { get; private set; }
@@ -35,11 +36,7 @@ namespace ColorControl
public LgServiceConfig Config { get; private set; }
private List<LgPreset> _lgPresets;
private string _lgPresetsFilename;
private LgTvApi _lgTvApi;
private string _dataDir;
private string _configFilename;
private bool _allowPowerOn;
private bool _justWokeUp;
@@ -48,9 +45,6 @@ namespace ColorControl
private List<LgPreset> _remoteControlButtons;
private List<LgApp> _lgApps = new List<LgApp>();
private JavaScriptSerializer _JsonSerializer = new JavaScriptSerializer();
private JavaScriptSerializer _JsonDeserializer = new JavaScriptSerializer();
private Dictionary<string, Func<bool>> _invokableActions = new Dictionary<string, Func<bool>>();
private bool _poweredOffByScreenSaver;
@@ -58,9 +52,8 @@ namespace ColorControl
private Task _monitorTask;
private int _monitorTaskCounter;
public LgService(string dataDir, bool allowPowerOn)
public LgService(string dataPath, bool allowPowerOn) : base(dataPath)
{
_dataDir = dataDir;
_allowPowerOn = allowPowerOn;
_invokableActions.Add("WOL", new Func<bool>(WakeSelectedDevice));
@@ -79,8 +72,6 @@ namespace ColorControl
// FriendlyScreenName = name;
// }
//}
var _ = RefreshDevices(afterStartUp: true);
}
~LgService()
@@ -88,6 +79,29 @@ namespace ColorControl
GlobalSave();
}
public static async Task<bool> ExecutePresetAsync(string presetName)
{
try
{
var lgService = new LgService(Program.DataDir, true);
await lgService.RefreshDevices(afterStartUp: true);
var result = await lgService.ApplyPreset(presetName);
if (!result)
{
Console.WriteLine("Preset not found or error while executing.");
}
return result;
}
catch (Exception ex)
{
Console.WriteLine("Error executing preset: " + ex.ToLogString());
return false;
}
}
public void GlobalSave()
{
SaveConfig();
@@ -95,11 +109,6 @@ namespace ColorControl
SaveRemoteControlButtons();
}
public List<LgPreset> GetPresets()
{
return _lgPresets;
}
public LgPreset CreateNewPreset()
{
var preset = new LgPreset();
@@ -110,7 +119,7 @@ namespace ColorControl
{
fullname = $"{name} ({number})";
number++;
} while (_lgPresets.Any(x => x.name.Equals(fullname)));
} while (_presets.Any(x => x.name.Equals(fullname)));
preset.name = fullname;
@@ -119,35 +128,35 @@ namespace ColorControl
private void LoadPresets()
{
_lgPresetsFilename = Path.Combine(_dataDir, "LgPresets.json");
_presetsFilename = Path.Combine(_dataPath, "LgPresets.json");
var toCopy = Path.Combine(Directory.GetCurrentDirectory(), "LgPresets.json");
if (!File.Exists(_lgPresetsFilename) && File.Exists(toCopy))
if (!File.Exists(_presetsFilename) && File.Exists(toCopy))
{
try
{
File.Copy(toCopy, _lgPresetsFilename);
File.Copy(toCopy, _presetsFilename);
}
catch (Exception e)
{
Logger.Error($"Error while copying {toCopy} to {_lgPresetsFilename}: {e.Message}");
Logger.Error($"Error while copying {toCopy} to {_presetsFilename}: {e.Message}");
}
}
if (File.Exists(_lgPresetsFilename))
if (File.Exists(_presetsFilename))
{
var json = File.ReadAllText(_lgPresetsFilename);
var json = File.ReadAllText(_presetsFilename);
_lgPresets = _JsonDeserializer.Deserialize<List<LgPreset>>(json);
_presets = _JsonSerializer.Deserialize<List<LgPreset>>(json);
}
else
{
_lgPresets = new List<LgPreset>();
_presets = new List<LgPreset>();
}
}
private void LoadConfig()
{
_configFilename = Path.Combine(_dataDir, "LgConfig.json");
_configFilename = Path.Combine(_dataPath, "LgConfig.json");
if (File.Exists(_configFilename))
{
Config = JsonConvert.DeserializeObject<LgServiceConfig>(File.ReadAllText(_configFilename));
@@ -162,7 +171,7 @@ namespace ColorControl
{
var defaultButtons = GenerateDefaultRemoteControlButtons();
_rcButtonsFilename = Path.Combine(_dataDir, "LgRemoteControlButtons.json");
_rcButtonsFilename = Path.Combine(_dataPath, "LgRemoteControlButtons.json");
//if (File.Exists(_rcButtonsFilename))
//{
// var json = File.ReadAllText(_rcButtonsFilename);
@@ -238,8 +247,8 @@ namespace ColorControl
{
try
{
var json = _JsonSerializer.Serialize(_lgPresets);
File.WriteAllText(_lgPresetsFilename, json);
var json = _JsonSerializer.Serialize(_presets);
File.WriteAllText(_presetsFilename, json);
}
catch (Exception e)
{
@@ -342,6 +351,19 @@ namespace ColorControl
return !_lgTvApi?.ConnectionClosed ?? false;
}
public async Task<bool> ApplyPreset(string presetName)
{
var preset = _presets.FirstOrDefault(p => p.name.Equals(presetName, StringComparison.OrdinalIgnoreCase));
if (preset != null)
{
return await ApplyPreset(preset);
}
else
{
return false;
}
}
public async Task<bool> ApplyPreset(LgPreset preset, bool reconnect = false)
{
var hasApp = !string.IsNullOrEmpty(preset.appId);
@@ -504,6 +526,25 @@ namespace ColorControl
return true;
}
internal async Task<bool> TestConnection()
{
if (!await Connected(true))
{
return false;
}
try
{
await _lgTvApi.IsMuted();
return true;
}
catch (Exception ex)
{
Logger.Error("TestConnection: " + ex.ToLogString());
return false;
}
}
internal bool WakeSelectedDevice()
{
return WakeSelectedDevice(SelectedDevice?.MacAddress ?? Config.PreferredMacAddress);
@@ -691,79 +732,98 @@ namespace ColorControl
var wasConnected = IsConnected();
_monitorTaskCounter++;
var validCounter = _monitorTaskCounter;
var lastProcessId = 0;
while (Config.PowerSwitchOnScreenSaver && validCounter == _monitorTaskCounter)
{
await Task.Delay(500);
if (_poweredOffByScreenSaver && !UserSessionInfo.UserLocalSession)
try
{
continue;
}
var processes = Process.GetProcesses();
if (_poweredOffByScreenSaver)
{
if (processes.Any(p => p.Id == _poweredOffByScreenSaverProcessId))
if (_poweredOffByScreenSaver && !UserSessionInfo.UserLocalSession)
{
continue;
}
Logger.Debug("Screensaver stopped, waking");
_poweredOffByScreenSaver = false;
_poweredOffByScreenSaverProcessId = 0;
var _ = WakeAndConnectToSelectedDeviceWithRetries();
var processes = Process.GetProcesses();
continue;
}
if (!IsConnected())
{
if (wasConnected)
if (_poweredOffByScreenSaver)
{
Logger.Debug("TV was connected, but not any longer");
wasConnected = false;
}
continue;
}
if (!wasConnected)
{
Logger.Debug("TV was not connected, but connection has now been established");
wasConnected = true;
}
foreach (var process in processes)
{
var name = process.ProcessName.ToLowerInvariant();
if (name.EndsWith(".scr"))
{
var parent = process.Parent();
if (parent?.ProcessName.Contains("winlogon") ?? false)
if (processes.Any(p => p.Id == _poweredOffByScreenSaverProcessId))
{
Logger.Debug($"Screensaver started: {process.ProcessName}, parent: {parent.ProcessName}");
try
{
Logger.Debug("Powering off tv because of screensaver");
_poweredOffByScreenSaver = await PowerOff();
_poweredOffByScreenSaverProcessId = process.Id;
}
catch (Exception e)
{
Logger.Error("CheckProcesses: can't power off: " + e.ToLogString());
}
if (!IsConnected())
{
_poweredOffByScreenSaver = false;
}
break;
continue;
}
else
Logger.Debug("Screensaver stopped, waking");
_poweredOffByScreenSaver = false;
_poweredOffByScreenSaverProcessId = 0;
lastProcessId = 0;
var _ = WakeAndConnectToSelectedDeviceWithRetries();
continue;
}
if (!IsConnected())
{
if (wasConnected)
{
Logger.Debug($"Screensaver started: {process.ProcessName}, but invalid parent: {parent?.ProcessName ?? "no parent"}");
Logger.Debug("TV was connected, but not any longer");
wasConnected = false;
}
continue;
}
if (!wasConnected)
{
Logger.Debug("TV was not connected, but connection has now been established");
wasConnected = true;
}
foreach (var process in processes)
{
var name = process.ProcessName.ToLowerInvariant();
if (name.EndsWith(".scr"))
{
var parent = process.Parent();
if (parent?.ProcessName.Contains("winlogon") ?? false)
{
Logger.Debug($"Screensaver started: {process.ProcessName}, parent: {parent.ProcessName}");
try
{
Logger.Debug("Test connection...");
var test = await TestConnection();
Logger.Debug("Test connection result: " + test);
Logger.Debug("Powering off tv because of screensaver");
_poweredOffByScreenSaver = await PowerOff();
_poweredOffByScreenSaverProcessId = process.Id;
lastProcessId = 0;
}
catch (Exception e)
{
Logger.Error("CheckProcesses: can't power off: " + e.ToLogString());
}
if (!IsConnected())
{
_poweredOffByScreenSaver = false;
}
break;
}
else
{
if (process.Id != lastProcessId)
{
Logger.Debug($"Screensaver started: {process.ProcessName}, but invalid parent: {parent?.ProcessName ?? "no parent"}");
lastProcessId = process.Id;
}
}
}
}
}
catch (Exception ex)
{
Logger.Error("CheckProcesses: " + ex.ToLogString());
}
}
}
}
+134 -64
View File
@@ -32,11 +32,13 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.tcMain = new System.Windows.Forms.TabControl();
this.tabNVIDIA = new System.Windows.Forms.TabPage();
this.lblNvPresetName = new System.Windows.Forms.Label();
this.edtNvPresetName = new System.Windows.Forms.TextBox();
this.btnAddModesNv = new System.Windows.Forms.Button();
this.btnNvPresetDelete = new System.Windows.Forms.Button();
this.lblError = new System.Windows.Forms.Label();
this.btnClone = new System.Windows.Forms.Button();
this.btnSetShortcut = new System.Windows.Forms.Button();
this.btnNvPresetSave = new System.Windows.Forms.Button();
this.lblShortcut = new System.Windows.Forms.Label();
this.edtShortcut = new System.Windows.Forms.TextBox();
this.btnChange = new System.Windows.Forms.Button();
@@ -67,14 +69,17 @@
this.miHDRIncluded = new System.Windows.Forms.ToolStripMenuItem();
this.miToggleHDR = new System.Windows.Forms.ToolStripMenuItem();
this.miHDREnabled = new System.Windows.Forms.ToolStripMenuItem();
this.miNvCopyId = new System.Windows.Forms.ToolStripMenuItem();
this.btnApply = new System.Windows.Forms.Button();
this.lvNvPresets = new System.Windows.Forms.ListView();
this.tabAMD = new System.Windows.Forms.TabPage();
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.btnSetAmdShortcut = 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();
@@ -163,6 +168,7 @@
this.lbPlugins = new System.Windows.Forms.ListBox();
this.label7 = new System.Windows.Forms.Label();
this.lblInfo = new System.Windows.Forms.Label();
this.miAmdCopyId = new System.Windows.Forms.ToolStripMenuItem();
this.tcMain.SuspendLayout();
this.tabNVIDIA.SuspendLayout();
this.mnuNvPresets.SuspendLayout();
@@ -205,11 +211,13 @@
//
// tabNVIDIA
//
this.tabNVIDIA.Controls.Add(this.lblNvPresetName);
this.tabNVIDIA.Controls.Add(this.edtNvPresetName);
this.tabNVIDIA.Controls.Add(this.btnAddModesNv);
this.tabNVIDIA.Controls.Add(this.btnNvPresetDelete);
this.tabNVIDIA.Controls.Add(this.lblError);
this.tabNVIDIA.Controls.Add(this.btnClone);
this.tabNVIDIA.Controls.Add(this.btnSetShortcut);
this.tabNVIDIA.Controls.Add(this.btnNvPresetSave);
this.tabNVIDIA.Controls.Add(this.lblShortcut);
this.tabNVIDIA.Controls.Add(this.edtShortcut);
this.tabNVIDIA.Controls.Add(this.btnChange);
@@ -223,10 +231,29 @@
this.tabNVIDIA.Text = "NVIDIA controller";
this.tabNVIDIA.UseVisualStyleBackColor = true;
//
// lblNvPresetName
//
this.lblNvPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblNvPresetName.AutoSize = true;
this.lblNvPresetName.Location = new System.Drawing.Point(6, 397);
this.lblNvPresetName.Name = "lblNvPresetName";
this.lblNvPresetName.Size = new System.Drawing.Size(38, 13);
this.lblNvPresetName.TabIndex = 22;
this.lblNvPresetName.Text = "Name:";
//
// edtNvPresetName
//
this.edtNvPresetName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.edtNvPresetName.Enabled = false;
this.edtNvPresetName.Location = new System.Drawing.Point(87, 394);
this.edtNvPresetName.Name = "edtNvPresetName";
this.edtNvPresetName.Size = new System.Drawing.Size(200, 20);
this.edtNvPresetName.TabIndex = 21;
//
// btnAddModesNv
//
this.btnAddModesNv.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnAddModesNv.Location = new System.Drawing.Point(574, 417);
this.btnAddModesNv.Location = new System.Drawing.Point(330, 365);
this.btnAddModesNv.Name = "btnAddModesNv";
this.btnAddModesNv.Size = new System.Drawing.Size(75, 23);
this.btnAddModesNv.TabIndex = 9;
@@ -238,7 +265,7 @@
//
this.btnNvPresetDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnNvPresetDelete.Enabled = false;
this.btnNvPresetDelete.Location = new System.Drawing.Point(493, 417);
this.btnNvPresetDelete.Location = new System.Drawing.Point(249, 365);
this.btnNvPresetDelete.Name = "btnNvPresetDelete";
this.btnNvPresetDelete.Size = new System.Drawing.Size(75, 23);
this.btnNvPresetDelete.TabIndex = 8;
@@ -260,7 +287,7 @@
//
this.btnClone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnClone.Enabled = false;
this.btnClone.Location = new System.Drawing.Point(412, 417);
this.btnClone.Location = new System.Drawing.Point(168, 365);
this.btnClone.Name = "btnClone";
this.btnClone.Size = new System.Drawing.Size(75, 23);
this.btnClone.TabIndex = 6;
@@ -268,23 +295,23 @@
this.btnClone.UseVisualStyleBackColor = true;
this.btnClone.Click += new System.EventHandler(this.btnClone_Click);
//
// btnSetShortcut
// btnNvPresetSave
//
this.btnSetShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnSetShortcut.Enabled = false;
this.btnSetShortcut.Location = new System.Drawing.Point(372, 417);
this.btnSetShortcut.Name = "btnSetShortcut";
this.btnSetShortcut.Size = new System.Drawing.Size(34, 23);
this.btnSetShortcut.TabIndex = 5;
this.btnSetShortcut.Text = "Set";
this.btnSetShortcut.UseVisualStyleBackColor = true;
this.btnSetShortcut.Click += new System.EventHandler(this.btnSetShortcut_Click);
this.btnNvPresetSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnNvPresetSave.Enabled = false;
this.btnNvPresetSave.Location = new System.Drawing.Point(411, 365);
this.btnNvPresetSave.Name = "btnNvPresetSave";
this.btnNvPresetSave.Size = new System.Drawing.Size(75, 23);
this.btnNvPresetSave.TabIndex = 5;
this.btnNvPresetSave.Text = "Save";
this.btnNvPresetSave.UseVisualStyleBackColor = true;
this.btnNvPresetSave.Click += new System.EventHandler(this.btnSetShortcut_Click);
//
// lblShortcut
//
this.lblShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblShortcut.AutoSize = true;
this.lblShortcut.Location = new System.Drawing.Point(168, 422);
this.lblShortcut.Location = new System.Drawing.Point(6, 423);
this.lblShortcut.Name = "lblShortcut";
this.lblShortcut.Size = new System.Drawing.Size(50, 13);
this.lblShortcut.TabIndex = 4;
@@ -294,10 +321,10 @@
//
this.edtShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.edtShortcut.Enabled = false;
this.edtShortcut.Location = new System.Drawing.Point(224, 419);
this.edtShortcut.Location = new System.Drawing.Point(87, 420);
this.edtShortcut.Name = "edtShortcut";
this.edtShortcut.ReadOnly = true;
this.edtShortcut.Size = new System.Drawing.Size(142, 20);
this.edtShortcut.Size = new System.Drawing.Size(200, 20);
this.edtShortcut.TabIndex = 3;
this.edtShortcut.TextChanged += new System.EventHandler(this.edtShortcut_TextChanged);
this.edtShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown);
@@ -308,7 +335,7 @@
this.btnChange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnChange.ContextMenuStrip = this.mnuNvPresets;
this.btnChange.Enabled = false;
this.btnChange.Location = new System.Drawing.Point(87, 417);
this.btnChange.Location = new System.Drawing.Point(87, 365);
this.btnChange.Name = "btnChange";
this.btnChange.Size = new System.Drawing.Size(75, 23);
this.btnChange.TabIndex = 2;
@@ -327,15 +354,16 @@
this.mnuNvPresetsColorSettings,
this.mnuRefreshRate,
this.miNvPresetDithering,
this.miNvHDR});
this.miNvHDR,
this.miNvCopyId});
this.mnuNvPresets.Name = "mnuNvPresets";
this.mnuNvPresets.Size = new System.Drawing.Size(163, 164);
this.mnuNvPresets.Size = new System.Drawing.Size(185, 186);
this.mnuNvPresets.Opening += new System.ComponentModel.CancelEventHandler(this.mnuNvPresets_Opening);
//
// miNvApply
//
this.miNvApply.Name = "miNvApply";
this.miNvApply.Size = new System.Drawing.Size(162, 22);
this.miNvApply.Size = new System.Drawing.Size(184, 22);
this.miNvApply.Text = "Apply";
this.miNvApply.Click += new System.EventHandler(this.btnApply_Click);
//
@@ -343,21 +371,21 @@
//
this.miNvPresetApplyOnStartup.CheckOnClick = true;
this.miNvPresetApplyOnStartup.Name = "miNvPresetApplyOnStartup";
this.miNvPresetApplyOnStartup.Size = new System.Drawing.Size(162, 22);
this.miNvPresetApplyOnStartup.Size = new System.Drawing.Size(184, 22);
this.miNvPresetApplyOnStartup.Text = "Apply on startup";
this.miNvPresetApplyOnStartup.Click += new System.EventHandler(this.miNvPresetApplyOnStartup_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(159, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(181, 6);
//
// mnuNvDisplay
//
this.mnuNvDisplay.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miNvPrimaryDisplay});
this.mnuNvDisplay.Name = "mnuNvDisplay";
this.mnuNvDisplay.Size = new System.Drawing.Size(162, 22);
this.mnuNvDisplay.Size = new System.Drawing.Size(184, 22);
this.mnuNvDisplay.Text = "Display";
//
// miNvPrimaryDisplay
@@ -372,7 +400,7 @@
this.mnuNvPresetsColorSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miNvPresetColorSettings});
this.mnuNvPresetsColorSettings.Name = "mnuNvPresetsColorSettings";
this.mnuNvPresetsColorSettings.Size = new System.Drawing.Size(162, 22);
this.mnuNvPresetsColorSettings.Size = new System.Drawing.Size(184, 22);
this.mnuNvPresetsColorSettings.Text = "Color settings";
//
// miNvPresetColorSettings
@@ -387,7 +415,7 @@
this.mnuRefreshRate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miRefreshRateIncluded});
this.mnuRefreshRate.Name = "mnuRefreshRate";
this.mnuRefreshRate.Size = new System.Drawing.Size(162, 22);
this.mnuRefreshRate.Size = new System.Drawing.Size(184, 22);
this.mnuRefreshRate.Text = "Refresh Rate";
//
// miRefreshRateIncluded
@@ -405,7 +433,7 @@
this.mnuNvDitheringBitDepth,
this.mnuNvDitheringMode});
this.miNvPresetDithering.Name = "miNvPresetDithering";
this.miNvPresetDithering.Size = new System.Drawing.Size(162, 22);
this.miNvPresetDithering.Size = new System.Drawing.Size(184, 22);
this.miNvPresetDithering.Text = "Dithering";
//
// miNvPresetApplyDithering
@@ -515,7 +543,7 @@
this.miToggleHDR,
this.miHDREnabled});
this.miNvHDR.Name = "miNvHDR";
this.miNvHDR.Size = new System.Drawing.Size(162, 22);
this.miNvHDR.Size = new System.Drawing.Size(184, 22);
this.miNvHDR.Text = "HDR";
//
// miHDRIncluded
@@ -539,11 +567,18 @@
this.miHDREnabled.Text = "Enabled";
this.miHDREnabled.Click += new System.EventHandler(this.miHDREnabled_Click);
//
// miNvCopyId
//
this.miNvCopyId.Name = "miNvCopyId";
this.miNvCopyId.Size = new System.Drawing.Size(184, 22);
this.miNvCopyId.Text = "Copy Id to Clipboard";
this.miNvCopyId.Click += new System.EventHandler(this.miNvCopyId_Click);
//
// btnApply
//
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnApply.Enabled = false;
this.btnApply.Location = new System.Drawing.Point(6, 417);
this.btnApply.Location = new System.Drawing.Point(6, 365);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(75, 23);
this.btnApply.TabIndex = 1;
@@ -562,7 +597,7 @@
this.lvNvPresets.Location = new System.Drawing.Point(6, 6);
this.lvNvPresets.MultiSelect = false;
this.lvNvPresets.Name = "lvNvPresets";
this.lvNvPresets.Size = new System.Drawing.Size(829, 405);
this.lvNvPresets.Size = new System.Drawing.Size(829, 353);
this.lvNvPresets.TabIndex = 0;
this.lvNvPresets.UseCompatibleStateImageBehavior = false;
this.lvNvPresets.View = System.Windows.Forms.View.Details;
@@ -571,11 +606,13 @@
//
// tabAMD
//
this.tabAMD.Controls.Add(this.lblAmdPresetName);
this.tabAMD.Controls.Add(this.edtAmdPresetName);
this.tabAMD.Controls.Add(this.btnAddAmd);
this.tabAMD.Controls.Add(this.lblErrorAMD);
this.tabAMD.Controls.Add(this.btnDeleteAmd);
this.tabAMD.Controls.Add(this.btnCloneAmd);
this.tabAMD.Controls.Add(this.btnSetAmdShortcut);
this.tabAMD.Controls.Add(this.btnAmdPresetSave);
this.tabAMD.Controls.Add(this.lblAmdShortcut);
this.tabAMD.Controls.Add(this.edtAmdShortcut);
this.tabAMD.Controls.Add(this.btnChangeAmd);
@@ -589,10 +626,29 @@
this.tabAMD.Text = "AMD controller";
this.tabAMD.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(6, 397);
this.lblAmdPresetName.Name = "lblAmdPresetName";
this.lblAmdPresetName.Size = new System.Drawing.Size(38, 13);
this.lblAmdPresetName.TabIndex = 24;
this.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(87, 394);
this.edtAmdPresetName.Name = "edtAmdPresetName";
this.edtAmdPresetName.Size = new System.Drawing.Size(200, 20);
this.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(574, 417);
this.btnAddAmd.Location = new System.Drawing.Point(330, 365);
this.btnAddAmd.Name = "btnAddAmd";
this.btnAddAmd.Size = new System.Drawing.Size(75, 23);
this.btnAddAmd.TabIndex = 18;
@@ -614,7 +670,7 @@
//
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(493, 417);
this.btnDeleteAmd.Location = new System.Drawing.Point(249, 365);
this.btnDeleteAmd.Name = "btnDeleteAmd";
this.btnDeleteAmd.Size = new System.Drawing.Size(75, 23);
this.btnDeleteAmd.TabIndex = 17;
@@ -626,7 +682,7 @@
//
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(412, 417);
this.btnCloneAmd.Location = new System.Drawing.Point(168, 365);
this.btnCloneAmd.Name = "btnCloneAmd";
this.btnCloneAmd.Size = new System.Drawing.Size(75, 23);
this.btnCloneAmd.TabIndex = 16;
@@ -634,23 +690,23 @@
this.btnCloneAmd.UseVisualStyleBackColor = true;
this.btnCloneAmd.Click += new System.EventHandler(this.btnCloneAmd_Click);
//
// btnSetAmdShortcut
// btnAmdPresetSave
//
this.btnSetAmdShortcut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnSetAmdShortcut.Enabled = false;
this.btnSetAmdShortcut.Location = new System.Drawing.Point(372, 417);
this.btnSetAmdShortcut.Name = "btnSetAmdShortcut";
this.btnSetAmdShortcut.Size = new System.Drawing.Size(34, 23);
this.btnSetAmdShortcut.TabIndex = 15;
this.btnSetAmdShortcut.Text = "Set";
this.btnSetAmdShortcut.UseVisualStyleBackColor = true;
this.btnSetAmdShortcut.Click += new System.EventHandler(this.btnSetAmdShortcut_Click);
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(411, 365);
this.btnAmdPresetSave.Name = "btnAmdPresetSave";
this.btnAmdPresetSave.Size = new System.Drawing.Size(75, 23);
this.btnAmdPresetSave.TabIndex = 15;
this.btnAmdPresetSave.Text = "Save";
this.btnAmdPresetSave.UseVisualStyleBackColor = true;
this.btnAmdPresetSave.Click += new System.EventHandler(this.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(168, 422);
this.lblAmdShortcut.Location = new System.Drawing.Point(6, 423);
this.lblAmdShortcut.Name = "lblAmdShortcut";
this.lblAmdShortcut.Size = new System.Drawing.Size(50, 13);
this.lblAmdShortcut.TabIndex = 14;
@@ -660,10 +716,10 @@
//
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(224, 419);
this.edtAmdShortcut.Location = new System.Drawing.Point(87, 420);
this.edtAmdShortcut.Name = "edtAmdShortcut";
this.edtAmdShortcut.ReadOnly = true;
this.edtAmdShortcut.Size = new System.Drawing.Size(142, 20);
this.edtAmdShortcut.Size = new System.Drawing.Size(200, 20);
this.edtAmdShortcut.TabIndex = 13;
this.edtAmdShortcut.TextChanged += new System.EventHandler(this.edtAmdShortcut_TextChanged);
this.edtAmdShortcut.KeyDown += new System.Windows.Forms.KeyEventHandler(this.edtShortcut_KeyDown);
@@ -674,7 +730,7 @@
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(87, 417);
this.btnChangeAmd.Location = new System.Drawing.Point(87, 365);
this.btnChangeAmd.Name = "btnChangeAmd";
this.btnChangeAmd.Size = new System.Drawing.Size(75, 23);
this.btnChangeAmd.TabIndex = 12;
@@ -693,15 +749,16 @@
this.mnuAmdColorSettings,
this.mnuAmdRefreshRate,
this.mnuAmdDithering,
this.mnuAmdHDR});
this.mnuAmdHDR,
this.miAmdCopyId});
this.mnuAmdPresets.Name = "mnuNvPresets";
this.mnuAmdPresets.Size = new System.Drawing.Size(163, 164);
this.mnuAmdPresets.Size = new System.Drawing.Size(185, 208);
this.mnuAmdPresets.Opening += new System.ComponentModel.CancelEventHandler(this.mnuAmdPresets_Opening);
//
// miAmdApply
//
this.miAmdApply.Name = "miAmdApply";
this.miAmdApply.Size = new System.Drawing.Size(162, 22);
this.miAmdApply.Size = new System.Drawing.Size(184, 22);
this.miAmdApply.Text = "Apply";
this.miAmdApply.Click += new System.EventHandler(this.btnApplyAmd_Click);
//
@@ -709,21 +766,21 @@
//
this.miAmdPresetApplyOnStartup.CheckOnClick = true;
this.miAmdPresetApplyOnStartup.Name = "miAmdPresetApplyOnStartup";
this.miAmdPresetApplyOnStartup.Size = new System.Drawing.Size(162, 22);
this.miAmdPresetApplyOnStartup.Size = new System.Drawing.Size(184, 22);
this.miAmdPresetApplyOnStartup.Text = "Apply on startup";
this.miAmdPresetApplyOnStartup.Click += new System.EventHandler(this.miAmdPresetApplyOnStartup_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(159, 6);
this.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(162, 22);
this.mnuAmdDisplay.Size = new System.Drawing.Size(184, 22);
this.mnuAmdDisplay.Text = "Display";
//
// miAmdPrimaryDisplay
@@ -738,7 +795,7 @@
this.mnuAmdColorSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdColorSettingsIncluded});
this.mnuAmdColorSettings.Name = "mnuAmdColorSettings";
this.mnuAmdColorSettings.Size = new System.Drawing.Size(162, 22);
this.mnuAmdColorSettings.Size = new System.Drawing.Size(184, 22);
this.mnuAmdColorSettings.Text = "Color settings";
//
// miAmdColorSettingsIncluded
@@ -753,7 +810,7 @@
this.mnuAmdRefreshRate.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdRefreshRateIncluded});
this.mnuAmdRefreshRate.Name = "mnuAmdRefreshRate";
this.mnuAmdRefreshRate.Size = new System.Drawing.Size(162, 22);
this.mnuAmdRefreshRate.Size = new System.Drawing.Size(184, 22);
this.mnuAmdRefreshRate.Text = "Refresh Rate";
//
// miAmdRefreshRateIncluded
@@ -768,7 +825,7 @@
this.mnuAmdDithering.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.miAmdDitheringIncluded});
this.mnuAmdDithering.Name = "mnuAmdDithering";
this.mnuAmdDithering.Size = new System.Drawing.Size(162, 22);
this.mnuAmdDithering.Size = new System.Drawing.Size(184, 22);
this.mnuAmdDithering.Text = "Dithering";
//
// miAmdDitheringIncluded
@@ -785,7 +842,7 @@
this.miAmdHDRToggle,
this.miAmdHDREnabled});
this.mnuAmdHDR.Name = "mnuAmdHDR";
this.mnuAmdHDR.Size = new System.Drawing.Size(162, 22);
this.mnuAmdHDR.Size = new System.Drawing.Size(184, 22);
this.mnuAmdHDR.Text = "HDR";
//
// miAmdHDRIncluded
@@ -813,7 +870,7 @@
//
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(6, 417);
this.btnApplyAmd.Location = new System.Drawing.Point(6, 365);
this.btnApplyAmd.Name = "btnApplyAmd";
this.btnApplyAmd.Size = new System.Drawing.Size(75, 23);
this.btnApplyAmd.TabIndex = 11;
@@ -832,7 +889,7 @@
this.lvAmdPresets.Location = new System.Drawing.Point(6, 6);
this.lvAmdPresets.MultiSelect = false;
this.lvAmdPresets.Name = "lvAmdPresets";
this.lvAmdPresets.Size = new System.Drawing.Size(829, 405);
this.lvAmdPresets.Size = new System.Drawing.Size(829, 353);
this.lvAmdPresets.TabIndex = 10;
this.lvAmdPresets.UseCompatibleStateImageBehavior = false;
this.lvAmdPresets.View = System.Windows.Forms.View.Details;
@@ -1612,6 +1669,13 @@
this.lblInfo.TabIndex = 1;
this.lblInfo.Text = "Info";
//
// 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);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -1670,7 +1734,7 @@
private System.Windows.Forms.ListView lvNvPresets;
private System.Windows.Forms.Button btnApply;
private System.Windows.Forms.Button btnChange;
private System.Windows.Forms.Button btnSetShortcut;
private System.Windows.Forms.Button btnNvPresetSave;
private System.Windows.Forms.Label lblShortcut;
private System.Windows.Forms.TextBox edtShortcut;
private System.Windows.Forms.TabPage tabOptions;
@@ -1774,7 +1838,7 @@
private System.Windows.Forms.ToolStripMenuItem mnuLgActions;
private System.Windows.Forms.Button btnDeleteAmd;
private System.Windows.Forms.Button btnCloneAmd;
private System.Windows.Forms.Button btnSetAmdShortcut;
private System.Windows.Forms.Button btnAmdPresetSave;
private System.Windows.Forms.Label lblAmdShortcut;
private System.Windows.Forms.TextBox edtAmdShortcut;
private System.Windows.Forms.Button btnChangeAmd;
@@ -1798,6 +1862,12 @@
private System.Windows.Forms.ListView lvAmdPresets;
private System.Windows.Forms.Button btnAddAmd;
private System.Windows.Forms.CheckBox chkMinimizeToSystemTray;
private System.Windows.Forms.ToolStripMenuItem miNvCopyId;
private System.Windows.Forms.Label lblNvPresetName;
private System.Windows.Forms.TextBox edtNvPresetName;
private System.Windows.Forms.Label lblAmdPresetName;
private System.Windows.Forms.TextBox edtAmdPresetName;
private System.Windows.Forms.ToolStripMenuItem miAmdCopyId;
}
}
+122 -49
View File
@@ -16,7 +16,6 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
namespace ColorControl
@@ -34,13 +33,10 @@ namespace ColorControl
private string _dataDir;
private NvService _nvService;
private JavaScriptSerializer _JsonSerializer = new JavaScriptSerializer();
private JavaScriptSerializer _JsonDeserializer = new JavaScriptSerializer();
private string _lastDisplayRefreshRates = string.Empty;
private NotifyIcon _trayIcon;
private bool _initialized = false;
private string _configFilename;
private Config _config;
private bool _setVisibleCalled = false;
private RestartDetector _restartDetector;
@@ -49,33 +45,34 @@ namespace ColorControl
private RemoteControlForm _remoteControlForm;
private MenuItem _nvTrayMenu;
private MenuItem _amdTrayMenu;
private MenuItem _lgTrayMenu;
private StartUpParams StartUpParams { get; }
private AmdService _amdService;
public MainForm(StartUpParams startUpParams)
public MainForm(AppContext appContext)
{
InitializeComponent();
StartUpParams = startUpParams;
StartUpParams = appContext.StartUpParams;
_dataDir = Utils.GetDataPath();
_dataDir = Program.DataDir;
_config = Program.Config;
InitLogger();
_configFilename = Path.Combine(_dataDir, "Settings.json");
LoadConfig();
MessageForms.MainForm = this;
_nvTrayMenu = new MenuItem("NVIDIA presets");
_amdTrayMenu = new MenuItem("NVIDIA presets");
_lgTrayMenu = new MenuItem("LG presets");
_trayIcon = new NotifyIcon()
{
Icon = Icon,
ContextMenu = new ContextMenu(new MenuItem[] {
_nvTrayMenu,
_amdTrayMenu,
_lgTrayMenu,
new MenuItem("-"),
new MenuItem("Open", OpenForm),
@@ -120,7 +117,7 @@ namespace ColorControl
_nvService = new NvService(_dataDir);
FillNvPresets();
}
catch (Exception e)
catch (Exception)
{
//Logger.Error("Error initializing NvService: " + e.ToLogString());
Logger.Debug("No NVIDIA device detected");
@@ -135,7 +132,7 @@ namespace ColorControl
_amdService = new AmdService(_dataDir);
FillAmdPresets();
}
catch (Exception e)
catch (Exception)
{
//Logger.Error("Error initializing AmdService: " + e.ToLogString());
Logger.Debug("No AMD device detected");
@@ -148,6 +145,7 @@ namespace ColorControl
try
{
_lgService = new LgService(_dataDir, StartUpParams.RunningFromScheduledTask);
_lgService.RefreshDevices(afterStartUp: true).ContinueWith((_) => BeginInvoke(new Action(AfterLgServiceRefreshDevices)));
FillLgPresets();
@@ -190,20 +188,12 @@ namespace ColorControl
}
}
private void InitLogger()
private void AfterLgServiceRefreshDevices()
{
var config = new NLog.Config.LoggingConfiguration();
// Targets where to log to: File and Console
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = Path.Combine(_dataDir, "LogFile.txt") };
//var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
// Rules for mapping loggers to targets
//config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole);
config.AddRule(LogLevel.Trace, LogLevel.Fatal, logfile);
// Apply config
NLog.LogManager.Configuration = config;
if (StartUpParams.ExecuteLgPreset)
{
var _ = _lgService.ApplyPreset(StartUpParams.LgPresetName);
}
}
private void InitInfo()
@@ -452,17 +442,20 @@ namespace ColorControl
btnApply.Enabled = enabled;
btnChange.Enabled = enabled;
edtNvPresetName.Enabled = enabled;
edtShortcut.Enabled = enabled;
btnSetShortcut.Enabled = enabled;
btnNvPresetSave.Enabled = enabled;
btnClone.Enabled = enabled;
btnNvPresetDelete.Enabled = enabled;
if (preset != null)
{
edtNvPresetName.Text = preset.name;
edtShortcut.Text = preset.shortcut;
}
else
{
edtNvPresetName.Text = string.Empty;
edtShortcut.Text = string.Empty;
}
}
@@ -535,9 +528,18 @@ namespace ColorControl
var preset = GetSelectedNvPreset();
var name = edtNvPresetName.Text.Trim();
if (!string.IsNullOrEmpty(name) && _nvService.GetPresets().Any(x => x.id != preset.id && x.name != null && x.name.Equals(name, StringComparison.OrdinalIgnoreCase)))
{
MessageForms.WarningOk("The name must be unique.");
return;
}
var clear = !string.IsNullOrEmpty(preset.shortcut);
preset.shortcut = shortcut;
preset.name = name;
AddOrUpdateItem();
@@ -578,16 +580,6 @@ namespace ColorControl
private void LoadConfig()
{
if (File.Exists(_configFilename))
{
var data = File.ReadAllText(_configFilename);
_config = _JsonDeserializer.Deserialize<Config>(data);
}
else
{
_config = new Config();
}
chkStartMinimized.Checked = _config.StartMinimized;
chkMinimizeOnClose.Checked = _config.MinimizeOnClose;
chkMinimizeToSystemTray.Checked = _config.MinimizeToTray;
@@ -614,8 +606,8 @@ namespace ColorControl
try
{
var data = _JsonSerializer.Serialize(_config);
File.WriteAllText(_configFilename, data);
var data = Utils.JsonSerializer.Serialize(_config);
File.WriteAllText(Program.ConfigFilename, data);
}
catch (Exception e)
{
@@ -1320,6 +1312,27 @@ namespace ColorControl
}
}
private void UpdateTrayMenuAmd()
{
var presets = _amdService.GetPresets().Where(x => x.applyColorData || x.applyDithering || x.applyHDR || x.applyRefreshRate);
_amdTrayMenu.MenuItems.Clear();
foreach (var preset in presets)
{
var name = preset.GetTextForMenuItem();
if (!string.IsNullOrEmpty(preset.shortcut))
{
name += "\t" + preset.shortcut;
}
var item = new MenuItem(name);
item.Tag = preset;
item.Click += TrayMenuItemAmd_Click;
_amdTrayMenu.MenuItems.Add(item);
}
}
private void TrayMenuItemNv_Click(object sender, EventArgs e)
{
var item = sender as MenuItem;
@@ -1328,17 +1341,29 @@ namespace ColorControl
ApplyNvPreset(preset);
}
private void TrayMenuItemAmd_Click(object sender, EventArgs e)
{
var item = sender as MenuItem;
var preset = (AmdPreset)item.Tag;
ApplyAmdPreset(preset);
}
private void trayIconContextMenu_Popup(object sender, EventArgs e)
{
_nvTrayMenu.Visible = _nvService != null;
if (_nvTrayMenu.Visible)
{
UpdateTrayMenuNv();
}
_lgTrayMenu.Visible = _lgService != null;
_amdTrayMenu.Visible = _amdService != null;
if (_amdTrayMenu.Visible)
{
UpdateTrayMenuAmd();
}
_lgTrayMenu.Visible = _lgService != null;
if (_lgTrayMenu.Visible)
{
UpdateTrayMenuLg();
@@ -1424,7 +1449,7 @@ namespace ColorControl
}
try
{
var result = _nvService.ApplyPreset(preset, _config);
var result = _nvService.ApplyPreset(preset, Program.AppContext);
if (!result)
{
throw new Exception("Error while applying NVIDIA preset. At least one setting could not be applied. Check the log for details.");
@@ -1448,7 +1473,7 @@ namespace ColorControl
}
try
{
var result = _amdService.ApplyPreset(preset, _config);
var result = _amdService.ApplyPreset(preset, Program.AppContext);
if (!result)
{
throw new Exception("Error while applying AMD preset. At least one setting could not be applied. Check the log for details.");
@@ -1694,6 +1719,11 @@ Do you want to continue?";
{
UpdateDisplayInfoItems();
UpdateDisplayInfoItemsAmd();
if (tcMain.SelectedTab == tabLog)
{
LoadLog();
}
}
private void btnClearLog_Click(object sender, EventArgs e)
@@ -1799,12 +1829,18 @@ Do you want to continue?";
}
private void ApplyNvPresetOnStartup(int attempts = 5) {
if (_config.NvPresetId_ApplyOnStartup != 0)
var presetIdOrName = !string.IsNullOrEmpty(StartUpParams.NvidiaPresetIdOrName) ? StartUpParams.NvidiaPresetIdOrName : _config.NvPresetId_ApplyOnStartup.ToString();
if (!string.IsNullOrEmpty(presetIdOrName))
{
var preset = _nvService?.GetPresets().FirstOrDefault(p => p.id == _config.NvPresetId_ApplyOnStartup);
var preset = _nvService?.GetPresetByIdOrName(presetIdOrName);
if (preset == null)
{
_config.NvPresetId_ApplyOnStartup = 0;
if (string.IsNullOrEmpty(StartUpParams.NvidiaPresetIdOrName))
{
_config.NvPresetId_ApplyOnStartup = 0;
}
}
else if (_nvService != null)
{
@@ -1830,12 +1866,17 @@ Do you want to continue?";
private void ApplyAmdPresetOnStartup(int attempts = 5)
{
if (_config.AmdPresetId_ApplyOnStartup != 0)
var presetIdOrName = !string.IsNullOrEmpty(StartUpParams.AmdPresetIdOrName) ? StartUpParams.AmdPresetIdOrName : _config.AmdPresetId_ApplyOnStartup.ToString();
if (!string.IsNullOrEmpty(presetIdOrName))
{
var preset = _amdService?.GetPresets().FirstOrDefault(p => p.id == _config.AmdPresetId_ApplyOnStartup);
var preset = _amdService?.GetPresetByIdOrName(presetIdOrName);
if (preset == null)
{
_config.AmdPresetId_ApplyOnStartup = 0;
if (string.IsNullOrEmpty(StartUpParams.AmdPresetIdOrName))
{
_config.AmdPresetId_ApplyOnStartup = 0;
}
}
else if (_amdService != null)
{
@@ -1939,9 +1980,18 @@ Do you want to continue?";
var preset = GetSelectedAmdPreset();
var name = edtAmdPresetName.Text.Trim();
if (!string.IsNullOrEmpty(name) && _amdService.GetPresets().Any(x => x.id != preset.id && x.name != null && x.name.Equals(name, StringComparison.OrdinalIgnoreCase)))
{
MessageForms.WarningOk("The name must be unique.");
return;
}
var clear = !string.IsNullOrEmpty(preset.shortcut);
preset.shortcut = shortcut;
preset.name = name;
AddOrUpdateItemAmd();
@@ -2083,17 +2133,20 @@ Do you want to continue?";
btnApplyAmd.Enabled = enabled;
btnChangeAmd.Enabled = enabled;
edtAmdPresetName.Enabled = enabled;
edtAmdShortcut.Enabled = enabled;
btnSetAmdShortcut.Enabled = enabled;
btnAmdPresetSave.Enabled = enabled;
btnCloneAmd.Enabled = enabled;
btnDeleteAmd.Enabled = enabled;
if (preset != null)
{
edtAmdPresetName.Text = preset.name;
edtAmdShortcut.Text = preset.shortcut;
}
else
{
edtAmdPresetName.Text = string.Empty;
edtAmdShortcut.Text = string.Empty;
}
}
@@ -2200,5 +2253,25 @@ Do you want to continue?";
_trayIcon.Visible = _config.MinimizeToTray;
}
}
private void miNvCopyId_Click(object sender, EventArgs e)
{
var preset = GetSelectedNvPreset();
if (preset != null)
{
Clipboard.SetText(preset.id.ToString());
}
}
private void miAmdCopyId_Click(object sender, EventArgs e)
{
var preset = GetSelectedAmdPreset();
if (preset != null)
{
Clipboard.SetText(preset.id.ToString());
}
}
}
}
+32 -22
View File
@@ -73,13 +73,15 @@ namespace ColorControl
public static string[] GetColumnNames()
{
//return new[] { "BPC", "Format", "Dynamic range", "Toggle HDR", "Shortcut" };
return new[] { "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Dithering", "HDR", "Shortcut", "Apply on startup" };
return new[] { "Name", "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Dithering", "HDR", "Shortcut", "Apply on startup" };
}
public override List<string> GetDisplayValues(Config config = null)
{
var values = new List<string>();
values.Add(name);
var display = string.Format("{0}", primaryDisplay ? "Primary" : displayName);
values.Add(display);
@@ -142,31 +144,39 @@ namespace ColorControl
public string GetTextForMenuItem()
{
var sb = new StringBuilder();
if (displayName != null)
if (!string.IsNullOrEmpty(name))
{
sb.AppendFormat("Display: {0} / ", displayName);
}
if (applyColorData)
{
var colorSettings = string.Format("Format: {0}, {1}, {2}", colorData.ColorDepth, colorData.ColorFormat, colorData.DynamicRange);
sb.Append(colorSettings);
sb.Append(name);
sb.Append(" / ");
}
if (applyRefreshRate)
else
{
sb.AppendFormat("{0}Hz", refreshRate);
sb.Append(" / ");
}
if (applyDithering)
{
var dithering = GetDitheringDescription("No");
sb.AppendFormat("Dithering: {0}", dithering);
sb.Append(" / ");
}
if (applyHDR)
{
sb.AppendFormat("HDR: {0}", toggleHDR ? "Toggle" : HDREnabled ? "Enabled" : "Disabled");
sb.Append(" / ");
if (displayName != null)
{
sb.AppendFormat("Display: {0} / ", displayName);
}
if (applyColorData)
{
var colorSettings = string.Format("Format: {0}, {1}, {2}", colorData.ColorDepth, colorData.ColorFormat, colorData.DynamicRange);
sb.Append(colorSettings);
sb.Append(" / ");
}
if (applyRefreshRate)
{
sb.AppendFormat("{0}Hz", refreshRate);
sb.Append(" / ");
}
if (applyDithering)
{
var dithering = GetDitheringDescription("No");
sb.AppendFormat("Dithering: {0}", dithering);
sb.Append(" / ");
}
if (applyHDR)
{
sb.AppendFormat("HDR: {0}", toggleHDR ? "Toggle" : HDREnabled ? "Enabled" : "Disabled");
sb.Append(" / ");
}
}
return sb.ToString(0, Math.Max(0, sb.Length - 3));
+55 -14
View File
@@ -10,7 +10,6 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Windows.Graphics.Display;
namespace ColorControl
{
@@ -38,8 +37,10 @@ namespace ColorControl
Temporal = 4
}
class NvService : GraphicsService
class NvService : GraphicsService<NvPreset>
{
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
[DllImport(@"nvapi64", EntryPoint = @"nvapi_QueryInterface", CallingConvention = CallingConvention.Cdecl,
PreserveSig = true)]
private static extern IntPtr NvAPI64_QueryInterface(uint interfaceId);
@@ -66,8 +67,6 @@ namespace ColorControl
public uint mode;
};
private List<NvPreset> _presets;
private Display _currentDisplay;
private NvPreset _lastAppliedPreset;
@@ -79,6 +78,28 @@ namespace ColorControl
LoadPresets();
}
public static bool ExecutePresetAsync(string idOrName)
{
try
{
var nvService = new NvService(Program.DataDir);
var result = nvService.ApplyPreset(idOrName);
if (!result)
{
Console.WriteLine("Preset not found or error while executing.");
}
return result;
}
catch (Exception ex)
{
Console.WriteLine("Error executing preset: " + ex.ToLogString());
return false;
}
}
public Display GetCurrentDisplay()
{
if (_currentDisplay == null)
@@ -89,7 +110,7 @@ namespace ColorControl
return _currentDisplay;
}
public bool HasDisplaysAttached()
public override bool HasDisplaysAttached()
{
try
{
@@ -106,11 +127,6 @@ namespace ColorControl
SavePresets();
}
public List<NvPreset> GetPresets()
{
return _presets;
}
private void LoadPresets()
{
_presetsFilename = Path.Combine(_dataPath, "NvPresets.json");
@@ -153,7 +169,21 @@ namespace ColorControl
}
}
public bool ApplyPreset(NvPreset preset, Config config)
public bool ApplyPreset(string idOrName)
{
var preset = GetPresetByIdOrName(idOrName);
if (preset != null)
{
return ApplyPreset(preset, Program.AppContext);
}
else
{
return false;
}
}
public bool ApplyPreset(NvPreset preset, AppContext appContext)
{
var result = true;
@@ -191,7 +221,7 @@ namespace ColorControl
if (hdrEnabled && newHdrEnabled)
{
SetHDRState(display, true);
SetHDRState(display, true, useSwitch: appContext.StartUpParams.NoGui);
applyHdr = false;
}
@@ -203,7 +233,7 @@ namespace ColorControl
var colorData = preset.applyColorData ? preset.colorData : display.DisplayDevice.CurrentColorData;
SetHDRState(display, newHdrEnabled, colorData);
SetHDRState(display, newHdrEnabled, colorData, appContext.StartUpParams.NoGui);
}
if (preset.applyRefreshRate)
@@ -253,8 +283,17 @@ namespace ColorControl
return colorData.ColorFormat != currentColorData.ColorFormat || colorData.ColorDepth != currentColorData.ColorDepth || settingRange != currentColorData.DynamicRange || settingSpace != currentColorData.Colorimetry;
}
private void SetHDRState(Display display, bool enabled, ColorData colorData = null)
private void SetHDRState(Display display, bool enabled, ColorData colorData = null, bool useSwitch = false)
{
if (useSwitch)
{
if (enabled != IsHDREnabled())
{
ToggleHDR();
}
return;
}
var newMaster = new MasteringDisplayColorData();
var hdr = new HDRColorData(enabled ? ColorDataHDRMode.UHDA : ColorDataHDRMode.Off, newMaster, colorData?.ColorFormat, colorData?.DynamicRange, colorData?.ColorDepth);
@@ -404,6 +443,8 @@ namespace ColorControl
{
var values = new List<string>();
values.Add("Current settings");
var name = display.Name;
var screen = Screen.AllScreens.FirstOrDefault(x => x.DeviceName.Equals(name));
+1
View File
@@ -5,6 +5,7 @@ namespace ColorControl
{
internal abstract class PresetBase
{
public string name { get; set; }
public string shortcut { get; set; }
private int _id;
+149 -20
View File
@@ -1,7 +1,8 @@
using NWin32;
using NLog;
using NWin32;
using System;
using System.Diagnostics;
using System.Text;
using System.IO;
using System.Threading;
using System.Windows.Forms;
@@ -9,6 +10,11 @@ namespace ColorControl
{
static class Program
{
public static string DataDir { get; private set; }
public static string ConfigFilename { get; private set; }
public static Config Config { get; private set; }
public static AppContext AppContext { get; private set; }
/// <summary>
/// The main entry point for the application.
/// </summary>
@@ -21,35 +27,41 @@ namespace ColorControl
// Handler for exceptions in threads behind forms.
Application.ThreadException += GlobalThreadExceptionHandler;
DataDir = Utils.GetDataPath();
InitLogger();
LoadConfig();
var startUpParams = StartUpParams.Parse(args);
if (startUpParams.ActivateChromeFontFix || startUpParams.DeactivateChromeFontFix)
AppContext = new AppContext(Config, startUpParams);
var existingProcess = Utils.GetProcessByName("ColorControl");
try
{
Utils.InstallChromeFix(startUpParams.ActivateChromeFontFix);
return;
if (HandleStartupParams(startUpParams, existingProcess))
{
return;
}
}
finally
{
Utils.CloseConsole();
}
string mutexId = $"Global\\{typeof(MainForm).GUID}";
bool mutexCreated;
var mutex = new Mutex(true, mutexId, out mutexCreated);
var mutex = new Mutex(true, mutexId, out var mutexCreated);
try
{
if (!mutexCreated)
{
var currentProcessId = Process.GetCurrentProcess().Id;
foreach (var process in Process.GetProcesses())
if (existingProcess != null && existingProcess.Threads.Count > 0)
{
if (process.ProcessName.Equals("ColorControl") && process.Id != currentProcessId)
{
if (process.Threads.Count > 0)
{
var thread = process.Threads[0];
var thread = existingProcess.Threads[0];
NativeMethods.EnumThreadWindows((uint)thread.Id, EnumThreadWindows, IntPtr.Zero);
NativeMethods.EnumThreadWindows((uint)thread.Id, EnumThreadWindows, IntPtr.Zero);
}
return;
}
return;
}
MessageBox.Show("Only one instance of this program can be active.", "ColorControl");
@@ -60,7 +72,7 @@ namespace ColorControl
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm(startUpParams));
Application.Run(new MainForm(AppContext));
}
catch (Exception ex)
{
@@ -77,6 +89,123 @@ namespace ColorControl
}
}
private static void InitLogger()
{
var config = new NLog.Config.LoggingConfiguration();
// Targets where to log to: File and Console
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = Path.Combine(DataDir, "LogFile.txt") };
//var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
// Rules for mapping loggers to targets
//config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole);
config.AddRule(LogLevel.Trace, LogLevel.Fatal, logfile);
// Apply config
LogManager.Configuration = config;
}
private static void LoadConfig()
{
ConfigFilename = Path.Combine(DataDir, "Settings.json");
if (File.Exists(ConfigFilename))
{
var data = File.ReadAllText(ConfigFilename);
Config = Utils.JsonSerializer.Deserialize<Config>(data);
}
else
{
Config = new Config();
}
}
private static bool HandleStartupParams(StartUpParams startUpParams, Process existingProcess)
{
if (startUpParams.ActivateChromeFontFix || startUpParams.DeactivateChromeFontFix)
{
Utils.InstallChromeFix(startUpParams.ActivateChromeFontFix);
return true;
}
var useConsole = startUpParams.NoGui || existingProcess != null;
if (!useConsole)
{
return false;
}
startUpParams.NoGui = true;
var result = false;
if (startUpParams.ExecuteHelp)
{
Utils.OpenConsole();
Console.WriteLine("\nColorControl CLI");
Console.WriteLine("Syntax : ColorControl command options");
Console.WriteLine("Commands:");
Console.WriteLine("--nvpreset <preset name or id>: execute NVIDIA-preset");
Console.WriteLine("--amdpreset <preset name or id>: execute AMD-preset");
Console.WriteLine("--lgpreset <preset name> : execute LG-preset");
Console.WriteLine("--help : displays this help info");
Console.WriteLine("Options :");
Console.WriteLine("--nogui: starts command from the command line and will not open GUI (is forced when GUI is already running)");
result = true;
}
if (startUpParams.ExecuteLgPreset)
{
Utils.OpenConsole();
Console.WriteLine($"Executing LG-preset '{startUpParams.LgPresetName}'...");
var task = LgService.ExecutePresetAsync(startUpParams.LgPresetName);
var taskResult = Utils.WaitForTask(task);
if (taskResult)
{
Console.WriteLine("Done.");
}
result = true;
}
if (startUpParams.ExecuteNvidiaPreset)
{
Utils.OpenConsole();
Console.WriteLine($"Executing NVIDIA-preset '{startUpParams.NvidiaPresetIdOrName}'...");
var taskResult = NvService.ExecutePresetAsync(startUpParams.NvidiaPresetIdOrName);
if (taskResult)
{
Console.WriteLine("Done.");
}
result = true;
}
if (startUpParams.ExecuteAmdPreset)
{
Utils.OpenConsole();
Console.WriteLine($"Executing AMD-preset '{startUpParams.AmdPresetIdOrName}'...");
var taskResult = AmdService.ExecutePresetAsync(startUpParams.AmdPresetIdOrName);
if (taskResult)
{
Console.WriteLine("Done.");
}
result = true;
}
return result;
}
public static int EnumThreadWindows(IntPtr handle, IntPtr param)
{
NativeMethods.SendMessageW(handle, Utils.WM_BRINGTOFRONT, UIntPtr.Zero, IntPtr.Zero);
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
+22 -4
View File
@@ -1,16 +1,18 @@
using System.Web.Script.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Script.Serialization;
namespace ColorControl
{
class ServiceBase
abstract class ServiceBase<T> where T : PresetBase
{
protected static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
protected string _dataPath;
protected string _presetsFilename;
protected JavaScriptSerializer _JsonSerializer;
protected JavaScriptSerializer _JsonDeserializer;
protected bool _initialized = false;
protected List<T> _presets;
public ServiceBase(string dataPath)
{
@@ -27,6 +29,22 @@ namespace ColorControl
Uninitialize();
}
public List<T> GetPresets()
{
return _presets;
}
public T GetPresetByIdOrName(string idOrName)
{
var preset = _presets.FirstOrDefault(p => p.name != null && p.name.Equals(idOrName, StringComparison.OrdinalIgnoreCase));
if (preset == null && int.TryParse(idOrName, out var id))
{
preset = _presets.FirstOrDefault(p => p.id == id);
}
return preset;
}
protected virtual void Initialize()
{
+68
View File
@@ -7,16 +7,55 @@ namespace ColorControl
public const string RunningFromScheduledTaskParam = "--scheduled";
public const string ActivateChromeFontFixParam = "--activate-chrome-font-fix";
public const string DeactivateChromeFontFixParam = "--deactivate-chrome-font-fix";
public const string ExecuteHelpParam = "--help";
public const string ExecuteNvidiaPresetParam = "--nvpreset";
public const string ExecuteAmdPresetParam = "--amdpreset";
public const string ExecuteLgPresetParam = "--lgpreset";
public const string NoGuiParam = "--nogui";
public bool RunningFromScheduledTask { get; private set; }
public bool ActivateChromeFontFix { get; private set; }
public bool DeactivateChromeFontFix { get; private set; }
public bool ExecuteHelp { get; private set; }
public bool ExecuteNvidiaPreset { get; private set; }
public string NvidiaPresetIdOrName { get; private set; }
public bool ExecuteAmdPreset { get; private set; }
public string AmdPresetIdOrName { get; private set; }
public bool ExecuteLgPreset { get; private set; }
public string LgPresetName { get; private set; }
public bool NoGui { get; set; }
public static StartUpParams Parse(IEnumerable<string> args)
{
var settings = new StartUpParams();
var parseNameParam = string.Empty;
foreach (var arg in args)
{
if (!string.IsNullOrEmpty(parseNameParam))
{
switch (parseNameParam)
{
case ExecuteNvidiaPresetParam:
{
settings.NvidiaPresetIdOrName = arg;
break;
}
case ExecuteAmdPresetParam:
{
settings.AmdPresetIdOrName = arg;
break;
}
case ExecuteLgPresetParam:
{
settings.LgPresetName = arg;
break;
}
}
parseNameParam = string.Empty;
continue;
}
switch (arg.ToLowerInvariant())
{
case RunningFromScheduledTaskParam:
@@ -34,6 +73,35 @@ namespace ColorControl
settings.DeactivateChromeFontFix = true;
break;
}
case ExecuteHelpParam:
{
settings.ExecuteHelp = true;
settings.NoGui = true;
break;
}
case ExecuteNvidiaPresetParam:
{
settings.ExecuteNvidiaPreset = true;
parseNameParam = ExecuteNvidiaPresetParam;
break;
}
case ExecuteAmdPresetParam:
{
settings.ExecuteAmdPreset = true;
parseNameParam = ExecuteAmdPresetParam;
break;
}
case ExecuteLgPresetParam:
{
settings.ExecuteLgPreset = true;
parseNameParam = ExecuteLgPresetParam;
break;
}
case NoGuiParam:
{
settings.NoGui = true;
break;
}
}
}
return settings;
+69 -1
View File
@@ -2,6 +2,7 @@
using Microsoft.Win32.TaskScheduler;
using NStandard;
using NWin32;
using NWin32.NativeTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -16,6 +17,7 @@ using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using Windows.Devices.Enumeration;
using Windows.Devices.Enumeration.Pnp;
@@ -35,11 +37,18 @@ namespace ColorControl
public const int WM_BRINGTOFRONT = NativeConstants.WM_USER + 1;
public const int ENUM_CURRENT_SETTINGS = -1;
public const int ENUM_REGISTRY_SETTINGS = -2;
public static string PKEY_PNPX_IpAddress = "{656a3bb3-ecc0-43fd-8477-4ae0404a96cd} 12297";
public static string PKEY_PNPX_PhysicalAddress = "{656a3bb3-ecc0-43fd-8477-4ae0404a96cd} 12294";
public delegate void PCREATE_PROCESS_NOTIFY_ROUTINE(IntPtr ParentId, IntPtr ProcessId, bool Create);
public static JavaScriptSerializer JsonSerializer = new JavaScriptSerializer();
public static bool ConsoleOpened { get; private set; }
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
[DllImport("user32.dll")]
@@ -51,6 +60,20 @@ namespace ColorControl
[DllImport("user32.dll")]
public extern static bool ShutdownBlockReasonDestroy(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern bool EnumDisplaySettingsA(string deviceName, int modeNum, out DEVMODEA devMode);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool AllocConsole();
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
private static extern bool AttachConsole(int processId);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FreeConsole();
//[DllImport("Wtsapi32.dll")]
//public extern static bool WTSRegisterSessionNotification(IntPtr hWnd, uint dwFlags);
@@ -330,13 +353,14 @@ namespace ColorControl
return devices;
}
public static void WaitForTask(System.Threading.Tasks.Task task)
public static T WaitForTask<T>(System.Threading.Tasks.Task<T> task)
{
while (task != null && (task.Status < TaskStatus.WaitingForChildrenToComplete))
{
Thread.Sleep(100);
Application.DoEvents();
}
return task.Result;
}
public static void SetNotifyIconText(NotifyIcon ni, string text)
@@ -618,6 +642,50 @@ namespace ColorControl
}
}
}
public static bool OpenConsole()
{
if (ConsoleOpened)
{
return true;
}
if (!AttachConsole(-1))
{
AllocConsole();
return true;
}
ConsoleOpened = true;
return false;
}
public static bool CloseConsole()
{
if (!ConsoleOpened)
{
return false;
}
SendKeys.SendWait("{ENTER}");
var result = FreeConsole();
return result;
}
public static Process GetProcessByName(string name, bool skipCurrent = true)
{
var currentProcessId = Process.GetCurrentProcess().Id;
foreach (var process in Process.GetProcesses())
{
if (process.ProcessName.Equals(name) && (!skipCurrent || process.Id != currentProcessId))
{
return process;
}
}
return null;
}
}
public static class ProcessExtensions
+1 -1
View File
@@ -18,7 +18,7 @@ namespace LgTv
}
public class LgTvApi:IDisposable
{
public bool ConnectionClosed { get => _connection == null || _connection.ConnectionClosed; }
public bool ConnectionClosed { get => _connection?.ConnectionClosed ?? true; }
private readonly LgTvApiCore _connection;
private LgWebOsMouseService _mouseConnection;