diff --git a/ColorControl/ColorControl.csproj b/ColorControl/ColorControl.csproj
index ce06623..3531fbf 100644
--- a/ColorControl/ColorControl.csproj
+++ b/ColorControl/ColorControl.csproj
@@ -18,8 +18,8 @@
Maassoft
Maassoft
0
- 9.6.4.0
- 9.6.4.0
+ 9.7.0.0
+ 9.7.0.0
false
true
false
@@ -63,6 +63,9 @@
UserControl
+
+ UserControl
+
UserControl
diff --git a/ColorControl/CommandLineHandler.cs b/ColorControl/CommandLineHandler.cs
index 6995308..5e1edc1 100644
--- a/ColorControl/CommandLineHandler.cs
+++ b/ColorControl/CommandLineHandler.cs
@@ -5,6 +5,7 @@ using ColorControl.Services.NVIDIA;
using ColorControl.Services.Samsung;
using ColorControl.Shared.Common;
using ColorControl.Shared.Contracts;
+using Microsoft.Extensions.DependencyInjection;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
@@ -16,55 +17,11 @@ namespace ColorControl
{
public static async Task HandleStartupParams(StartUpParams startUpParams, Process existingProcess)
{
- if (startUpParams.ActivateChromeFontFix || startUpParams.DeactivateChromeFontFix)
- {
- Utils.InstallChromeFix(startUpParams.ActivateChromeFontFix, startUpParams.ChromeFontFixApplicationDataFolder);
- return true;
- }
- if (startUpParams.EnableAutoStart || startUpParams.DisableAutoStart)
- {
- Utils.RegisterTask(Program.TS_TASKNAME, startUpParams.EnableAutoStart, startUpParams.AutoStartRunLevel);
- return true;
- }
- if (startUpParams.SetProcessAffinity)
- {
- Utils.SetProcessAffinity(startUpParams.ProcessId, startUpParams.AffinityMask);
- return true;
- }
- if (startUpParams.SetProcessPriority)
- {
- Utils.SetProcessPriority(startUpParams.ProcessId, startUpParams.PriorityClass);
- return true;
- }
if (startUpParams.StartElevated)
{
StartElevated();
return true;
}
- if (startUpParams.SendWol)
- {
- return WOL.WakeFunction(startUpParams.WolMacAddress, startUpParams.WolIpAddress);
- }
- if (startUpParams.InstallService)
- {
- Utils.InstallService();
- return true;
- }
- if (startUpParams.UninstallService)
- {
- Utils.UninstallService();
- return true;
- }
- if (startUpParams.StartService)
- {
- Utils.StartService();
- return true;
- }
- if (startUpParams.StopService)
- {
- Utils.StopService();
- return true;
- }
var useConsole = startUpParams.NoGui || existingProcess != null;
@@ -152,7 +109,9 @@ Options:
{
try
{
- Application.Run(new ElevatedForm());
+ var elevatedForm = Program.ServiceProvider.GetRequiredService();
+
+ Application.Run(elevatedForm);
}
catch (Exception ex)
{
diff --git a/ColorControl/Forms/ElevatedForm.cs b/ColorControl/Forms/ElevatedForm.cs
index 10b02ae..a2dcf2b 100644
--- a/ColorControl/Forms/ElevatedForm.cs
+++ b/ColorControl/Forms/ElevatedForm.cs
@@ -1,85 +1,53 @@
-using ColorControl.Shared.Contracts;
-using ColorControl.Shared.Native;
-using NWin32;
+using ColorControl.Svc;
using System;
using System.Drawing;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
-namespace ColorControl.Forms
+namespace ColorControl.Forms;
+
+public partial class ElevatedForm : Form
{
- public partial class ElevatedForm : Form
+ private ColorControlBackgroundService _backgroundService;
+
+ public ElevatedForm(ColorControlBackgroundService backgroundService)
{
- public ElevatedForm()
+ InitializeComponent();
+
+ FormBorderStyle = FormBorderStyle.None;
+ ShowInTaskbar = false;
+ Load += ElevatedForm_Load;
+ Shown += ElevatedForm_Shown;
+
+ Task.Run(CheckMutexAsync);
+
+ _backgroundService = backgroundService;
+ _backgroundService.PipeName = "elevatedpipe";
+
+ Task.Run(async () => await _backgroundService.StartAsync(CancellationToken.None));
+ }
+
+ private void ElevatedForm_Shown(object sender, EventArgs e)
+ {
+ Hide();
+ }
+
+ protected void ElevatedForm_Load(object sender, EventArgs e)
+ {
+ Size = new Size(0, 0);
+ }
+
+ private void CheckMutexAsync()
+ {
+ var mutex = new Mutex(false, Shared.Common.GlobalContext.CurrentContext.MutexId, out var created);
+ try
{
- InitializeComponent();
-
- FormBorderStyle = FormBorderStyle.None;
- ShowInTaskbar = false;
- Load += ElevatedForm_Load;
- Shown += ElevatedForm_Shown;
-
- var filterStatus = new WinApi.CHANGEFILTERSTRUCT();
- filterStatus.size = (uint)Marshal.SizeOf(filterStatus);
- filterStatus.info = 0;
-
- WinApi.ChangeWindowMessageFilterEx(Handle, NativeConstants.WM_COPYDATA, WinApi.ChangeWindowMessageFilterExAction.Allow, ref filterStatus);
-
- Task.Run(CheckMutexAsync);
+ mutex.WaitOne();
}
-
- private void ElevatedForm_Shown(object sender, EventArgs e)
+ catch (AbandonedMutexException)
{
- Hide();
- }
-
- protected void ElevatedForm_Load(object sender, EventArgs e)
- {
- Size = new Size(0, 0);
- }
-
- protected override void WndProc(ref Message m)
- {
- if (m.Msg == NativeConstants.WM_COPYDATA)
- {
- var container = (WinApi.COPYDATASTRUCT)m.GetLParam(typeof(WinApi.COPYDATASTRUCT));
- var message = Marshal.PtrToStringAnsi(container.lpData);
-
- HandleMessage(message);
- }
-
- base.WndProc(ref m);
- }
-
- private void HandleMessage(string message)
- {
- var args = message.Split(' ');
-
- var startUpParams = StartUpParams.Parse(args);
-
- try
- {
- var _ = CommandLineHandler.HandleStartupParams(startUpParams, null);
- }
- catch (Exception)
- {
-
- }
- }
-
- private void CheckMutexAsync()
- {
- var mutex = new Mutex(false, Shared.Common.AppContext.CurrentContext.MutexId, out var created);
- try
- {
- mutex.WaitOne();
- }
- catch (AbandonedMutexException)
- {
- }
- BeginInvoke(Application.Exit);
}
+ BeginInvoke(Application.Exit);
}
}
diff --git a/ColorControl/MainForm.Designer.cs b/ColorControl/MainForm.Designer.cs
index 9dbb87e..ce3e26e 100644
--- a/ColorControl/MainForm.Designer.cs
+++ b/ColorControl/MainForm.Designer.cs
@@ -59,9 +59,6 @@
chkStartMinimized = new System.Windows.Forms.CheckBox();
chkStartAfterLogin = new System.Windows.Forms.CheckBox();
tabInfo = new System.Windows.Forms.TabPage();
- grpNVIDIAInfo = new System.Windows.Forms.GroupBox();
- btnRefreshNVIDIAInfo = new System.Windows.Forms.Button();
- tvNVIDIAInfo = new System.Windows.Forms.TreeView();
groupBox3 = new System.Windows.Forms.GroupBox();
lbPlugins = new System.Windows.Forms.ListBox();
label7 = new System.Windows.Forms.Label();
@@ -73,7 +70,6 @@
grpMiscellaneousOptions.SuspendLayout();
grpGeneralOptions.SuspendLayout();
tabInfo.SuspendLayout();
- grpNVIDIAInfo.SuspendLayout();
groupBox3.SuspendLayout();
SuspendLayout();
//
@@ -441,7 +437,6 @@
//
// tabInfo
//
- tabInfo.Controls.Add(grpNVIDIAInfo);
tabInfo.Controls.Add(groupBox3);
tabInfo.Location = new System.Drawing.Point(4, 24);
tabInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
@@ -452,41 +447,6 @@
tabInfo.Text = "Info";
tabInfo.UseVisualStyleBackColor = true;
//
- // grpNVIDIAInfo
- //
- grpNVIDIAInfo.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
- grpNVIDIAInfo.Controls.Add(btnRefreshNVIDIAInfo);
- grpNVIDIAInfo.Controls.Add(tvNVIDIAInfo);
- grpNVIDIAInfo.Location = new System.Drawing.Point(463, 7);
- grpNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- grpNVIDIAInfo.Name = "grpNVIDIAInfo";
- grpNVIDIAInfo.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
- grpNVIDIAInfo.Size = new System.Drawing.Size(643, 511);
- grpNVIDIAInfo.TabIndex = 4;
- grpNVIDIAInfo.TabStop = false;
- grpNVIDIAInfo.Text = "NVIDIA info";
- //
- // btnRefreshNVIDIAInfo
- //
- btnRefreshNVIDIAInfo.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
- btnRefreshNVIDIAInfo.Location = new System.Drawing.Point(7, 478);
- btnRefreshNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- btnRefreshNVIDIAInfo.Name = "btnRefreshNVIDIAInfo";
- btnRefreshNVIDIAInfo.Size = new System.Drawing.Size(88, 27);
- btnRefreshNVIDIAInfo.TabIndex = 1;
- btnRefreshNVIDIAInfo.Text = "Refresh";
- btnRefreshNVIDIAInfo.UseVisualStyleBackColor = true;
- btnRefreshNVIDIAInfo.Click += btnRefreshNVIDIAInfo_Click;
- //
- // tvNVIDIAInfo
- //
- tvNVIDIAInfo.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
- tvNVIDIAInfo.Location = new System.Drawing.Point(7, 22);
- tvNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
- tvNVIDIAInfo.Name = "tvNVIDIAInfo";
- tvNVIDIAInfo.Size = new System.Drawing.Size(628, 448);
- tvNVIDIAInfo.TabIndex = 0;
- //
// groupBox3
//
groupBox3.Controls.Add(lbPlugins);
@@ -579,7 +539,6 @@
grpGeneralOptions.ResumeLayout(false);
grpGeneralOptions.PerformLayout();
tabInfo.ResumeLayout(false);
- grpNVIDIAInfo.ResumeLayout(false);
groupBox3.ResumeLayout(false);
groupBox3.PerformLayout();
ResumeLayout(false);
@@ -597,9 +556,6 @@
private System.Windows.Forms.ListBox lbPlugins;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label lblInfo;
- private System.Windows.Forms.GroupBox grpNVIDIAInfo;
- private System.Windows.Forms.TreeView tvNVIDIAInfo;
- private System.Windows.Forms.Button btnRefreshNVIDIAInfo;
private System.Windows.Forms.GroupBox grpMiscellaneousOptions;
private System.Windows.Forms.CheckBox chkFixChromeFonts;
private System.Windows.Forms.Label lblFixChromeFontsDescription;
diff --git a/ColorControl/MainForm.cs b/ColorControl/MainForm.cs
index 36f94d4..015ddd8 100644
--- a/ColorControl/MainForm.cs
+++ b/ColorControl/MainForm.cs
@@ -15,7 +15,6 @@ using Linearstar.Windows.RawInput;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using novideo_srgb;
-using NvAPIWrapper.Display;
using NWin32;
using System;
using System.Collections.Generic;
@@ -39,10 +38,12 @@ namespace ColorControl
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly PowerEventDispatcher _powerEventDispatcher;
private readonly ServiceManager _serviceManager;
+ private readonly IServiceProvider _serviceProvider;
+ private readonly WinApiAdminService _winApiAdminService;
+ private readonly WinApiService _winApiService;
private string _dataDir;
private NvPanel _nvPanel;
- private NvDitherPanel _nvDitherPanel;
private NotifyIcon _trayIcon;
private bool _initialized = false;
@@ -76,7 +77,8 @@ namespace ColorControl
private Dictionary _shortcuts = new();
private Dictionary> _modules = new();
- public MainForm(AppContextProvider appContextProvider, PowerEventDispatcher powerEventDispatcher, ServiceManager serviceManager)
+ public MainForm(AppContextProvider appContextProvider, PowerEventDispatcher powerEventDispatcher, ServiceManager serviceManager,
+ IServiceProvider serviceProvider, WinApiAdminService winApiAdminService, WinApiService winApiService)
{
InitializeComponent();
@@ -87,6 +89,9 @@ namespace ColorControl
_powerEventDispatcher = powerEventDispatcher;
_serviceManager = serviceManager;
+ _serviceProvider = serviceProvider;
+ _winApiAdminService = winApiAdminService;
+ _winApiService = winApiService;
_dataDir = Program.DataDir;
_config = Program.Config;
@@ -130,17 +135,17 @@ namespace ColorControl
_trayIcon.ContextMenuStrip.Opened += trayIconContextMenu_Popup;
_trayIcon.BalloonTipClicked += trayIconBalloonTip_Clicked;
- chkStartAfterLogin.Checked = Utils.TaskExists(Program.TS_TASKNAME);
+ chkStartAfterLogin.Checked = _winApiService.TaskExists(Program.TS_TASKNAME);
- chkFixChromeFonts.Enabled = Utils.IsChromeInstalled();
+ chkFixChromeFonts.Enabled = _winApiService.IsChromeInstalled();
if (chkFixChromeFonts.Enabled)
{
- var fixInstalled = Utils.IsChromeFixInstalled();
+ var fixInstalled = _winApiService.IsChromeFixInstalled();
if (_config.FixChromeFonts && !fixInstalled)
{
- Utils.ExecuteElevated(StartUpParams.ActivateChromeFontFixParam);
+ _winApiAdminService.InstallChromeFix(true, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
}
- chkFixChromeFonts.Checked = Utils.IsChromeFixInstalled();
+ chkFixChromeFonts.Checked = _winApiService.IsChromeFixInstalled();
}
InitShortcut(SHORTCUTID_SCREENSAVER, _config.ScreenSaverShortcut, StartScreenSaver);
@@ -230,12 +235,12 @@ namespace ColorControl
var text = "Use Windows Service";
btnStartStopService.Enabled = true;
- if (Utils.IsServiceRunning())
+ if (_winApiService.IsServiceRunning())
{
text += " (running)";
btnStartStopService.Text = "Stop";
}
- else if (Utils.IsServiceInstalled())
+ else if (_winApiService.IsServiceInstalled())
{
text += " (installed, not running)";
btnStartStopService.Text = "Start";
@@ -256,11 +261,11 @@ namespace ColorControl
{
//throw new Exception("bla");
Logger.Debug("Initializing NVIDIA...");
- var appContextProvider = Program.ServiceProvider.GetRequiredService();
- _serviceManager.NvService = new NvService(appContextProvider);
+ var appContextProvider = _serviceProvider.GetRequiredService();
+ _serviceManager.NvService = _serviceProvider.GetRequiredService();
Logger.Debug("Initializing NVIDIA...Done.");
- var rpcService = Program.ServiceProvider.GetRequiredService();
+ var rpcService = _serviceProvider.GetRequiredService();
_nvPanel = new NvPanel(_serviceManager.NvService, _trayIcon, Handle, appContextProvider, rpcService);
_nvPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
@@ -282,7 +287,7 @@ namespace ColorControl
{
try
{
- var appContextProvider = Program.ServiceProvider.GetRequiredService();
+ var appContextProvider = _serviceProvider.GetRequiredService();
_serviceManager.AmdService = new AmdService(appContextProvider);
_amdPanel = new AmdPanel(_serviceManager.AmdService, _trayIcon, Handle);
@@ -305,7 +310,7 @@ namespace ColorControl
{
try
{
- _serviceManager.GameService = Program.ServiceProvider.GetRequiredService();
+ _serviceManager.GameService = _serviceProvider.GetRequiredService();
_gamePanel = new GamePanel(_serviceManager.GameService, _serviceManager.NvService, _serviceManager.AmdService, _serviceManager.LgService, _serviceManager.SamsungService, _trayIcon, Handle);
_gamePanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
@@ -336,7 +341,7 @@ namespace ColorControl
{
try
{
- _serviceManager.LgService = Program.ServiceProvider.GetRequiredService();
+ _serviceManager.LgService = _serviceProvider.GetRequiredService();
_lgPanel = new LgPanel(_serviceManager.LgService, _serviceManager.NvService, _serviceManager.AmdService, _trayIcon, Handle);
_lgPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
@@ -360,7 +365,7 @@ namespace ColorControl
{
try
{
- _serviceManager.SamsungService = Program.ServiceProvider.GetRequiredService();
+ _serviceManager.SamsungService = _serviceProvider.GetRequiredService();
//_serviceManager.SamsungService.Init();
@@ -387,7 +392,7 @@ namespace ColorControl
Text = Application.ProductName + " " + Application.ProductVersion;
- if (Utils.IsAdministrator())
+ if (_winApiService.IsAdministrator())
{
Text += " (administrator)";
}
@@ -435,7 +440,7 @@ namespace ColorControl
{
if (_updateHtmlUrl != null)
{
- Utils.StartProcess(_updateHtmlUrl);
+ _winApiAdminService.StartProcess(_updateHtmlUrl);
}
}
@@ -691,7 +696,7 @@ namespace ColorControl
private void CheckElevationMethod()
{
- if (Utils.IsAdministrator())
+ if (_winApiService.IsAdministrator())
{
return;
}
@@ -703,15 +708,15 @@ namespace ColorControl
return;
}
- if (_config.ElevationMethod == ElevationMethod.UseService && !Utils.IsServiceInstalled() &&
+ if (_config.ElevationMethod == ElevationMethod.UseService && !_winApiService.IsServiceInstalled() &&
(MessageForms.QuestionYesNo("The elevation method is set to Windows Service but it is not installed. Do you want to install it now?") == DialogResult.Yes))
{
- Utils.InstallService();
+ _winApiAdminService.InstallService();
}
- else if (_config.ElevationMethod == ElevationMethod.UseService && !Utils.IsServiceRunning() &&
+ else if (_config.ElevationMethod == ElevationMethod.UseService && !_winApiService.IsServiceRunning() &&
(MessageForms.QuestionYesNo("The elevation method is set to Windows Service but it is not running. Do you want to start it now?") == DialogResult.Yes))
{
- Utils.StartService();
+ _winApiAdminService.StartService();
}
return;
@@ -764,7 +769,6 @@ NOTE: installing the service may cause a User Account Control popup.");
{
if (tcMain.SelectedTab == tabInfo)
{
- LoadInfo();
}
else if (tcMain.SelectedTab == tabOptions)
{
@@ -786,26 +790,6 @@ NOTE: installing the service may cause a User Account Control popup.");
}
}
- if (_serviceManager.NvService != null)
- {
- if (_nvDitherPanel == null)
- {
- _nvDitherPanel = new NvDitherPanel(_serviceManager.NvService);
-
- tabOptions.Controls.Add(_nvDitherPanel);
-
- _nvDitherPanel.Top = grpGeneralOptions.Top;
- _nvDitherPanel.Left = grpGeneralOptions.Left + grpGeneralOptions.Width + 4;
- _nvDitherPanel.Width = tabOptions.Width - _nvDitherPanel.Left - 4;
-
- _nvDitherPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- }
- else
- {
- _nvDitherPanel.UpdateInfo();
- }
- }
-
_initialized = false;
try
{
@@ -944,24 +928,8 @@ NOTE: installing the service may cause a User Account Control popup.");
await _samsungPanel?.ApplyPreset(preset);
}
- private void LoadInfo()
- {
- grpNVIDIAInfo.Visible = _serviceManager.NvService != null;
- }
-
private void btnRefreshNVIDIAInfo_Click(object sender, EventArgs e)
{
- if (_serviceManager.NvService != null)
- {
- tvNVIDIAInfo.Nodes.Clear();
- var displays = Display.GetDisplays();
- for (var i = 0; i < displays.Length; i++)
- {
- var display = displays[i];
- var node = TreeNodeBuilder.CreateTree(display, $"Display[{i}]");
- tvNVIDIAInfo.Nodes.Add(node);
- }
- }
}
private void btnSetShortcutScreenSaver_Click(object sender, EventArgs e)
@@ -1063,7 +1031,7 @@ NOTE: installing the service may cause a User Account Control popup.");
{
_updateHtmlUrl = latest.html_url.Value;
- if (latest.assets != null && Utils.IsServiceRunning())
+ if (latest.assets != null && _winApiService.IsServiceRunning())
{
var asset = latest.assets[0];
_downloadUrl = asset.browser_download_url.Value;
@@ -1196,8 +1164,6 @@ NOTE: installing the service may cause a User Account Control popup.");
{
_config.ElevationMethod = elevationMethod;
- Utils.UseDedicatedElevatedProcess = _config.ElevationMethod == ElevationMethod.UseElevatedProcess;
-
var _ = _config.ElevationMethod switch
{
ElevationMethod.None => SetElevationMethodNone(),
@@ -1217,7 +1183,7 @@ NOTE: installing the service may cause a User Account Control popup.");
RegisterScheduledTask();
}
- Utils.UninstallService();
+ _winApiAdminService.UninstallService();
return true;
}
@@ -1230,16 +1196,16 @@ NOTE: installing the service may cause a User Account Control popup.");
RegisterScheduledTask();
}
- Utils.UninstallService();
+ _winApiAdminService.UninstallService();
return true;
}
private bool SetElevationMethodUseService()
{
- Utils.InstallService();
+ _winApiAdminService.InstallService();
- if (Utils.IsServiceInstalled())
+ if (_winApiService.IsServiceInstalled())
{
MessageForms.InfoOk("Service installed successfully.");
return true;
@@ -1257,14 +1223,14 @@ NOTE: installing the service may cause a User Account Control popup.");
RegisterScheduledTask();
}
- Utils.UninstallService();
+ _winApiAdminService.UninstallService();
return true;
}
private void RegisterScheduledTask(bool enabled = true)
{
- Utils.RegisterTask(Program.TS_TASKNAME, enabled, _config.ElevationMethod == ElevationMethod.RunAsAdmin ? Microsoft.Win32.TaskScheduler.TaskRunLevel.Highest : Microsoft.Win32.TaskScheduler.TaskRunLevel.LUA);
+ _winApiAdminService.RegisterTask(Program.TS_TASKNAME, enabled, _config.ElevationMethod == ElevationMethod.RunAsAdmin ? Microsoft.Win32.TaskScheduler.TaskRunLevel.Highest : Microsoft.Win32.TaskScheduler.TaskRunLevel.LUA);
}
private void btnElevationInfo_Click(object sender, EventArgs e)
@@ -1273,7 +1239,7 @@ NOTE: installing the service may cause a User Account Control popup.");
NOTE: if ColorControl itself already runs as administrator this is indicated in the title: ColorControl {Application.ProductVersion} (administrator).
-Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as administrator.
+Currently ColorControl is {(_winApiService.IsAdministrator() ? "" : "not ")}running as administrator.
");
}
@@ -1286,11 +1252,11 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad
if (start)
{
- Utils.StartService();
+ _winApiAdminService.StartService();
}
else
{
- Utils.StopService();
+ _winApiAdminService.StopService();
}
var wait = 1500;
@@ -1299,7 +1265,7 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad
{
await Task.Delay(100);
- if (start == Utils.IsServiceRunning())
+ if (start == _winApiService.IsServiceRunning())
{
break;
}
@@ -1376,11 +1342,9 @@ Currently ColorControl is {(Utils.IsAdministrator() ? "" : "not ")}running as ad
{
_config.FixChromeFonts = chkFixChromeFonts.Checked;
- var param = chkFixChromeFonts.Checked ? StartUpParams.ActivateChromeFontFixParam : StartUpParams.DeactivateChromeFontFixParam;
-
var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- Utils.ExecuteElevated($"{param} {folder}");
+ _winApiAdminService.InstallChromeFix(chkFixChromeFonts.Checked, folder);
}
}
diff --git a/ColorControl/Program.cs b/ColorControl/Program.cs
index e0e16fd..f9d5ae5 100644
--- a/ColorControl/Program.cs
+++ b/ColorControl/Program.cs
@@ -1,13 +1,16 @@
-using ColorControl.Services.Common;
+using ColorControl.Forms;
+using ColorControl.Services.Common;
using ColorControl.Services.EventDispatcher;
using ColorControl.Services.GameLauncher;
using ColorControl.Services.LG;
+using ColorControl.Services.NVIDIA;
using ColorControl.Services.Samsung;
using ColorControl.Shared.Common;
using ColorControl.Shared.Contracts;
using ColorControl.Shared.Native;
using ColorControl.Shared.Services;
using ColorControl.Svc;
+using ColorControl.XForms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
@@ -31,7 +34,7 @@ namespace ColorControl
public static string ConfigFilename { get; private set; }
public static string LogFilename { get; private set; }
public static Config Config { get; private set; }
- public static Shared.Common.AppContext AppContext { get; private set; }
+ public static GlobalContext AppContext { get; private set; }
public static bool IsRestarting { get; private set; }
public static bool UserExit = false;
@@ -59,27 +62,23 @@ namespace ColorControl
//Utils.UpdateFiles(@"H:\temp\ColorControl\ColorControl", @"C:\Users\vinni\source\repos\ColorControl\ColorControl\bin\Debug\net6.0-windows10.0.20348.0");
//Utils.UnZipFile(@"H:\temp\ColorControl\ColorControl.zip", @"H:\temp\ColorControl\temp");
- var runAsService = args.Contains("--service") || Utils.IsAdministrator() && Process.GetCurrentProcess().Parent()?.ProcessName?.Equals("services", StringComparison.InvariantCultureIgnoreCase) == true;
+ var runAsService = args.Contains("--service") || WinApiService.IsAdministratorStatic() && Process.GetCurrentProcess().Parent()?.ProcessName?.Equals("services", StringComparison.InvariantCultureIgnoreCase) == true;
+ var runElevated = args.Contains("--elevated");
- InitLogger(runAsService);
+ InitLogger(runAsService, runElevated);
Logger.Debug($"Using data path: {DataDir}");
//Logger.Debug("Parent process: " + Process.GetCurrentProcess().Parent()?.ProcessName);
- var host = CreateHostBuilder().Build();
- ServiceProvider = host.Services;
-
- var appContextProvider = ServiceProvider.GetRequiredService();
-
if (runAsService)
{
- AppContext = new Shared.Common.AppContext(null, new StartUpParams(), DataDir, _loggingRule);
- appContextProvider.SetAppContext(AppContext);
-
await RunService(args);
return;
}
+ var host = CreateHostBuilder().Build();
+ ServiceProvider = host.Services;
+
var mutexId = $"Global\\{typeof(MainForm).GUID}";
var currentDomain = AppDomain.CurrentDomain;
@@ -90,16 +89,17 @@ namespace ColorControl
LoadConfig();
+ var appContextProvider = ServiceProvider.GetRequiredService();
+ var startUpParams = StartUpParams.Parse(args);
+
+ AppContext = new GlobalContext(Config, startUpParams, DataDir, _loggingRule, mutexId);
+ appContextProvider.SetAppContext(AppContext);
+
if (Config.UseGdiScaling)
{
Application.SetHighDpiMode(HighDpiMode.DpiUnawareGdiScaled);
}
- var startUpParams = StartUpParams.Parse(args);
-
- AppContext = new Shared.Common.AppContext(Config, startUpParams, DataDir, _loggingRule, mutexId);
- appContextProvider.SetAppContext(AppContext);
-
var existingProcess = Utils.GetProcessByName("ColorControl");
try
@@ -145,12 +145,26 @@ namespace ColorControl
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
+ if (Debugger.IsAttached)
+ {
+ var winApiService = ServiceProvider.GetRequiredService();
+
+ if (winApiService.IsAdministrator())
+ {
+ var backgroundService = ServiceProvider.GetRequiredService();
+ backgroundService.PipeName = PipeUtils.ElevatedPipe;
+
+ Task.Run(async () => await backgroundService.StartAsync(CancellationToken.None));
+ }
+ }
+
_mainForm = ServiceProvider.GetRequiredService();
Application.Run(_mainForm);
if (Debugger.IsAttached && !IsRestarting)
{
- Utils.StopService();
+ var winApiAdminService = ServiceProvider.GetRequiredService();
+ winApiAdminService.StopService();
}
}
catch (Exception ex)
@@ -181,12 +195,12 @@ namespace ColorControl
Environment.Exit(0);
}
- private static void InitLogger(bool runAsService)
+ private static void InitLogger(bool runAsService, bool runElevated)
{
var config = new LoggingConfiguration();
// Targets where to log to: File and Console
- var logFileAppendix = runAsService ? "_svc" : "";
+ var logFileAppendix = runAsService ? "_svc" : runElevated ? "_elevated" : "";
LogFilename = Path.Combine(DataDir, $"LogFile{logFileAppendix}.txt");
@@ -220,8 +234,6 @@ namespace ColorControl
}
Config ??= new Config();
- Utils.UseDedicatedElevatedProcess = Config.UseDedicatedElevatedProcess;
-
var minLogLevel = LogLevel.FromString(Config.LogLevel);
if (minLogLevel != LogLevel.Trace)
@@ -245,9 +257,9 @@ namespace ColorControl
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton();
- services.AddTransient();
});
}
private static async Task RunService(string[] args)
@@ -266,6 +278,12 @@ namespace ColorControl
})
.Build();
+ ServiceProvider = host.Services;
+
+ var appContextProvider = ServiceProvider.GetRequiredService();
+ AppContext = new GlobalContext(null, new StartUpParams(), DataDir, _loggingRule);
+ appContextProvider.SetAppContext(AppContext);
+
await host.RunAsync();
}
@@ -273,6 +291,17 @@ namespace ColorControl
{
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+
+ RpcServerService.ServiceTypes.Add(typeof(NvService));
}
public static int EnumThreadWindows(IntPtr handle, IntPtr param)
diff --git a/ColorControl/Services/AMD/AmdPanel.cs b/ColorControl/Services/AMD/AmdPanel.cs
index db5973d..cee18e4 100644
--- a/ColorControl/Services/AMD/AmdPanel.cs
+++ b/ColorControl/Services/AMD/AmdPanel.cs
@@ -30,7 +30,7 @@ namespace ColorControl.Services.AMD
_trayIcon = trayIcon;
_mainHandle = handle;
- _config = Shared.Common.AppContext.CurrentContext.Config;
+ _config = Shared.Common.GlobalContext.CurrentContext.Config;
InitializeComponent();
@@ -127,7 +127,7 @@ namespace ColorControl.Services.AMD
private async Task ApplyAmdPresetOnStartup(int attempts = 5)
{
- var startUpParams = Shared.Common.AppContext.CurrentContext.StartUpParams;
+ var startUpParams = Shared.Common.GlobalContext.CurrentContext.StartUpParams;
var presetIdOrName = !string.IsNullOrEmpty(startUpParams.AmdPresetIdOrName) ? startUpParams.AmdPresetIdOrName : _config.AmdPresetId_ApplyOnStartup.ToString();
if (!string.IsNullOrEmpty(presetIdOrName))
diff --git a/ColorControl/Services/Common/ServiceManager.cs b/ColorControl/Services/Common/ServiceManager.cs
index 5935686..9132e46 100644
--- a/ColorControl/Services/Common/ServiceManager.cs
+++ b/ColorControl/Services/Common/ServiceManager.cs
@@ -3,70 +3,76 @@ using ColorControl.Services.GameLauncher;
using ColorControl.Services.LG;
using ColorControl.Services.NVIDIA;
using ColorControl.Services.Samsung;
-using ColorControl.Shared.Common;
+using ColorControl.Shared.Services;
using System;
using System.Linq;
using System.Threading.Tasks;
-namespace ColorControl.Services.Common
+namespace ColorControl.Services.Common;
+
+public class ServiceManager
{
- public class ServiceManager
+ private readonly WinApiAdminService _winApiAdminService;
+
+ internal NvService NvService { get; set; }
+ internal LgService LgService { get; set; }
+ internal AmdService AmdService { get; set; }
+ internal GameService GameService { get; set; }
+ internal SamsungService SamsungService { get; set; }
+
+ public ServiceManager(WinApiAdminService winApiAdminService)
{
- internal NvService NvService { get; set; }
- internal LgService LgService { get; set; }
- internal AmdService AmdService { get; set; }
- internal GameService GameService { get; set; }
- internal SamsungService SamsungService { get; set; }
+ _winApiAdminService = winApiAdminService;
+ }
- public async Task HandleExternalServiceAsync(string serviceName, string[] parameters)
+ public async Task HandleExternalServiceAsync(string serviceName, string[] parameters)
+ {
+ if (string.IsNullOrEmpty(serviceName) || parameters.Length == 0)
{
- if (string.IsNullOrEmpty(serviceName) || parameters.Length == 0)
- {
- return false;
- }
-
- if (NvService != null && serviceName.Equals("NvPreset", StringComparison.OrdinalIgnoreCase))
- {
- return await NvService.ApplyPreset(parameters[0]);
- }
- if (NvService != null && serviceName.Equals("GsyncEnabled", StringComparison.OrdinalIgnoreCase))
- {
- return NvService.IsGsyncEnabled();
- }
- if (AmdService != null && serviceName.Equals("AmdPreset", StringComparison.OrdinalIgnoreCase))
- {
- return await AmdService.ApplyPreset(parameters[0]);
- }
- if (LgService != null && serviceName.Equals("LgPreset", StringComparison.OrdinalIgnoreCase))
- {
- await LgService.ApplyPreset(parameters[0]);
-
- return true;
- }
- if (SamsungService != null && serviceName.Equals("SamsungPreset", StringComparison.OrdinalIgnoreCase))
- {
- await SamsungService.ApplyPreset(parameters[0]);
-
- return true;
- }
-
- if (serviceName.Equals("StartProgram", StringComparison.OrdinalIgnoreCase))
- {
- Utils.StartProcess(parameters[0], parameters.Length > 1 ? string.Join(" ", parameters.Skip(1)) : null, setWorkingDir: true);
-
- return true;
- }
-
return false;
}
- public void Save()
+ if (NvService != null && serviceName.Equals("NvPreset", StringComparison.OrdinalIgnoreCase))
{
- NvService?.GlobalSave();
- AmdService?.GlobalSave();
- LgService?.GlobalSave();
- GameService?.GlobalSave();
- SamsungService?.GlobalSave();
+ return await NvService.ApplyPreset(parameters[0]);
}
+ if (NvService != null && serviceName.Equals("GsyncEnabled", StringComparison.OrdinalIgnoreCase))
+ {
+ return NvService.IsGsyncEnabled();
+ }
+ if (AmdService != null && serviceName.Equals("AmdPreset", StringComparison.OrdinalIgnoreCase))
+ {
+ return await AmdService.ApplyPreset(parameters[0]);
+ }
+ if (LgService != null && serviceName.Equals("LgPreset", StringComparison.OrdinalIgnoreCase))
+ {
+ await LgService.ApplyPreset(parameters[0]);
+
+ return true;
+ }
+ if (SamsungService != null && serviceName.Equals("SamsungPreset", StringComparison.OrdinalIgnoreCase))
+ {
+ await SamsungService.ApplyPreset(parameters[0]);
+
+ return true;
+ }
+
+ if (serviceName.Equals("StartProgram", StringComparison.OrdinalIgnoreCase))
+ {
+ _winApiAdminService.StartProcess(parameters[0], parameters.Length > 1 ? string.Join(" ", parameters.Skip(1)) : null, setWorkingDir: true);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public void Save()
+ {
+ NvService?.GlobalSave();
+ AmdService?.GlobalSave();
+ LgService?.GlobalSave();
+ GameService?.GlobalSave();
+ SamsungService?.GlobalSave();
}
}
diff --git a/ColorControl/Services/EventDispatcher/EventDispatcher.cs b/ColorControl/Services/EventDispatcher/EventDispatcher.cs
index 71476da..38b1a07 100644
--- a/ColorControl/Services/EventDispatcher/EventDispatcher.cs
+++ b/ColorControl/Services/EventDispatcher/EventDispatcher.cs
@@ -16,6 +16,10 @@ public class EventDispatcher where T : EventArgs
{
eventHandlers.Add(eventName, eventHandler);
}
+ else
+ {
+ eventHandlers[eventName] += eventHandler;
+ }
}
public void RegisterAsyncEventHandler(string eventName, AsyncEventHandler eventHandler)
@@ -24,6 +28,10 @@ public class EventDispatcher where T : EventArgs
{
asyncEventHandlers.Add(eventName, eventHandler);
}
+ else
+ {
+ asyncEventHandlers[eventName] += eventHandler;
+ }
}
public void UnregisterEventHandler(string eventName)
diff --git a/ColorControl/Services/EventDispatcher/ProcessEventDispatcher.cs b/ColorControl/Services/EventDispatcher/ProcessEventDispatcher.cs
index f24ef92..8069665 100644
--- a/ColorControl/Services/EventDispatcher/ProcessEventDispatcher.cs
+++ b/ColorControl/Services/EventDispatcher/ProcessEventDispatcher.cs
@@ -28,10 +28,10 @@ namespace ColorControl.Services.EventDispatcher
{
public const string Event_ProcessChanged = "ProcessChanged";
public bool IsRunning { get; set; }
+ public ProcessChangedEventArgs MonitorContext { get; private set; }
protected static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
- private ProcessChangedEventArgs MonitorContext { get; set; }
private AppContextProvider _appContextProvider { get; }
public ProcessEventDispatcher(AppContextProvider appContextProvider)
@@ -88,6 +88,8 @@ namespace ColorControl.Services.EventDispatcher
{
var processes = Process.GetProcesses();
+ context.StartedProcesses = processes.Where(p => context.RunningProcesses?.Any(rp => rp.Id == p.Id) == false).ToList();
+ context.StoppedProcesses = context.RunningProcesses?.Where(p => processes.Any(rp => rp.Id == p.Id) == false).ToList();
context.RunningProcesses = processes;
context.IsNotificationDisabled = FormUtils.IsNotificationDisabled();
diff --git a/ColorControl/Services/GameLauncher/GamePanel.Designer.cs b/ColorControl/Services/GameLauncher/GamePanel.Designer.cs
index 65b36be..e8c96ac 100644
--- a/ColorControl/Services/GameLauncher/GamePanel.Designer.cs
+++ b/ColorControl/Services/GameLauncher/GamePanel.Designer.cs
@@ -34,6 +34,7 @@
mnuGameOptions = new System.Windows.Forms.ContextMenuStrip(components);
miGameProcessorAffinity = new System.Windows.Forms.ToolStripMenuItem();
miGameProcessPriority = new System.Windows.Forms.ToolStripMenuItem();
+ miPresetNVIDIAProfileInspector = new System.Windows.Forms.ToolStripMenuItem();
chkGameQuickAccess = new System.Windows.Forms.CheckBox();
btnGameSettings = new System.Windows.Forms.Button();
mnuGameActions = new System.Windows.Forms.ContextMenuStrip(components);
@@ -51,6 +52,7 @@
mnuGameNvidiaPresets = new System.Windows.Forms.ToolStripMenuItem();
mnuGameAmdPresets = new System.Windows.Forms.ToolStripMenuItem();
mnuGameLgPresets = new System.Windows.Forms.ToolStripMenuItem();
+ mnuGameSamsungPresets = new System.Windows.Forms.ToolStripMenuItem();
mnuGameStartProgram = new System.Windows.Forms.ToolStripMenuItem();
label4 = new System.Windows.Forms.Label();
edtGameName = new System.Windows.Forms.TextBox();
@@ -60,7 +62,7 @@
btnGameAdd = new System.Windows.Forms.Button();
btnGameLaunch = new System.Windows.Forms.Button();
lvGamePresets = new System.Windows.Forms.ListView();
- mnuGameSamsungPresets = new System.Windows.Forms.ToolStripMenuItem();
+ miGameOptionsAutoApplySettings = new System.Windows.Forms.ToolStripMenuItem();
mnuGameOptions.SuspendLayout();
mnuGameActions.SuspendLayout();
mnuGameAddStep.SuspendLayout();
@@ -96,24 +98,31 @@
// mnuGameOptions
//
mnuGameOptions.ImageScalingSize = new System.Drawing.Size(20, 20);
- mnuGameOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miGameProcessorAffinity, miGameProcessPriority });
+ mnuGameOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miGameProcessorAffinity, miGameProcessPriority, miPresetNVIDIAProfileInspector, miGameOptionsAutoApplySettings });
mnuGameOptions.Name = "mnuLgButtons";
- mnuGameOptions.Size = new System.Drawing.Size(166, 48);
+ mnuGameOptions.Size = new System.Drawing.Size(202, 114);
//
// miGameProcessorAffinity
//
miGameProcessorAffinity.Name = "miGameProcessorAffinity";
- miGameProcessorAffinity.Size = new System.Drawing.Size(165, 22);
+ miGameProcessorAffinity.Size = new System.Drawing.Size(201, 22);
miGameProcessorAffinity.Text = "Processor affinity";
miGameProcessorAffinity.Click += btnGameProcessAffinity_Click;
//
// miGameProcessPriority
//
miGameProcessPriority.Name = "miGameProcessPriority";
- miGameProcessPriority.Size = new System.Drawing.Size(165, 22);
+ miGameProcessPriority.Size = new System.Drawing.Size(201, 22);
miGameProcessPriority.Text = "Process priority";
miGameProcessPriority.Click += miGameProcessPriority_Click;
//
+ // miPresetNVIDIAProfileInspector
+ //
+ miPresetNVIDIAProfileInspector.Name = "miPresetNVIDIAProfileInspector";
+ miPresetNVIDIAProfileInspector.Size = new System.Drawing.Size(201, 22);
+ miPresetNVIDIAProfileInspector.Text = "NVIDIA Profile Inspector";
+ miPresetNVIDIAProfileInspector.Click += miPresetNVIDIAProfileInspector_Click;
+ //
// chkGameQuickAccess
//
chkGameQuickAccess.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
@@ -145,21 +154,21 @@
mnuGameActions.ImageScalingSize = new System.Drawing.Size(20, 20);
mnuGameActions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuGameNvInspector, miGameSetQuickAccessShortcut });
mnuGameActions.Name = "mnuLgButtons";
- mnuGameActions.Size = new System.Drawing.Size(212, 48);
+ mnuGameActions.Size = new System.Drawing.Size(202, 48);
mnuGameActions.Opening += mnuGameActions_Opening;
//
// mnuGameNvInspector
//
mnuGameNvInspector.Name = "mnuGameNvInspector";
- mnuGameNvInspector.Size = new System.Drawing.Size(211, 22);
+ mnuGameNvInspector.Size = new System.Drawing.Size(201, 22);
mnuGameNvInspector.Text = "NVIDIA Profile Inspector";
mnuGameNvInspector.Click += mnuGameNvInspector_Click;
//
// miGameSetQuickAccessShortcut
//
miGameSetQuickAccessShortcut.Name = "miGameSetQuickAccessShortcut";
- miGameSetQuickAccessShortcut.Size = new System.Drawing.Size(211, 22);
- miGameSetQuickAccessShortcut.Text = "Set Quick Access Shortcut";
+ miGameSetQuickAccessShortcut.Size = new System.Drawing.Size(201, 22);
+ miGameSetQuickAccessShortcut.Text = "Settings...";
miGameSetQuickAccessShortcut.Click += miGameSetQuickAccessShortcut_Click;
//
// chkGameRunAsAdmin
@@ -261,31 +270,37 @@
mnuGameAddStep.ImageScalingSize = new System.Drawing.Size(20, 20);
mnuGameAddStep.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuGameNvidiaPresets, mnuGameAmdPresets, mnuGameLgPresets, mnuGameSamsungPresets, mnuGameStartProgram });
mnuGameAddStep.Name = "mnuLgButtons";
- mnuGameAddStep.Size = new System.Drawing.Size(181, 136);
+ mnuGameAddStep.Size = new System.Drawing.Size(164, 114);
mnuGameAddStep.Opening += mnuGameAddStep_Opening;
//
// mnuGameNvidiaPresets
//
mnuGameNvidiaPresets.Name = "mnuGameNvidiaPresets";
- mnuGameNvidiaPresets.Size = new System.Drawing.Size(180, 22);
+ mnuGameNvidiaPresets.Size = new System.Drawing.Size(163, 22);
mnuGameNvidiaPresets.Text = "NVIDIA presets";
//
// mnuGameAmdPresets
//
mnuGameAmdPresets.Name = "mnuGameAmdPresets";
- mnuGameAmdPresets.Size = new System.Drawing.Size(180, 22);
+ mnuGameAmdPresets.Size = new System.Drawing.Size(163, 22);
mnuGameAmdPresets.Text = "AMD presets";
//
// mnuGameLgPresets
//
mnuGameLgPresets.Name = "mnuGameLgPresets";
- mnuGameLgPresets.Size = new System.Drawing.Size(180, 22);
+ mnuGameLgPresets.Size = new System.Drawing.Size(163, 22);
mnuGameLgPresets.Text = "LG presets";
//
+ // mnuGameSamsungPresets
+ //
+ mnuGameSamsungPresets.Name = "mnuGameSamsungPresets";
+ mnuGameSamsungPresets.Size = new System.Drawing.Size(163, 22);
+ mnuGameSamsungPresets.Text = "Samsung presets";
+ //
// mnuGameStartProgram
//
mnuGameStartProgram.Name = "mnuGameStartProgram";
- mnuGameStartProgram.Size = new System.Drawing.Size(180, 22);
+ mnuGameStartProgram.Size = new System.Drawing.Size(163, 22);
mnuGameStartProgram.Text = "Start Program";
mnuGameStartProgram.Click += mnuGameStartProgram_Click;
//
@@ -379,6 +394,7 @@
lvGamePresets.AllowDrop = true;
lvGamePresets.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
lvGamePresets.CheckBoxes = true;
+ lvGamePresets.ContextMenuStrip = mnuGameOptions;
lvGamePresets.FullRowSelect = true;
lvGamePresets.Location = new System.Drawing.Point(8, 8);
lvGamePresets.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
@@ -396,11 +412,12 @@
lvGamePresets.DragEnter += lvGamePresets_DragEnter;
lvGamePresets.DoubleClick += lvGamePresets_DoubleClick;
//
- // mnuGameSamsungPresets
+ // miGameOptionsAutoApplySettings
//
- mnuGameSamsungPresets.Name = "mnuGameSamsungPresets";
- mnuGameSamsungPresets.Size = new System.Drawing.Size(180, 22);
- mnuGameSamsungPresets.Text = "Samsung presets";
+ miGameOptionsAutoApplySettings.Name = "miGameOptionsAutoApplySettings";
+ miGameOptionsAutoApplySettings.Size = new System.Drawing.Size(201, 22);
+ miGameOptionsAutoApplySettings.Text = "Auto apply settings...";
+ miGameOptionsAutoApplySettings.Click += miGameOptionsAutoApplySettings_Click;
//
// GamePanel
//
@@ -470,5 +487,7 @@
private System.Windows.Forms.ToolStripMenuItem miGameProcessPriority;
private System.Windows.Forms.ComboBox cbxGameStepType;
private System.Windows.Forms.ToolStripMenuItem mnuGameSamsungPresets;
+ private System.Windows.Forms.ToolStripMenuItem miPresetNVIDIAProfileInspector;
+ private System.Windows.Forms.ToolStripMenuItem miGameOptionsAutoApplySettings;
}
}
diff --git a/ColorControl/Services/GameLauncher/GamePanel.cs b/ColorControl/Services/GameLauncher/GamePanel.cs
index c8b9742..a153796 100644
--- a/ColorControl/Services/GameLauncher/GamePanel.cs
+++ b/ColorControl/Services/GameLauncher/GamePanel.cs
@@ -43,7 +43,7 @@ namespace ColorControl.Services.GameLauncher
_amdService = amdService;
_lgService = lgService;
_samsungService = samsungService;
- _config = Shared.Common.AppContext.CurrentContext.Config;
+ _config = Shared.Common.GlobalContext.CurrentContext.Config;
InitializeComponent();
@@ -139,7 +139,7 @@ namespace ColorControl.Services.GameLauncher
var preset = GetSelectedGamePreset();
var enabled = preset != null;
- FormUtils.EnableControls(this, enabled, new List { lvGamePresets, btnGameAdd });
+ FormUtils.EnableControls(this, enabled, new List { lvGamePresets, btnGameAdd, btnGameSettings });
if (preset != null)
{
@@ -361,16 +361,44 @@ namespace ColorControl.Services.GameLauncher
private void miGameSetQuickAccessShortcut_Click(object sender, EventArgs e)
{
- var shortcut = FormUtils.EditShortcut(_config.GameQuickAccessShortcut);
+ EditGameSettings();
+ }
- if (shortcut == null)
+ private void EditGameSettings()
+ {
+ var quickAccessField = new FieldDefinition
+ {
+ Label = "Quick Access shortcut",
+ FieldType = FieldType.Shortcut,
+ Value = _config.GameQuickAccessShortcut
+ };
+
+ var applyExternallyLaunched = new FieldDefinition
+ {
+ Label = "Apply presets when launching games externally",
+ SubLabel = "This will monitor processes and automatically apply the preset whenever a known game is launched",
+ FieldType = FieldType.CheckBox,
+ Value = _gameService.Config.ApplyExternallyLaunched
+ };
+
+ var values = MessageForms.ShowDialog("Game launcher settings", new[] {
+ quickAccessField,
+ applyExternallyLaunched
+ });
+ if (!values.Any())
{
return;
}
+ var shortcut = (string)quickAccessField.Value;
+
_config.GameQuickAccessShortcut = shortcut;
KeyboardShortcutManager.RegisterShortcut(SHORTCUTID_GAMEQA, _config.GameQuickAccessShortcut);
+
+ _gameService.Config.ApplyExternallyLaunched = applyExternallyLaunched.ValueAsBool;
+
+ UpdateInfo();
}
private void mnuGameActions_Opening(object sender, CancelEventArgs e)
@@ -490,5 +518,52 @@ namespace ColorControl.Services.GameLauncher
{
FormUtils.ListViewSort(sender, e);
}
+
+ private void miPresetNVIDIAProfileInspector_Click(object sender, EventArgs e)
+ {
+ var form = new frmDrvSettings();
+ form.Show();
+
+ var preset = GetSelectedGamePreset();
+
+ var executable = Path.GetFileName(preset.Path);
+
+ form.SetProfileByExecutable(executable);
+ }
+
+ private void miGameOptionsAutoApplySettings_Click(object sender, EventArgs e)
+ {
+ var preset = GetSelectedGamePreset();
+
+ var allowAutoApplyField = new FieldDefinition
+ {
+ Label = "Allow this preset to be automatically executed when the process starts",
+ FieldType = FieldType.CheckBox,
+ Value = preset.AutoSettings.AllowAutoApply
+ };
+
+ var processActions = new[] { ProcessAutoAction.None, ProcessAutoAction.Suspend }.Select(t => Utils.GetDescription(t));
+
+ var processActionField = new FieldDefinition
+ {
+ Label = "Optional action to perform directly after the process starts",
+ SubLabel = "Temporarily suspending the process may help when enabling/disabling HDR or other settings",
+ FieldType = FieldType.DropDown,
+ Values = processActions,
+ Value = preset.AutoSettings.ProcessAutoAction
+ };
+
+ var values = MessageForms.ShowDialog("Auto apply settings", new[] {
+ allowAutoApplyField,
+ processActionField
+ });
+ if (!values.Any())
+ {
+ return;
+ }
+
+ preset.AutoSettings.AllowAutoApply = allowAutoApplyField.ValueAsBool;
+ preset.AutoSettings.ProcessAutoAction = processActionField.ValueAsEnum();
+ }
}
}
diff --git a/ColorControl/Services/GameLauncher/GamePanel.resx b/ColorControl/Services/GameLauncher/GamePanel.resx
index 568ff43..cb6c59a 100644
--- a/ColorControl/Services/GameLauncher/GamePanel.resx
+++ b/ColorControl/Services/GameLauncher/GamePanel.resx
@@ -18,7 +18,7 @@
System.Resources.ResXResourceReader, System.Windows.Forms, ...
System.Resources.ResXResourceWriter, System.Windows.Forms, ...
this is my long stringthis is a comment
- Blue
+ Blue
[base64 mime encoded serialized .NET Framework object]
diff --git a/ColorControl/Services/GameLauncher/GamePreset.cs b/ColorControl/Services/GameLauncher/GamePreset.cs
index 12f51e7..8dd6266 100644
--- a/ColorControl/Services/GameLauncher/GamePreset.cs
+++ b/ColorControl/Services/GameLauncher/GamePreset.cs
@@ -26,6 +26,19 @@ namespace ColorControl.Services.GameLauncher
RealTime = NativeConstants.REALTIME_PRIORITY_CLASS
}
+ public enum ProcessAutoAction
+ {
+ None = 0,
+ Suspend = 1,
+ Restart = 2
+ }
+
+ class AutoSettings
+ {
+ public bool AllowAutoApply { get; set; }
+ public ProcessAutoAction ProcessAutoAction { get; set; }
+ }
+
class GamePreset : PresetBase
{
public string Path { get; set; }
@@ -36,12 +49,14 @@ namespace ColorControl.Services.GameLauncher
public List FinalizeSteps { get; set; }
public uint ProcessAffinityMask { get; set; }
public uint ProcessPriorityClass { get; set; }
+ public AutoSettings AutoSettings { get; set; }
public GamePreset() : base()
{
PreLaunchSteps = new List();
PostLaunchSteps = new List();
FinalizeSteps = new List();
+ AutoSettings = new AutoSettings();
}
public GamePreset(GamePreset preset) : this()
@@ -73,15 +88,16 @@ namespace ColorControl.Services.GameLauncher
public override List GetDisplayValues(Config config = null)
{
- var values = new List();
+ var values = new List
+ {
+ name,
+ Path,
+ Parameters,
- values.Add(name);
- values.Add(Path);
- values.Add(Parameters);
-
- values.Add(string.Join(", ", PreLaunchSteps));
- values.Add(string.Join(", ", PostLaunchSteps));
- values.Add(string.Join(", ", FinalizeSteps));
+ string.Join(", ", PreLaunchSteps),
+ string.Join(", ", PostLaunchSteps),
+ string.Join(", ", FinalizeSteps)
+ };
return values;
}
diff --git a/ColorControl/Services/GameLauncher/GameService.cs b/ColorControl/Services/GameLauncher/GameService.cs
index 88657e8..cf4db42 100644
--- a/ColorControl/Services/GameLauncher/GameService.cs
+++ b/ColorControl/Services/GameLauncher/GameService.cs
@@ -1,27 +1,120 @@
using ColorControl.Services.Common;
+using ColorControl.Services.EventDispatcher;
using ColorControl.Shared.Common;
using ColorControl.Shared.Services;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
namespace ColorControl.Services.GameLauncher
{
class GameService : ServiceBase
{
- //private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
+ private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
public override string ServiceName => "Game";
protected override string PresetsBaseFilename => "GamePresets.json";
+ private ProcessEventDispatcher _processEventDispatcher;
+ private readonly WinApiAdminService _winApiAdminService;
+ private readonly WinApiService _winApiService;
private ServiceManager _serviceManager;
+ private int _lastStartedProcessId;
+ private System.DateTime _lastStartedPresetDateTime = System.DateTime.MinValue;
+ private string _lastStartedProcessPath;
+ private string _configFilename;
- public GameService(AppContextProvider appContextProvider, ServiceManager serviceManager) : base(appContextProvider)
+ public GameServiceConfig Config { get; private set; }
+
+ public GameService(AppContextProvider appContextProvider, ServiceManager serviceManager, ProcessEventDispatcher processEventDispatcher, WinApiAdminService winApiAdminService, WinApiService winApiService) : base(appContextProvider)
{
+ LoadConfig();
LoadPresets();
_serviceManager = serviceManager;
+ _processEventDispatcher = processEventDispatcher;
+ _winApiAdminService = winApiAdminService;
+ _winApiService = winApiService;
+ _processEventDispatcher.RegisterAsyncEventHandler(ProcessEventDispatcher.Event_ProcessChanged, ProcessChanged);
+ }
+
+ private async Task ProcessChanged(object sender, ProcessChangedEventArgs e, CancellationToken token)
+ {
+ if (e.StartedProcesses?.Any() != true || !Config.ApplyExternallyLaunched)
+ {
+ return;
+ }
+
+ if (_lastStartedPresetDateTime > System.DateTime.Now.AddSeconds(-5))
+ {
+ return;
+ }
+ _lastStartedProcessId = 0;
+
+ var startedProcesses = e.StartedProcesses;
+
+ foreach (var startedProcess in startedProcesses)
+ {
+ try
+ {
+ if (await HandleStartedProcess(startedProcess))
+ {
+ return;
+ }
+ }
+ catch (System.Exception) { }
+ }
+ }
+
+ private async Task HandleStartedProcess(Process process)
+ {
+ GamePreset preset;
+
+ if (_winApiService.IsAdministrator())
+ {
+ var fileName = process.MainModule.FileName;
+
+ preset = _presets.FirstOrDefault(p => fileName.Contains(Path.GetDirectoryName(p.Path), System.StringComparison.OrdinalIgnoreCase));
+ }
+ else
+ {
+ var name = process.ProcessName.Replace("-Win64-Shipping", "");
+ preset = _presets.FirstOrDefault(p => Path.GetFileName(p.Path).Contains(name, System.StringComparison.OrdinalIgnoreCase));
+ }
+
+ if (preset == null || !preset.AutoSettings.AllowAutoApply)
+ {
+ return false;
+ }
+
+ if (_lastStartedProcessId != process.Id)
+ {
+ Logger.Debug($"Auto-starting preset {preset.name} for process {process.ProcessName}");
+
+ var mainThreadId = 0;
+ var suspended = false;
+ if (preset.AutoSettings.ProcessAutoAction == ProcessAutoAction.Suspend)
+ {
+ mainThreadId = _winApiAdminService.SuspendMainThread(process.Id);
+ suspended = true;
+ }
+ else if (preset.AutoSettings.ProcessAutoAction == ProcessAutoAction.Restart)
+ {
+ _winApiAdminService.StopProcess(process.Id);
+ process = null;
+ }
+
+ var _ = ExecutePreset(preset, process, suspended ? mainThreadId : 0);
+
+ return true;
+ }
+
+ return false;
}
protected override List GetDefaultPresets()
@@ -37,6 +130,7 @@ namespace ColorControl.Services.GameLauncher
public void GlobalSave()
{
SavePresets();
+ SaveConfig();
}
public async Task ApplyPreset(string idOrName)
@@ -57,17 +151,34 @@ namespace ColorControl.Services.GameLauncher
return await ApplyPreset(preset, Program.AppContext);
}
- public async Task ApplyPreset(GamePreset preset, AppContext appContext)
+ public async Task ApplyPreset(GamePreset preset, GlobalContext _)
+ {
+ var result = await ExecutePreset(preset);
+
+ _lastAppliedPreset = preset;
+
+ PresetApplied();
+
+ return result;
+ }
+
+ private async Task ExecutePreset(GamePreset preset, Process process = null, int resumeThreadId = default)
{
var result = true;
await ExecuteSteps(preset.PreLaunchSteps);
- Process process = null;
-
- if (!string.IsNullOrEmpty(preset.Path))
+ if (process == null && !string.IsNullOrEmpty(preset.Path))
{
- process = Utils.StartProcess(preset.Path, preset.Parameters, setWorkingDir: true, elevate: preset.RunAsAdministrator, affinityMask: preset.ProcessAffinityMask, priorityClass: preset.ProcessPriorityClass);
+ process = _winApiAdminService.StartProcess(preset.Path, preset.Parameters, setWorkingDir: true, elevate: preset.RunAsAdministrator, affinityMask: preset.ProcessAffinityMask, priorityClass: preset.ProcessPriorityClass);
+
+ _lastStartedPresetDateTime = System.DateTime.Now;
+ _lastStartedProcessId = process.Id;
+ _lastStartedProcessPath = Path.GetDirectoryName(preset.Path);
+ }
+ else if (resumeThreadId != default)
+ {
+ _winApiAdminService.ResumeThread((uint)resumeThreadId);
}
await ExecuteSteps(preset.PostLaunchSteps);
@@ -77,16 +188,27 @@ namespace ColorControl.Services.GameLauncher
await ExecuteFinalizationStepsAsync(process, preset.FinalizeSteps);
}
- _lastAppliedPreset = preset;
-
- PresetApplied();
-
return result;
}
private async Task ExecuteFinalizationStepsAsync(Process process, List finalizeSteps)
{
- await process.WaitForExitAsync();
+ await Task.Delay(1000);
+
+ try
+ {
+ if (process.HasExited)
+ {
+ return;
+ }
+
+ await process.WaitForExitAsync();
+ }
+ catch (Exception ex)
+ {
+ Logger.Error(ex);
+ return;
+ }
await ExecuteSteps(finalizeSteps);
}
@@ -140,5 +262,27 @@ namespace ColorControl.Services.GameLauncher
}
}
+
+ private void LoadConfig()
+ {
+ _configFilename = Path.Combine(_dataPath, "GameConfig.json");
+ try
+ {
+ if (File.Exists(_configFilename))
+ {
+ Config = JsonConvert.DeserializeObject(File.ReadAllText(_configFilename));
+ }
+ }
+ catch (System.Exception ex)
+ {
+ Logger.Error($"LoadConfig: {ex.Message}");
+ }
+ Config ??= new GameServiceConfig();
+ }
+
+ private void SaveConfig()
+ {
+ Utils.WriteObject(_configFilename, Config);
+ }
}
}
diff --git a/ColorControl/Services/GameLauncher/GameServiceConfig.cs b/ColorControl/Services/GameLauncher/GameServiceConfig.cs
new file mode 100644
index 0000000..f65dd71
--- /dev/null
+++ b/ColorControl/Services/GameLauncher/GameServiceConfig.cs
@@ -0,0 +1,11 @@
+namespace ColorControl.Services.GameLauncher
+{
+ class GameServiceConfig
+ {
+ public bool ApplyExternallyLaunched { get; set; }
+
+ public GameServiceConfig()
+ {
+ }
+ }
+}
diff --git a/ColorControl/Services/LG/LgDevice.cs b/ColorControl/Services/LG/LgDevice.cs
index 6a8f18d..e7a846a 100644
--- a/ColorControl/Services/LG/LgDevice.cs
+++ b/ColorControl/Services/LG/LgDevice.cs
@@ -1,5 +1,6 @@
using ColorControl.Services.Common;
using ColorControl.Shared.Common;
+using ColorControl.Shared.Services;
using LgTv;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
@@ -262,8 +263,10 @@ namespace ColorControl.Services.LG
AddSetDeviceConfigAction("HDMI_4_icon", typeof(HdmiIcon), "HDMI 4 icon");
AddGenericPictureAction("soundMode", typeof(SoundMode), category: "sound", title: "Sound Mode");
+ AddGenericPictureAction("smartSoundMode", typeof(OffToOn), category: "sound", title: "Adaptive Sound Control");
AddGenericPictureAction("soundOutput", typeof(SoundOutput), category: "sound", title: "Sound Output");
AddGenericPictureAction("autoVolume", typeof(OffToOn), category: "sound", title: "Auto Volume");
+ AddGenericPictureAction("virtualSurround", typeof(OffToOn), category: "sound", title: "Virtual Surround");
//AddGenericPictureAction("enableToastPopup", typeof(OffToOn), category: "option", title: "enableToastPopup");
AddSetConfigAction("tv.conti.supportUsedTime", typeof(BoolFalseToTrue), title: "Total Power On Time");
@@ -917,7 +920,9 @@ namespace ColorControl.Services.LG
if (MacAddress != null)
{
- result = WOL.WakeFunctionCheckAdmin(MacAddress, IpAddress);
+ var wolService = Program.ServiceProvider.GetRequiredService();
+
+ result = wolService.SendWol(MacAddress, IpAddress);
_justWokeUp = true;
}
else
diff --git a/ColorControl/Services/LG/LgGameBar.cs b/ColorControl/Services/LG/LgGameBar.cs
index 0d33699..d8b2420 100644
--- a/ColorControl/Services/LG/LgGameBar.cs
+++ b/ColorControl/Services/LG/LgGameBar.cs
@@ -263,7 +263,7 @@ namespace ColorControl.Services.LG
private void UpdateInfo()
{
lblTvName.Text = $"Device: {_lgDevice?.Name ?? "No tv selected"}";
- lblProcessName.Text = $"Current process: {_lgService.MonitorContext?.ForegroundProcess?.ProcessName ?? _lgService.MonitorContext?.LastFullScreenProcessName ?? "No full screen process"}";
+ lblProcessName.Text = $"Current process: {_lgService.CurrentProcessEvent?.ForegroundProcess?.ProcessName ?? _lgService.CurrentProcessEvent?.LastFullScreenProcessName ?? "No full screen process"}";
UpdateValues();
}
diff --git a/ColorControl/Services/LG/LgPanel.cs b/ColorControl/Services/LG/LgPanel.cs
index 295d908..551ac9e 100644
--- a/ColorControl/Services/LG/LgPanel.cs
+++ b/ColorControl/Services/LG/LgPanel.cs
@@ -43,7 +43,7 @@ namespace ColorControl.Services.LG
_trayIcon = trayIcon;
_mainHandle = handle;
- _config = Shared.Common.AppContext.CurrentContext.Config;
+ _config = Shared.Common.GlobalContext.CurrentContext.Config;
InitializeComponent();
@@ -96,7 +96,7 @@ namespace ColorControl.Services.LG
{
FillLgDevices();
- var startUpParams = Shared.Common.AppContext.CurrentContext.StartUpParams;
+ var startUpParams = Shared.Common.GlobalContext.CurrentContext.StartUpParams;
if (startUpParams.ExecuteLgPreset)
{
diff --git a/ColorControl/Services/LG/LgService.cs b/ColorControl/Services/LG/LgService.cs
index 0130ea2..04a9368 100644
--- a/ColorControl/Services/LG/LgService.cs
+++ b/ColorControl/Services/LG/LgService.cs
@@ -22,19 +22,6 @@ namespace ColorControl.Services.LG
{
class LgService : ServiceBase
{
- internal class ProcessMonitorContext
- {
- public List Devices { get; set; }
- public bool WasFullScreen { get; set; }
- public Process[] StartedProcesses { get; set; }
- public Process[] StoppedProcesses { get; set; }
- public Process[] RunningProcesses { get; set; }
- public bool IsNotificationDisabled { get; set; }
- public Process ForegroundProcess { get; set; }
- public bool ForegroundProcessIsFullScreen { get; set; }
- public string LastFullScreenProcessName = string.Empty;
- }
-
protected static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
public static string LgListAppsJson = "listApps.json";
@@ -56,7 +43,6 @@ namespace ColorControl.Services.LG
public event EventHandler SelectedDeviceChangedEvent;
public LgServiceConfig Config { get; private set; }
- public ProcessMonitorContext MonitorContext { get; private set; }
protected override string PresetsBaseFilename => "LgPresets.json";
@@ -75,9 +61,13 @@ namespace ColorControl.Services.LG
private int _poweredOffByScreenSaverProcessId;
private LgPreset _lastTriggeredPreset;
private RestartDetector _restartDetector;
+ private readonly WinApiService _winApiService;
+ private readonly WinApiAdminService _winApiAdminService;
private SynchronizationContext _syncContext;
- public LgService(AppContextProvider appContextProvider, PowerEventDispatcher powerEventDispatcher, SessionSwitchDispatcher sessionSwitchDispatcher, ProcessEventDispatcher processEventDispatcher, ServiceManager serviceManager, RestartDetector restartDetector) : base(appContextProvider)
+ public ProcessChangedEventArgs CurrentProcessEvent => _processEventDispatcher?.MonitorContext;
+
+ public LgService(AppContextProvider appContextProvider, PowerEventDispatcher powerEventDispatcher, SessionSwitchDispatcher sessionSwitchDispatcher, ProcessEventDispatcher processEventDispatcher, ServiceManager serviceManager, RestartDetector restartDetector, WinApiService winApiService, WinApiAdminService winApiAdminService) : base(appContextProvider)
{
_allowPowerOn = appContextProvider.GetAppContext().StartUpParams.RunningFromScheduledTask;
_powerEventDispatcher = powerEventDispatcher;
@@ -87,6 +77,8 @@ namespace ColorControl.Services.LG
LgPreset.LgApps = _lgApps;
_restartDetector = restartDetector;
+ _winApiService = winApiService;
+ _winApiAdminService = winApiAdminService;
_syncContext = appContextProvider.GetAppContext().SynchronizationContext;
LgTvApiCore.SyncContext = _syncContext;
@@ -851,7 +843,7 @@ namespace ColorControl.Services.LG
var standByScript = Path.Combine(Program.DataDir, "StandByScript.bat");
if (File.Exists(standByScript))
{
- Utils.StartProcess(standByScript, hidden: true, wait: true);
+ _winApiAdminService.StartProcess(standByScript, hidden: true, wait: true);
}
}
@@ -911,13 +903,13 @@ namespace ColorControl.Services.LG
if (File.Exists(resumeScript))
{
- Utils.StartProcess(resumeScript, hidden: true);
+ _winApiAdminService.StartProcess(resumeScript, hidden: true);
}
}
private void SendConfigToService()
{
- if (!Utils.IsServiceRunning())
+ if (!_winApiService.IsServiceRunning())
{
return;
}
diff --git a/ColorControl/Services/NVIDIA/NvInfoPanel.Designer.cs b/ColorControl/Services/NVIDIA/NvInfoPanel.Designer.cs
new file mode 100644
index 0000000..47cb9c3
--- /dev/null
+++ b/ColorControl/Services/NVIDIA/NvInfoPanel.Designer.cs
@@ -0,0 +1,89 @@
+namespace ColorControl.Services.NVIDIA
+{
+ partial class NvInfoPanel
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ grpNVIDIAInfo = new System.Windows.Forms.GroupBox();
+ btnRefreshNVIDIAInfo = new System.Windows.Forms.Button();
+ tvNVIDIAInfo = new System.Windows.Forms.TreeView();
+ grpNVIDIAInfo.SuspendLayout();
+ SuspendLayout();
+ //
+ // grpNVIDIAInfo
+ //
+ grpNVIDIAInfo.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
+ grpNVIDIAInfo.Controls.Add(btnRefreshNVIDIAInfo);
+ grpNVIDIAInfo.Controls.Add(tvNVIDIAInfo);
+ grpNVIDIAInfo.Location = new System.Drawing.Point(4, 3);
+ grpNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ grpNVIDIAInfo.Name = "grpNVIDIAInfo";
+ grpNVIDIAInfo.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ grpNVIDIAInfo.Size = new System.Drawing.Size(643, 547);
+ grpNVIDIAInfo.TabIndex = 5;
+ grpNVIDIAInfo.TabStop = false;
+ grpNVIDIAInfo.Text = "NVIDIA info";
+ //
+ // btnRefreshNVIDIAInfo
+ //
+ btnRefreshNVIDIAInfo.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
+ btnRefreshNVIDIAInfo.Location = new System.Drawing.Point(8, 514);
+ btnRefreshNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ btnRefreshNVIDIAInfo.Name = "btnRefreshNVIDIAInfo";
+ btnRefreshNVIDIAInfo.Size = new System.Drawing.Size(88, 27);
+ btnRefreshNVIDIAInfo.TabIndex = 1;
+ btnRefreshNVIDIAInfo.Text = "Refresh";
+ btnRefreshNVIDIAInfo.UseVisualStyleBackColor = true;
+ btnRefreshNVIDIAInfo.Click += btnRefreshNVIDIAInfo_Click;
+ //
+ // tvNVIDIAInfo
+ //
+ tvNVIDIAInfo.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
+ tvNVIDIAInfo.Location = new System.Drawing.Point(8, 22);
+ tvNVIDIAInfo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ tvNVIDIAInfo.Name = "tvNVIDIAInfo";
+ tvNVIDIAInfo.Size = new System.Drawing.Size(627, 486);
+ tvNVIDIAInfo.TabIndex = 0;
+ //
+ // NvInfoPanel
+ //
+ AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ Controls.Add(grpNVIDIAInfo);
+ Name = "NvInfoPanel";
+ Size = new System.Drawing.Size(654, 556);
+ grpNVIDIAInfo.ResumeLayout(false);
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox grpNVIDIAInfo;
+ private System.Windows.Forms.Button btnRefreshNVIDIAInfo;
+ private System.Windows.Forms.TreeView tvNVIDIAInfo;
+ }
+}
diff --git a/ColorControl/Services/NVIDIA/NvInfoPanel.cs b/ColorControl/Services/NVIDIA/NvInfoPanel.cs
new file mode 100644
index 0000000..a617cf2
--- /dev/null
+++ b/ColorControl/Services/NVIDIA/NvInfoPanel.cs
@@ -0,0 +1,46 @@
+using ColorControl.Shared.Forms;
+using NvAPIWrapper.Display;
+using System.Windows.Forms;
+
+namespace ColorControl.Services.NVIDIA
+{
+ public partial class NvInfoPanel : UserControl, IModulePanel
+ {
+ private NvService _nvService;
+
+ internal NvInfoPanel(NvService nvService)
+ {
+ _nvService = nvService;
+
+ InitializeComponent();
+
+ if (DarkModeUtils.UseDarkMode)
+ {
+ grpNVIDIAInfo.ForeColor = FormUtils.CurrentForeColor;
+ }
+
+ RefreshInfo();
+ }
+
+ public void UpdateInfo()
+ {
+ RefreshInfo();
+ }
+
+ private void btnRefreshNVIDIAInfo_Click(object sender, System.EventArgs e)
+ {
+ }
+
+ private void RefreshInfo()
+ {
+ tvNVIDIAInfo.Nodes.Clear();
+ var displays = Display.GetDisplays();
+ for (var i = 0; i < displays.Length; i++)
+ {
+ var display = displays[i];
+ var node = TreeNodeBuilder.CreateTree(display, $"Display[{i}]");
+ tvNVIDIAInfo.Nodes.Add(node);
+ }
+ }
+ }
+}
diff --git a/ColorControl/Services/NVIDIA/NvInfoPanel.resx b/ColorControl/Services/NVIDIA/NvInfoPanel.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/ColorControl/Services/NVIDIA/NvInfoPanel.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ColorControl/Services/NVIDIA/NvPanel.Designer.cs b/ColorControl/Services/NVIDIA/NvPanel.Designer.cs
index 0a7c5e3..987376b 100644
--- a/ColorControl/Services/NVIDIA/NvPanel.Designer.cs
+++ b/ColorControl/Services/NVIDIA/NvPanel.Designer.cs
@@ -82,6 +82,8 @@ namespace ColorControl.Services.NVIDIA
miNvDriverSettingsIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuNvOtherSettings = new System.Windows.Forms.ToolStripMenuItem();
miNvOtherIncluded = new System.Windows.Forms.ToolStripMenuItem();
+ mnuNvHdmiSettings = new System.Windows.Forms.ToolStripMenuItem();
+ miNvHdmiIncluded = new System.Windows.Forms.ToolStripMenuItem();
mnuNvOverclocking = new System.Windows.Forms.ToolStripMenuItem();
miNvOverclockingIncluded = new System.Windows.Forms.ToolStripMenuItem();
miNvCopyId = new System.Windows.Forms.ToolStripMenuItem();
@@ -91,9 +93,9 @@ namespace ColorControl.Services.NVIDIA
miNvProfileInspector = new System.Windows.Forms.ToolStripMenuItem();
miNvNovideo = new System.Windows.Forms.ToolStripMenuItem();
miNvSettings = new System.Windows.Forms.ToolStripMenuItem();
+ miNvTestDithering = new System.Windows.Forms.ToolStripMenuItem();
lvNvPresetsToolTip = new System.Windows.Forms.ToolTip(components);
- mnuNvHdmiSettings = new System.Windows.Forms.ToolStripMenuItem();
- miNvHdmiIncluded = new System.Windows.Forms.ToolStripMenuItem();
+ miNVIDIAInfo = new System.Windows.Forms.ToolStripMenuItem();
mnuNvPresets.SuspendLayout();
mnuNvSettings.SuspendLayout();
SuspendLayout();
@@ -326,7 +328,7 @@ namespace ColorControl.Services.NVIDIA
mnuNvPresets.ImageScalingSize = new System.Drawing.Size(20, 20);
mnuNvPresets.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvApply, miNvPresetApplyOnStartup, tssNvPresetMenu, mnuNvDisplay, mnuNvPresetsColorSettings, mnuRefreshRate, mnuNvResolution, miNvPresetDithering, miNvHDR, mnuNvDriverSettings, mnuNvOtherSettings, mnuNvHdmiSettings, mnuNvOverclocking, miNvCopyId });
mnuNvPresets.Name = "mnuNvPresets";
- mnuNvPresets.Size = new System.Drawing.Size(185, 318);
+ mnuNvPresets.Size = new System.Drawing.Size(185, 296);
mnuNvPresets.Opening += mnuNvPresets_Opening;
//
// miNvApply
@@ -543,7 +545,7 @@ namespace ColorControl.Services.NVIDIA
// miNvDriverSettingsIncluded
//
miNvDriverSettingsIncluded.Name = "miNvDriverSettingsIncluded";
- miNvDriverSettingsIncluded.Size = new System.Drawing.Size(180, 22);
+ miNvDriverSettingsIncluded.Size = new System.Drawing.Size(120, 22);
miNvDriverSettingsIncluded.Text = "Included";
miNvDriverSettingsIncluded.Click += miNvDriverSettingsIncluded_Click;
//
@@ -557,10 +559,24 @@ namespace ColorControl.Services.NVIDIA
// miNvOtherIncluded
//
miNvOtherIncluded.Name = "miNvOtherIncluded";
- miNvOtherIncluded.Size = new System.Drawing.Size(180, 22);
+ miNvOtherIncluded.Size = new System.Drawing.Size(120, 22);
miNvOtherIncluded.Text = "Included";
miNvOtherIncluded.Click += miNvOtherIncluded_Click;
//
+ // mnuNvHdmiSettings
+ //
+ mnuNvHdmiSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvHdmiIncluded });
+ mnuNvHdmiSettings.Name = "mnuNvHdmiSettings";
+ mnuNvHdmiSettings.Size = new System.Drawing.Size(184, 22);
+ mnuNvHdmiSettings.Text = "HDMI Settings";
+ //
+ // miNvHdmiIncluded
+ //
+ miNvHdmiIncluded.Name = "miNvHdmiIncluded";
+ miNvHdmiIncluded.Size = new System.Drawing.Size(120, 22);
+ miNvHdmiIncluded.Text = "Included";
+ miNvHdmiIncluded.Click += miNvHdmiIncluded_Click;
+ //
// mnuNvOverclocking
//
mnuNvOverclocking.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvOverclockingIncluded });
@@ -571,7 +587,7 @@ namespace ColorControl.Services.NVIDIA
// miNvOverclockingIncluded
//
miNvOverclockingIncluded.Name = "miNvOverclockingIncluded";
- miNvOverclockingIncluded.Size = new System.Drawing.Size(180, 22);
+ miNvOverclockingIncluded.Size = new System.Drawing.Size(120, 22);
miNvOverclockingIncluded.Text = "Included";
miNvOverclockingIncluded.Click += miNvOverclockingIncluded_Click;
//
@@ -620,9 +636,9 @@ namespace ColorControl.Services.NVIDIA
// mnuNvSettings
//
mnuNvSettings.ImageScalingSize = new System.Drawing.Size(20, 20);
- mnuNvSettings.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvProfileInspector, miNvNovideo, miNvSettings });
+ mnuNvSettings.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvProfileInspector, miNvNovideo, miNvSettings, miNvTestDithering, miNVIDIAInfo });
mnuNvSettings.Name = "mnuLgButtons";
- mnuNvSettings.Size = new System.Drawing.Size(202, 70);
+ mnuNvSettings.Size = new System.Drawing.Size(202, 136);
//
// miNvProfileInspector
//
@@ -645,19 +661,19 @@ namespace ColorControl.Services.NVIDIA
miNvSettings.Text = "Settings";
miNvSettings.Click += miNvSettings_Click;
//
- // mnuNvHdmiSettings
+ // miNvTestDithering
//
- mnuNvHdmiSettings.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { miNvHdmiIncluded });
- mnuNvHdmiSettings.Name = "mnuNvHdmiSettings";
- mnuNvHdmiSettings.Size = new System.Drawing.Size(184, 22);
- mnuNvHdmiSettings.Text = "HDMI Settings";
+ miNvTestDithering.Name = "miNvTestDithering";
+ miNvTestDithering.Size = new System.Drawing.Size(201, 22);
+ miNvTestDithering.Text = "Test dithering";
+ miNvTestDithering.Click += miNvTestDithering_Click;
//
- // miNvHdmiIncluded
+ // miNVIDIAInfo
//
- miNvHdmiIncluded.Name = "miNvHdmiIncluded";
- miNvHdmiIncluded.Size = new System.Drawing.Size(180, 22);
- miNvHdmiIncluded.Text = "Included";
- miNvHdmiIncluded.Click += miNvHdmiIncluded_Click;
+ miNVIDIAInfo.Name = "miNVIDIAInfo";
+ miNVIDIAInfo.Size = new System.Drawing.Size(201, 22);
+ miNVIDIAInfo.Text = "NVIDIA Info";
+ miNVIDIAInfo.Click += miNVIDIAInfo_Click;
//
// NvPanel
//
@@ -760,5 +776,7 @@ namespace ColorControl.Services.NVIDIA
private System.Windows.Forms.ToolStripMenuItem miNvOtherIncluded;
private System.Windows.Forms.ToolStripMenuItem mnuNvHdmiSettings;
private System.Windows.Forms.ToolStripMenuItem miNvHdmiIncluded;
+ private System.Windows.Forms.ToolStripMenuItem miNvTestDithering;
+ private System.Windows.Forms.ToolStripMenuItem miNVIDIAInfo;
}
}
diff --git a/ColorControl/Services/NVIDIA/NvPanel.cs b/ColorControl/Services/NVIDIA/NvPanel.cs
index 7731bac..405505e 100644
--- a/ColorControl/Services/NVIDIA/NvPanel.cs
+++ b/ColorControl/Services/NVIDIA/NvPanel.cs
@@ -37,9 +37,9 @@ namespace ColorControl.Services.NVIDIA
private readonly AppContextProvider _appContextProvider;
private string _lastDisplayRefreshRates = string.Empty;
private NotifyIcon _trayIcon;
- private RpcService _rpcService;
+ private RpcClientService _rpcService;
- public NvPanel(NvService nvService, NotifyIcon trayIcon, IntPtr handle, AppContextProvider appContextProvider, RpcService rpcService)
+ public NvPanel(NvService nvService, NotifyIcon trayIcon, IntPtr handle, AppContextProvider appContextProvider, RpcClientService rpcService)
{
_nvService = nvService;
_trayIcon = trayIcon;
@@ -287,17 +287,20 @@ namespace ColorControl.Services.NVIDIA
{
var preset = GetSelectedNvPreset(true);
+ var checkState = miNvPresetDitheringEnabled.CheckState;
+ var newCheckState = checkState == CheckState.Checked ? CheckState.Unchecked : checkState == CheckState.Unchecked ? CheckState.Indeterminate : CheckState.Checked;
+
if (preset.IsDisplayPreset)
{
- miNvPresetDitheringEnabled.Checked = !miNvPresetDitheringEnabled.Checked;
+ miNvPresetDitheringEnabled.CheckState = newCheckState;
- _nvService.SetDithering(miNvPresetDitheringEnabled.Checked ? NvDitherState.Enabled : NvDitherState.Disabled);
+ _nvService.SetDithering(newCheckState == CheckState.Indeterminate ? NvDitherState.Auto : newCheckState == CheckState.Checked ? NvDitherState.Enabled : NvDitherState.Disabled);
UpdateDisplayInfoItems();
return;
}
- preset.ditheringEnabled = !preset.ditheringEnabled;
+ preset.ditheringEnabled = checkState == CheckState.Indeterminate ? null : checkState == CheckState.Checked;
AddOrUpdateItem();
}
@@ -395,7 +398,7 @@ namespace ColorControl.Services.NVIDIA
miNvPresetColorSettings.Checked = preset.applyColorData;
miNvPresetApplyDithering.Checked = preset.applyDithering;
- miNvPresetDitheringEnabled.Checked = preset.ditheringEnabled;
+ miNvPresetDitheringEnabled.CheckState = preset.ditheringEnabled == null ? CheckState.Indeterminate : preset.ditheringEnabled == true ? CheckState.Checked : CheckState.Unchecked;
foreach (var item in mnuNvDitheringBitDepth.DropDownItems.OfType())
{
@@ -1466,7 +1469,7 @@ namespace ColorControl.Services.NVIDIA
return;
}
- _nvService.ApplyOverclocking(newSettings);
+ _nvService.ApplyOverclocking(new List { newSettings });
UpdateNvGpuInfo();
}
@@ -1687,7 +1690,7 @@ namespace ColorControl.Services.NVIDIA
private async Task ApplyNvPresetOnStartup(int attempts = 5)
{
- var startUpParams = Shared.Common.AppContext.CurrentContext.StartUpParams;
+ var startUpParams = Shared.Common.GlobalContext.CurrentContext.StartUpParams;
var presetIdOrName = !string.IsNullOrEmpty(startUpParams.NvidiaPresetIdOrName) ? startUpParams.NvidiaPresetIdOrName : _config.NvPresetId_ApplyOnStartup.ToString();
@@ -1728,7 +1731,7 @@ namespace ColorControl.Services.NVIDIA
if (preset.IsDisplayPreset)
{
- _nvService.SetDithering(preset.ditheringEnabled ? NvDitherState.Enabled : NvDitherState.Disabled, ditheringBits, preset.ditheringMode);
+ _nvService.SetDithering(preset.DitherState, ditheringBits, preset.ditheringMode);
UpdateDisplayInfoItems();
return;
@@ -1749,7 +1752,7 @@ namespace ColorControl.Services.NVIDIA
if (preset.IsDisplayPreset)
{
- _nvService.SetDithering(preset.ditheringEnabled ? NvDitherState.Enabled : NvDitherState.Disabled, preset.ditheringBits, ditheringMode);
+ _nvService.SetDithering(preset.DitherState, preset.ditheringBits, ditheringMode);
UpdateDisplayInfoItems();
return;
@@ -1797,5 +1800,19 @@ namespace ColorControl.Services.NVIDIA
AddOrUpdateItem();
}
+
+ private void miNvTestDithering_Click(object sender, EventArgs e)
+ {
+ var panel = new NvDitherPanel(_nvService);
+
+ MessageForms.ShowControl(panel, "Test dithering");
+ }
+
+ private void miNVIDIAInfo_Click(object sender, EventArgs e)
+ {
+ var panel = new NvInfoPanel(_nvService);
+
+ MessageForms.ShowControl(panel, "NVIDIA Info");
+ }
}
}
diff --git a/ColorControl/Services/NVIDIA/NvPreset.cs b/ColorControl/Services/NVIDIA/NvPreset.cs
index 95c5c01..1b1a396 100644
--- a/ColorControl/Services/NVIDIA/NvPreset.cs
+++ b/ColorControl/Services/NVIDIA/NvPreset.cs
@@ -23,7 +23,7 @@ namespace ColorControl.Services.NVIDIA
public bool HDREnabled { get; set; }
public bool toggleHDR { get; set; }
public bool applyDithering { get; set; }
- public bool ditheringEnabled { get; set; }
+ public bool? ditheringEnabled { get; set; }
public bool applyRefreshRate { get; set; }
public uint refreshRate { get; set; }
public bool applyResolution { get; set; }
@@ -49,6 +49,7 @@ namespace ColorControl.Services.NVIDIA
public Display Display { get; set; }
[JsonIgnore]
public string InfoLine { get; set; }
+ public NvDitherState DitherState => ditheringEnabled.HasValue ? ditheringEnabled == true ? NvDitherState.Enabled : NvDitherState.Disabled : NvDitherState.Auto;
public NvPreset() : base()
{
@@ -224,14 +225,19 @@ namespace ColorControl.Services.NVIDIA
public string GetDitheringDescription(string disabledText = "Disabled")
{
- var dithering = ditheringEnabled ? string.Empty : disabledText;
- if (ditheringEnabled)
+ if (ditheringEnabled == null && ditheringBits == 0 && ditheringMode == 0)
+ {
+ return "Auto: Disabled";
+ }
+
+ if (ditheringEnabled is null or true)
{
var ditherBitsDescription = ((NvDitherBits)ditheringBits).GetDescription();
var ditherModeDescription = ((NvDitherMode)ditheringMode).GetDescription();
- dithering = string.Format("{0} {1}", ditherBitsDescription, ditherModeDescription);
+ return string.Format("{0}{1} {2}", ditheringEnabled == null ? "Auto: " : "", ditherBitsDescription, ditherModeDescription);
}
- return dithering;
+
+ return disabledText;
}
public string GetHdmiSettingsDescription()
diff --git a/ColorControl/Services/NVIDIA/NvService.cs b/ColorControl/Services/NVIDIA/NvService.cs
index de1fc11..7af7bb3 100644
--- a/ColorControl/Services/NVIDIA/NvService.cs
+++ b/ColorControl/Services/NVIDIA/NvService.cs
@@ -7,6 +7,7 @@ using ColorControl.Shared.Native;
using ColorControl.Shared.Services;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
+using novideo_srgb;
using nspector.Common;
using nspector.Common.Meta;
using NvAPIWrapper.Display;
@@ -143,11 +144,15 @@ namespace ColorControl.Services.NVIDIA
DRS_RBAR_OPTIONS,
DRS_RBAR_SIZE_LIMIT
};
-
+ private readonly WinApiService _winApiService;
+ private readonly RpcClientService _rpcClientService;
private static NvService ServiceInstance;
- public NvService(AppContextProvider appContextProvider) : base(appContextProvider)
+ public NvService(AppContextProvider appContextProvider, WinApiService winApiService, RpcClientService rpcClientService) : base(appContextProvider)
{
+ _winApiService = winApiService;
+ _rpcClientService = rpcClientService;
+ _rpcClientService.Name = nameof(NvService);
NvPreset.NvService = this;
AddJsonConverter(new ColorDataConverter());
@@ -159,9 +164,7 @@ namespace ColorControl.Services.NVIDIA
{
try
{
- var appContextProvider = Program.ServiceProvider.GetRequiredService();
-
- var nvService = new NvService(appContextProvider);
+ var nvService = Program.ServiceProvider.GetRequiredService();
var result = await nvService.ApplyPreset(idOrName);
@@ -315,6 +318,11 @@ namespace ColorControl.Services.NVIDIA
if (applyHdr)
{
+ if (newHdrEnabled && !hdrEnabled)
+ {
+ MainWindow.BeforeDisplaySettingsChange();
+ }
+
SetHDRState(display, newHdrEnabled);
}
@@ -341,7 +349,7 @@ namespace ColorControl.Services.NVIDIA
if (preset.applyDithering)
{
- if (!SetDithering(preset.ditheringEnabled ? NvDitherState.Enabled : NvDitherState.Disabled, preset: preset))
+ if (!SetDithering(preset.DitherState, preset: preset))
{
result = false;
}
@@ -364,19 +372,17 @@ namespace ColorControl.Services.NVIDIA
return Task.FromResult(result);
}
- public bool ApplyOverclocking(NvGpuOcSettings setting)
- {
- return ApplyOverclocking(new List { setting });
- }
-
public bool ApplyOverclocking(List settings)
{
- if (!Utils.IsAdministrator())
+ if (!_winApiService.IsAdministrator())
{
- var result = PipeUtils.SendMessage(new SvcNvOverclockingMessage
+ var message = new SvcRpcSetNvOverclockingMessage
{
+ MethodName = nameof(ApplyOverclocking),
OverclockingSettings = settings
- });
+ };
+
+ var result = _rpcClientService.Call