From 1c22b2daf8fd0f859ed99d741f6616770ebf4961 Mon Sep 17 00:00:00 2001 From: Maassoft Date: Sun, 28 Sep 2025 15:10:25 +0200 Subject: [PATCH] fix some issues, add ddc settings, make new ui default --- ColorControl.UI/Blazor.cs | 129 +- .../Pages/ColorProfile/ColorProfilePage.razor | 75 +- .../Components/Pages/Game/GameSummary.razor | 4 + .../Components/Pages/Generic/FieldDefs.razor | 10 +- .../Components/Pages/Generic/RangeInput.razor | 1 - .../Components/Pages/Generic/StepsInput.razor | 343 +- .../Pages/Nvidia/NvidiaPreset.razor | 189 +- .../Pages/Nvidia/NvidiaSummary.razor | 4 + .../Components/Pages/Options.razor | 59 +- ColorControl.UI/Services/JSHelper.cs | 5 + .../Services/RpcUiClientService.cs | 118 +- ColorControl.UI/wwwroot/helper.js | 4 + ColorControl/ColorControl.csproj | 5 +- ColorControl/Forms/OptionsPanel.cs | 2 +- ColorControl/MainForm.cs | 649 ++- ColorControl/Program.cs | 33 +- ColorControl/Services/AMD/AmdPanel.cs | 39 - ColorControl/Services/AMD/AmdService.cs | 36 + .../Services/Common/ColorProfileService.cs | 638 +-- .../Services/Common/GraphicsService.cs | 402 +- .../Services/Common/NotifyIconManager.cs | 398 +- .../Services/Common/OptionsService.cs | 19 +- ColorControl/Services/Common/ServiceBase.cs | 2 +- .../Services/GameLauncher/GameService.cs | 10 + ColorControl/Services/LG/LgDevice.cs | 23 +- ColorControl/Services/LG/LgServiceConfig.cs | 87 +- ColorControl/Services/NVIDIA/NvPanel.cs | 3492 ++++++++--------- ColorControl/Services/NVIDIA/NvService.cs | 131 +- .../Services/Samsung/SamsungService.cs | 6 +- .../Svc/ColorControlBackgroundService.cs | 4 + ColorControl/XForms/BrowserWindow.xaml.cs | 156 +- LittleCms/IccProfile.cs | 2 +- MHC2Gen/GenerateProfileCommand.cs | 7 +- MHC2Gen/IccContext.cs | 138 +- MHC2Gen/MHC2Wrapper.cs | 5 + Nspector/nspector/CustomSettingNames.xml | 631 +-- NvAPIWrapper/Native/Display/Scaling.cs | 3 + Shared/Common/GenericBoolResult.cs | 50 + Shared/Contracts/Config.cs | 225 +- Shared/Contracts/DdcSetting.cs | 62 + Shared/Contracts/DdcSettings.cs | 27 + .../Contracts/DisplayInfo/ColorProfileDto.cs | 94 +- Shared/Contracts/Game/GamePreset.cs | 1 + Shared/Contracts/NVIDIA/NvPreset.cs | 11 +- Shared/Contracts/PresetStep.cs | 27 +- Shared/Contracts/Samsung/SamsungPreset.cs | 1 + Shared/Contracts/VcpCodes.cs | 264 ++ Shared/Contracts/VcpInfo.cs | 10 + Shared/Native/CCD.cs | 11 +- Shared/Native/WinApi.cs | 39 + Shared/Native/WinError.cs | 51 + Shared/Services/RpcServerService.cs | 296 +- 52 files changed, 5258 insertions(+), 3770 deletions(-) create mode 100644 Shared/Common/GenericBoolResult.cs create mode 100644 Shared/Contracts/DdcSetting.cs create mode 100644 Shared/Contracts/DdcSettings.cs create mode 100644 Shared/Contracts/VcpCodes.cs create mode 100644 Shared/Contracts/VcpInfo.cs create mode 100644 Shared/Native/WinError.cs diff --git a/ColorControl.UI/Blazor.cs b/ColorControl.UI/Blazor.cs index db7b437..6f0310d 100644 --- a/ColorControl.UI/Blazor.cs +++ b/ColorControl.UI/Blazor.cs @@ -1,43 +1,118 @@ using ColorControl.Shared.Contracts; using ColorControl.UI.Services; +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.AspNetCore.Hosting.Server.Features; +using System.Net; namespace ColorControl.UI; public static class Blazor { - public static void Start(Config? config = null) - { - var builder = WebApplication.CreateBuilder(); + private static WebApplication? CurrentApplication; + private static int Port; + private static bool AllowRemoteConnections; - // Add services to the container. - builder.Services.AddRazorComponents() - .AddInteractiveServerComponents(); + public static bool IsRunning(Config config) => CurrentApplication != null && Port == config.UiPort && AllowRemoteConnections == config.UiAllowRemoteConnections; - builder.Services.AddSingleton(new AppState { SelectedTheme = (config?.UseDarkMode ?? true) ? "dark" : "light" }); - builder.Services.AddTransient(); - builder.Services.AddTransient(); - builder.Services.AddHttpContextAccessor(); - builder.Services.AddSingleton(); - builder.WebHost.ConfigureKestrel(o => o.ListenAnyIP(config?.UiPort > 0 ? config.UiPort : 5000)); + public static async Task Start(Config config) + { + if (IsRunning(config)) + { + return; + } - var app = builder.Build(); + await Stop(); - // Configure the HTTP request pipeline. - if (!app.Environment.IsDevelopment()) - { - app.UseExceptionHandler("/Error", createScopeForErrors: true); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } + var builder = WebApplication.CreateBuilder(); - app.UseHttpsRedirection(); + // Add services to the container. + builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); - app.UseStaticFiles(); - app.UseAntiforgery(); + builder.Services.AddSingleton(new AppState { SelectedTheme = config.UseDarkMode ? "dark" : "light" }); + builder.Services.AddTransient(); + builder.Services.AddTransient(); + builder.Services.AddHttpContextAccessor(); + builder.Services.AddSingleton(); - app.MapRazorComponents() - .AddInteractiveServerRenderMode(); + builder.Services.Configure(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(3)); + + var listenPort = config.UiPort > 0 ? config.UiPort : 0; + + builder.WebHost.ConfigureKestrel(options => + { + if (config.UiAllowRemoteConnections) + { + options.ListenAnyIP(listenPort); + } + else + { + options.Listen(IPAddress.Parse("127.0.0.1"), listenPort); + } + }); + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (!app.Environment.IsDevelopment()) + { + app.UseExceptionHandler("/Error", createScopeForErrors: true); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); + } + + app.UseHttpsRedirection(); + + app.UseStaticFiles(); + app.UseAntiforgery(); + + app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + + CurrentApplication = app; + Port = config.UiPort; + AllowRemoteConnections = config.UiAllowRemoteConnections; + + await app.RunAsync(); + } + + public static async Task Stop() + { + if (CurrentApplication != null) + { + await CurrentApplication.StopAsync(); + CurrentApplication = null; + } + } + + public static string GetCurrentUrl() + { + var port = GetCurrentPort(); + + return $"http://localhost:{port}"; + } + + public static int GetCurrentPort() + { + if (CurrentApplication == null) + { + return -1; + } + + var server = CurrentApplication.Services.GetService(); + var addressFeature = server?.Features.Get(); + + if (addressFeature == null) + { + return -1; + } + + foreach (var address in addressFeature.Addresses) + { + return int.Parse(address.Split(':').Last()); + } + + return -1; + } - app.Run(); - } } diff --git a/ColorControl.UI/Components/Pages/ColorProfile/ColorProfilePage.razor b/ColorControl.UI/Components/Pages/ColorProfile/ColorProfilePage.razor index 9fafe5e..596ea3f 100644 --- a/ColorControl.UI/Components/Pages/ColorProfile/ColorProfilePage.razor +++ b/ColorControl.UI/Components/Pages/ColorProfile/ColorProfilePage.razor @@ -51,6 +51,16 @@ +
+ + +
+
@@ -236,21 +246,49 @@
-
-
-
- - -
-
-
-
- - -
+ } +
+
+
+ +
- +
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ @if (ColorProfile.IsHDRProfile) + {
@@ -280,17 +318,6 @@
} - else - { -
-
-
- - -
-
-
- }
diff --git a/ColorControl.UI/Components/Pages/Game/GameSummary.razor b/ColorControl.UI/Components/Pages/Game/GameSummary.razor index 5f6e6da..1f91ab4 100644 --- a/ColorControl.UI/Components/Pages/Game/GameSummary.razor +++ b/ColorControl.UI/Components/Pages/Game/GameSummary.razor @@ -68,6 +68,10 @@ else { QA } + @if (!preset.PathExists) + { + Not found + } diff --git a/ColorControl.UI/Components/Pages/Generic/FieldDefs.razor b/ColorControl.UI/Components/Pages/Generic/FieldDefs.razor index 2080131..2dba84a 100644 --- a/ColorControl.UI/Components/Pages/Generic/FieldDefs.razor +++ b/ColorControl.UI/Components/Pages/Generic/FieldDefs.razor @@ -46,7 +46,7 @@
- @if (field.ValueType != null) { @foreach (var item in Enum.GetValues(field.ValueType)) @@ -111,4 +111,12 @@ @code { [Parameter] public List? Fields { get; set; } + + [Parameter] + public EventCallback FieldValueChanged { get; set; } + + private async Task FieldBindAfter(FieldDefinition field) + { + await FieldValueChanged.InvokeAsync(field); + } } \ No newline at end of file diff --git a/ColorControl.UI/Components/Pages/Generic/RangeInput.razor b/ColorControl.UI/Components/Pages/Generic/RangeInput.razor index 56b66b9..b72ff9a 100644 --- a/ColorControl.UI/Components/Pages/Generic/RangeInput.razor +++ b/ColorControl.UI/Components/Pages/Generic/RangeInput.razor @@ -112,5 +112,4 @@ ExtraLabelStyling = LabelStylingFunc?.Invoke(Value); } - } \ No newline at end of file diff --git a/ColorControl.UI/Components/Pages/Generic/StepsInput.razor b/ColorControl.UI/Components/Pages/Generic/StepsInput.razor index 18f397b..5a45a58 100644 --- a/ColorControl.UI/Components/Pages/Generic/StepsInput.razor +++ b/ColorControl.UI/Components/Pages/Generic/StepsInput.razor @@ -19,89 +19,170 @@
@if (NvPresets != null || SamsungPresets != null || LgPresets != null || CustomItems != null) { -
} @@ -121,7 +202,7 @@ { var stepIndex = index; - +
} +
+

+ + @if (!Preset.IsDisplayPreset) + { + + } + + +

+
+
+ + @if (!Preset.DdcSettings.Settings.Any()) + { +
+ + +
+ } + + @foreach (var ddcSetting in Preset.DdcSettings.Settings) + { +
+ + +
+ +
+ + + @if (ddcSetting.MaxValue != 0) + { +
+ Max. value: @ddcSetting.MaxValue +
+ } +
+ + @if (!Preset.IsDisplayPreset) + { +
+ + +
+ } + } + + @if (!string.IsNullOrEmpty(DdcErrorMessage)) + { + + } + +
+ + +
+
+
+
+ @if (ShowOverclocking) {
@@ -560,39 +640,40 @@
} -
-
-

- -

-
-
- + @if (!Preset.IsDisplayPreset) + { +
+
+

+ +

+
+
+ +
-
-
-

- -

-
-
- -
- -