Skip to content

Commit 6e206a6

Browse files
committed
fix Nvidia crash, remove UWP dependencies
1 parent d31d2f3 commit 6e206a6

40 files changed

+8607
-8512
lines changed

ColorControl.UI/ColorControl.UI.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0-windows10.0.20348.0</TargetFramework>
4+
<TargetFramework>net9.0-windows</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<OutputType>Library</OutputType>
7+
<OutputType>Library</OutputType>
8+
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
89
</PropertyGroup>
910

1011
<ItemGroup>
11-
<PackageReference Include="NLog" Version="5.2.8" />
12+
<PackageReference Include="NLog" Version="5.3.4" />
1213
</ItemGroup>
1314

1415
<ItemGroup>

ColorControl.UI/Components/Pages/ColorProfile/ColorProfilePage.razor

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@
251251
</div>
252252
</div>
253253
}
254+
else
255+
{
256+
<div class="row">
257+
<div class="col">
258+
<div class="mb-2">
259+
<label class="form-label" for="shadowDetailBoost">Shadow detail boost (%)</label>
260+
<input class="form-control" id="shadowDetailBoost" type="number" min="0" max="100" @bind="ColorProfile.ShadowDetailBoost" disabled="@(ColorProfile.SDRTransferFunction == SDRTransferFunction.Piecewise)" />
261+
</div>
262+
</div>
263+
</div>
264+
}
254265
</div>
255266
</div>
256267
</div>

ColorControl.UI/Components/Pages/ColorProfile/ColorProfileSummary.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ else
3333
{
3434
<span>No displays found</span>
3535
}
36-
@foreach (var display in Displays)
36+
else
3737
{
3838
<div class="mb-2">
3939
<label class="form-label" for="device">Selected display</label>
4040
<select class="form-select" id="device" @bind="SelectedDisplayId" @bind:after="SelectedDisplayChanged">
41-
@foreach (var device in Displays)
41+
@foreach (var display in Displays)
4242
{
4343
<option value="@display.DisplayId">@display.DisplayName @@ @display.AdapterName</option>
4444
}

ColorControl.UI/Components/Pages/Generic/ShortcutInput.razor

Lines changed: 126 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,133 @@
77

88
@if (Label != null)
99
{
10-
<div class="mb-2">
11-
<label class="form-label" for="name">@Label</label>
12-
<input class="form-control" type="text" readonly value="@Shortcut"
13-
@onchange="(ChangeEventArgs e) => ShortcutOnChange(e)"
14-
@onkeydown="ShortcutOnKeyDown"
15-
@onkeyup="(KeyboardEventArgs e) => ShortcutOnKeyUp(e)"
16-
@onfocus="ShortcutOnFocus"
17-
@onblur="ShortcutOnBlur"/>
18-
</div>
10+
<div class="mb-2">
11+
<label class="form-label" for="name">@Label</label>
12+
<div class="input-group">
13+
<input class="form-control" type="text" readonly value="@Shortcut"
14+
@onchange="(ChangeEventArgs e) => ShortcutOnChange(e)"
15+
@onkeydown="ShortcutOnKeyDown"
16+
@onkeyup="(KeyboardEventArgs e) => ShortcutOnKeyUp(e)"
17+
@onfocus="ShortcutOnFocus"
18+
@onblur="ShortcutOnBlur"/>
19+
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
20+
</button>
21+
<ul class="dropdown-menu">
22+
@foreach (var modifier in Modifiers) {
23+
<li>
24+
<a class="dropdown-item" @onclick="() => ModifierOnClick(modifier.Key)">
25+
<input class="form-check-input me-2" type="checkbox" id="flexCheckChecked" checked="@modifier.Value" @onchange="(e) => ModifierKeyChanged(e, modifier.Key)">@modifier.Key
26+
</a>
27+
</li>
28+
}
29+
</ul>
30+
</div>
31+
</div>
1932
}
2033

2134
@code {
22-
[Parameter]
23-
public string? Label { get; set; }
24-
25-
[Parameter]
26-
public string? Shortcut { get; set; }
27-
28-
[Parameter]
29-
public EventCallback<string?> ShortcutChanged { get; set; }
30-
31-
private async Task ShortcutOnChange(ChangeEventArgs e)
32-
{
33-
Shortcut = e.Value?.ToString();
34-
await ShortcutChanged.InvokeAsync(Shortcut);
35-
}
36-
37-
private void ShortcutOnKeyDown(KeyboardEventArgs e)
38-
{
39-
if (e.Key == "Tab")
40-
{
41-
return;
42-
}
43-
44-
var text = KeyboardShortcutDispatcher.FormatKeyboardShortcut(e.ShiftKey, e.CtrlKey, e.AltKey, e.Key, e.Code);
45-
Shortcut = text;
46-
}
47-
48-
private async Task ShortcutOnKeyUp(KeyboardEventArgs e)
49-
{
50-
//KeyboardShortcutDispatcher.HandleKeyboardShortcutUp()
51-
await ShortcutChanged.InvokeAsync(Shortcut);
52-
}
53-
54-
private void ShortcutOnFocus(FocusEventArgs e)
55-
{
56-
KeyboardShortcutDispatcher.IsActive = false;
57-
}
58-
59-
private void ShortcutOnBlur(FocusEventArgs e)
60-
{
61-
KeyboardShortcutDispatcher.IsActive = true;
62-
}
35+
[Parameter]
36+
public string? Label { get; set; }
37+
38+
[Parameter]
39+
public string? Shortcut { get; set; }
40+
41+
[Parameter]
42+
public EventCallback<string?> ShortcutChanged { get; set; }
43+
44+
private Dictionary<string, bool> Modifiers = new() {
45+
{ "Shift", false },
46+
{ "Control", false },
47+
{ "Alt", false },
48+
{ "Win", false }
49+
};
50+
51+
protected override void OnParametersSet()
52+
{
53+
LoadModifiers();
54+
}
55+
56+
private async Task ShortcutOnChange(ChangeEventArgs e)
57+
{
58+
Shortcut = e.Value?.ToString();
59+
LoadModifiers();
60+
await ShortcutChanged.InvokeAsync(Shortcut);
61+
}
62+
63+
private void ShortcutOnKeyDown(KeyboardEventArgs e)
64+
{
65+
if (e.Key == "Tab")
66+
{
67+
return;
68+
}
69+
70+
var text = KeyboardShortcutDispatcher.FormatKeyboardShortcut(e.ShiftKey, e.CtrlKey, e.AltKey, e.Key, e.Code);
71+
Shortcut = text;
72+
}
73+
74+
private async Task ShortcutOnKeyUp(KeyboardEventArgs e)
75+
{
76+
//KeyboardShortcutDispatcher.HandleKeyboardShortcutUp()
77+
await ShortcutChanged.InvokeAsync(Shortcut);
78+
}
79+
80+
private void ShortcutOnFocus(FocusEventArgs e)
81+
{
82+
KeyboardShortcutDispatcher.IsActive = false;
83+
}
84+
85+
private void ShortcutOnBlur(FocusEventArgs e)
86+
{
87+
KeyboardShortcutDispatcher.IsActive = true;
88+
}
89+
90+
private void LoadModifiers()
91+
{
92+
foreach (var modifier in Modifiers.Keys)
93+
{
94+
Modifiers[modifier] = Shortcut?.Contains(modifier) == true;
95+
}
96+
}
97+
private async Task ModifierKeyChanged(ChangeEventArgs e, string modifier)
98+
{
99+
var value = e.Value is bool boolValue && boolValue;
100+
101+
Modifiers[modifier] = value;
102+
103+
await SetModifiers();
104+
}
105+
106+
private async Task SetModifiers()
107+
{
108+
var shortcut = Shortcut ?? "";
109+
foreach (var modifier in Modifiers.Keys)
110+
{
111+
shortcut = shortcut.Replace(modifier, "").Trim().TrimStart(',');
112+
}
113+
114+
shortcut = shortcut.Trim();
115+
116+
foreach (var modifier in Modifiers.Where(kv => kv.Value).Select(kv => kv.Key).Reverse())
117+
{
118+
if (shortcut.StartsWith("+"))
119+
{
120+
shortcut = $"{modifier} {shortcut}";
121+
}
122+
else
123+
{
124+
shortcut = $"{modifier}, {shortcut}";
125+
}
126+
}
127+
128+
Shortcut = shortcut;
129+
130+
await ShortcutChanged.InvokeAsync(Shortcut);
131+
}
132+
133+
private async Task ModifierOnClick(string modifier)
134+
{
135+
Modifiers[modifier] = !Modifiers[modifier];
136+
137+
await SetModifiers();
138+
}
63139
}

ColorControl.UI/Components/Pages/Nvidia/NvidiaDithering.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
</div>
9090
<div class="modal-footer">
9191
<span class="me-auto">
92-
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="SetDitherRegistryKeyOnClick">Set dither registry key</button>
93-
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="RestartDriverOnClick">Restart driver</button>
92+
<button type="button" class="btn btn-secondary" @onclick="SetDitherRegistryKeyOnClick">Set dither registry key</button>
93+
<button type="button" class="btn btn-secondary" @onclick="RestartDriverOnClick">Restart driver</button>
9494
</span>
9595
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
9696
</div>

ColorControl.UI/Components/Pages/Nvidia/NvidiaPreset.razor

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@inject RpcUiClientService _rpcClientService
1212
@inject AppState AppState
1313
@inject NavigationManager _navigationManager;
14+
@inject JSHelper jsHelper;
1415

1516
<div class="modal" id="presetModal" tabindex="-1" data-bs-backdrop="static" data-bs-keyboard="false" @onfocus="ModalOnFocus">
1617
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
@@ -70,10 +71,10 @@
7071
<div class="mb-2">
7172
<label class="form-label" for="mode">Display</label>
7273
<select class="form-select" id="mode" @bind="Preset.DisplayId" disabled="@(Preset.primaryDisplay)">
73-
@foreach (var display in displayPresets)
74-
{
75-
<option value="@display.DisplayId">@display.displayName</option>
76-
}
74+
@foreach (var display in displayPresets)
75+
{
76+
<option value="@display.DisplayId">@display.displayName</option>
77+
}
7778
</select>
7879
</div>
7980
<div class="mb-2">
@@ -356,7 +357,7 @@
356357
</div>
357358
<div class="mb-2">
358359
<label class="form-label" for="bits">Bit depth</label>
359-
<select class="form-select" id="bits" @bind="Preset.NvDitherBits">
360+
<select class="form-select" id="bits" @bind="Preset.NvDitherBits">
360361
@foreach (var bits in Enum.GetValues<NvDitherBits>())
361362
{
362363
<option value="@bits.ToString()">@bits.GetDescription()</option>
@@ -544,7 +545,7 @@
544545
</div>
545546
<div class="modal-footer">
546547
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="() => IsVisible = false">Close</button>
547-
<button type="submit" class="btn btn-primary" data-bs-dismiss="@(IsValid() ? "modal" : "")" @onclick="ApplyClick">@(Preset?.IsDisplayPreset == true ? "Apply" : "Save")</button>
548+
<button type="submit" class="btn btn-primary" disabled="@(!IsValid())" @onclick="ApplyClick">@(Preset?.IsDisplayPreset == true ? "Apply" : "Save")</button>
548549
</div>
549550
</div>
550551
</div>
@@ -667,12 +668,20 @@
667668
else
668669
{
669670
var result = await _rpcClientService.CallAsync<bool>("NvService", "UpdatePreset", Preset);
671+
672+
if (!result)
673+
{
674+
return;
675+
}
670676
}
671677

672678
if (AfterApply != null)
673679
{
674680
await AfterApply.Invoke(Preset);
675681
}
682+
683+
await jsHelper.CloseModal("presetModal");
684+
IsVisible = false;
676685
}
677686

678687
private async Task ApplyDisplayPreset()

ColorControl.UI/Components/Pages/Nvidia/NvidiaSummary.razor

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ else
9090
<br />
9191
<small class="text-body">Color profile: @preset.ColorProfileSettings.ProfileName</small>
9292
}
93+
@if (preset.driverSettings?.Any() == true)
94+
{
95+
<br />
96+
<div class="dropdown">
97+
<span role="button" class="text-decoration-underline dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside" @onclick="() => DriverSettingsOnClick(preset)">
98+
<small>@preset.driverSettings.Count() driver settings changed</small>
99+
</span>
100+
<form class="dropdown-menu">
101+
@if (DriverSettings != null)
102+
{
103+
<ul class="list-group p-0">
104+
@foreach (var setting in DriverSettings)
105+
{
106+
<li class="list-group-item py-0 px-1"><small>@setting.FriendlyName</small></li>
107+
}
108+
</ul>
109+
}
110+
</form>
111+
</div>
112+
}
93113
</div>
94114
</div>
95115
</div>
@@ -258,6 +278,7 @@ else
258278
private NvPreset? CurrentGpuSettingsPreset;
259279
private NvGpuInfoDto? CurrentGpuInfo;
260280
private bool DitheringVisible;
281+
private List<NvSettingItemDto>? DriverSettings;
261282

262283
private PresetOrder PresetOrder;
263284

@@ -371,4 +392,14 @@ else
371392

372393
Presets = Presets?.OrderPresetsBy(PresetOrder);
373394
}
395+
396+
private async Task DriverSettingsOnClick(NvPreset preset)
397+
{
398+
var driverSettings = await _rpcClientService.CallAsync<List<NvSettingItemDto>>("NvService", "GetDriverSettings", Type.Missing, true);
399+
400+
if (driverSettings != null)
401+
{
402+
DriverSettings = driverSettings.Where(s => s.Value != s.DefaultValue && s.State == 2).ToList();
403+
}
404+
}
374405
}

ColorControl.UI/Components/Pages/Options.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ else
301301

302302
private async Task ElevationMethodInput(ChangeEventArgs e)
303303
{
304-
var value = e.Value != null ? (ElevationMethod)int.Parse((string)e.Value) : ElevationMethod.None;
304+
var value = e.Value != null ? Enum.Parse<ElevationMethod>((string)e.Value) : ElevationMethod.None;
305305
await _rpcClientService.CallAsync<bool>("OptionsService", "SetElevationMethod", value);
306306
}
307307

0 commit comments

Comments
 (0)