mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-21 08:09:49 -05:00
fix Nvidia crash, remove UWP dependencies
This commit is contained in:
1 parent
d31d2f321f
commit
6e206a6728
40 files changed
+8544
-8449
No files matched your search
@@ -251,6 +251,17 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="shadowDetailBoost">Shadow detail boost (%)</label>
|
||||
<input class="form-control" id="shadowDetailBoost" type="number" min="0" max="100" @bind="ColorProfile.ShadowDetailBoost" disabled="@(ColorProfile.SDRTransferFunction == SDRTransferFunction.Piecewise)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,12 +33,12 @@ else
|
||||
{
|
||||
<span>No displays found</span>
|
||||
}
|
||||
@foreach (var display in Displays)
|
||||
else
|
||||
{
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="device">Selected display</label>
|
||||
<select class="form-select" id="device" @bind="SelectedDisplayId" @bind:after="SelectedDisplayChanged">
|
||||
@foreach (var device in Displays)
|
||||
@foreach (var display in Displays)
|
||||
{
|
||||
<option value="@display.DisplayId">@display.DisplayName @@ @display.AdapterName</option>
|
||||
}
|
||||
|
||||
@@ -7,57 +7,133 @@
|
||||
|
||||
@if (Label != null)
|
||||
{
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="name">@Label</label>
|
||||
<input class="form-control" type="text" readonly value="@Shortcut"
|
||||
@onchange="(ChangeEventArgs e) => ShortcutOnChange(e)"
|
||||
@onkeydown="ShortcutOnKeyDown"
|
||||
@onkeyup="(KeyboardEventArgs e) => ShortcutOnKeyUp(e)"
|
||||
@onfocus="ShortcutOnFocus"
|
||||
@onblur="ShortcutOnBlur"/>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="name">@Label</label>
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" readonly value="@Shortcut"
|
||||
@onchange="(ChangeEventArgs e) => ShortcutOnChange(e)"
|
||||
@onkeydown="ShortcutOnKeyDown"
|
||||
@onkeyup="(KeyboardEventArgs e) => ShortcutOnKeyUp(e)"
|
||||
@onfocus="ShortcutOnFocus"
|
||||
@onblur="ShortcutOnBlur"/>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
@foreach (var modifier in Modifiers) {
|
||||
<li>
|
||||
<a class="dropdown-item" @onclick="() => ModifierOnClick(modifier.Key)">
|
||||
<input class="form-check-input me-2" type="checkbox" id="flexCheckChecked" checked="@modifier.Value" @onchange="(e) => ModifierKeyChanged(e, modifier.Key)">@modifier.Key
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? Label { get; set; }
|
||||
[Parameter]
|
||||
public string? Label { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string? Shortcut { get; set; }
|
||||
[Parameter]
|
||||
public string? Shortcut { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string?> ShortcutChanged { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<string?> ShortcutChanged { get; set; }
|
||||
|
||||
private async Task ShortcutOnChange(ChangeEventArgs e)
|
||||
{
|
||||
Shortcut = e.Value?.ToString();
|
||||
await ShortcutChanged.InvokeAsync(Shortcut);
|
||||
}
|
||||
private Dictionary<string, bool> Modifiers = new() {
|
||||
{ "Shift", false },
|
||||
{ "Control", false },
|
||||
{ "Alt", false },
|
||||
{ "Win", false }
|
||||
};
|
||||
|
||||
private void ShortcutOnKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "Tab")
|
||||
{
|
||||
return;
|
||||
}
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
LoadModifiers();
|
||||
}
|
||||
|
||||
var text = KeyboardShortcutDispatcher.FormatKeyboardShortcut(e.ShiftKey, e.CtrlKey, e.AltKey, e.Key, e.Code);
|
||||
Shortcut = text;
|
||||
}
|
||||
private async Task ShortcutOnChange(ChangeEventArgs e)
|
||||
{
|
||||
Shortcut = e.Value?.ToString();
|
||||
LoadModifiers();
|
||||
await ShortcutChanged.InvokeAsync(Shortcut);
|
||||
}
|
||||
|
||||
private async Task ShortcutOnKeyUp(KeyboardEventArgs e)
|
||||
{
|
||||
//KeyboardShortcutDispatcher.HandleKeyboardShortcutUp()
|
||||
await ShortcutChanged.InvokeAsync(Shortcut);
|
||||
}
|
||||
private void ShortcutOnKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "Tab")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private void ShortcutOnFocus(FocusEventArgs e)
|
||||
{
|
||||
KeyboardShortcutDispatcher.IsActive = false;
|
||||
}
|
||||
var text = KeyboardShortcutDispatcher.FormatKeyboardShortcut(e.ShiftKey, e.CtrlKey, e.AltKey, e.Key, e.Code);
|
||||
Shortcut = text;
|
||||
}
|
||||
|
||||
private void ShortcutOnBlur(FocusEventArgs e)
|
||||
{
|
||||
KeyboardShortcutDispatcher.IsActive = true;
|
||||
}
|
||||
private async Task ShortcutOnKeyUp(KeyboardEventArgs e)
|
||||
{
|
||||
//KeyboardShortcutDispatcher.HandleKeyboardShortcutUp()
|
||||
await ShortcutChanged.InvokeAsync(Shortcut);
|
||||
}
|
||||
|
||||
private void ShortcutOnFocus(FocusEventArgs e)
|
||||
{
|
||||
KeyboardShortcutDispatcher.IsActive = false;
|
||||
}
|
||||
|
||||
private void ShortcutOnBlur(FocusEventArgs e)
|
||||
{
|
||||
KeyboardShortcutDispatcher.IsActive = true;
|
||||
}
|
||||
|
||||
private void LoadModifiers()
|
||||
{
|
||||
foreach (var modifier in Modifiers.Keys)
|
||||
{
|
||||
Modifiers[modifier] = Shortcut?.Contains(modifier) == true;
|
||||
}
|
||||
}
|
||||
private async Task ModifierKeyChanged(ChangeEventArgs e, string modifier)
|
||||
{
|
||||
var value = e.Value is bool boolValue && boolValue;
|
||||
|
||||
Modifiers[modifier] = value;
|
||||
|
||||
await SetModifiers();
|
||||
}
|
||||
|
||||
private async Task SetModifiers()
|
||||
{
|
||||
var shortcut = Shortcut ?? "";
|
||||
foreach (var modifier in Modifiers.Keys)
|
||||
{
|
||||
shortcut = shortcut.Replace(modifier, "").Trim().TrimStart(',');
|
||||
}
|
||||
|
||||
shortcut = shortcut.Trim();
|
||||
|
||||
foreach (var modifier in Modifiers.Where(kv => kv.Value).Select(kv => kv.Key).Reverse())
|
||||
{
|
||||
if (shortcut.StartsWith("+"))
|
||||
{
|
||||
shortcut = $"{modifier} {shortcut}";
|
||||
}
|
||||
else
|
||||
{
|
||||
shortcut = $"{modifier}, {shortcut}";
|
||||
}
|
||||
}
|
||||
|
||||
Shortcut = shortcut;
|
||||
|
||||
await ShortcutChanged.InvokeAsync(Shortcut);
|
||||
}
|
||||
|
||||
private async Task ModifierOnClick(string modifier)
|
||||
{
|
||||
Modifiers[modifier] = !Modifiers[modifier];
|
||||
|
||||
await SetModifiers();
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,8 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<span class="me-auto">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="SetDitherRegistryKeyOnClick">Set dither registry key</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="RestartDriverOnClick">Restart driver</button>
|
||||
<button type="button" class="btn btn-secondary" @onclick="SetDitherRegistryKeyOnClick">Set dither registry key</button>
|
||||
<button type="button" class="btn btn-secondary" @onclick="RestartDriverOnClick">Restart driver</button>
|
||||
</span>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
@inject RpcUiClientService _rpcClientService
|
||||
@inject AppState AppState
|
||||
@inject NavigationManager _navigationManager;
|
||||
@inject JSHelper jsHelper;
|
||||
|
||||
<div class="modal" id="presetModal" tabindex="-1" data-bs-backdrop="static" data-bs-keyboard="false" @onfocus="ModalOnFocus">
|
||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
|
||||
@@ -70,10 +71,10 @@
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="mode">Display</label>
|
||||
<select class="form-select" id="mode" @bind="Preset.DisplayId" disabled="@(Preset.primaryDisplay)">
|
||||
@foreach (var display in displayPresets)
|
||||
{
|
||||
<option value="@display.DisplayId">@display.displayName</option>
|
||||
}
|
||||
@foreach (var display in displayPresets)
|
||||
{
|
||||
<option value="@display.DisplayId">@display.displayName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
@@ -356,7 +357,7 @@
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="bits">Bit depth</label>
|
||||
<select class="form-select" id="bits" @bind="Preset.NvDitherBits">
|
||||
<select class="form-select" id="bits" @bind="Preset.NvDitherBits">
|
||||
@foreach (var bits in Enum.GetValues<NvDitherBits>())
|
||||
{
|
||||
<option value="@bits.ToString()">@bits.GetDescription()</option>
|
||||
@@ -544,7 +545,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="() => IsVisible = false">Close</button>
|
||||
<button type="submit" class="btn btn-primary" data-bs-dismiss="@(IsValid() ? "modal" : "")" @onclick="ApplyClick">@(Preset?.IsDisplayPreset == true ? "Apply" : "Save")</button>
|
||||
<button type="submit" class="btn btn-primary" disabled="@(!IsValid())" @onclick="ApplyClick">@(Preset?.IsDisplayPreset == true ? "Apply" : "Save")</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -667,12 +668,20 @@
|
||||
else
|
||||
{
|
||||
var result = await _rpcClientService.CallAsync<bool>("NvService", "UpdatePreset", Preset);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (AfterApply != null)
|
||||
{
|
||||
await AfterApply.Invoke(Preset);
|
||||
}
|
||||
|
||||
await jsHelper.CloseModal("presetModal");
|
||||
IsVisible = false;
|
||||
}
|
||||
|
||||
private async Task ApplyDisplayPreset()
|
||||
|
||||
@@ -90,6 +90,26 @@ else
|
||||
<br />
|
||||
<small class="text-body">Color profile: @preset.ColorProfileSettings.ProfileName</small>
|
||||
}
|
||||
@if (preset.driverSettings?.Any() == true)
|
||||
{
|
||||
<br />
|
||||
<div class="dropdown">
|
||||
<span role="button" class="text-decoration-underline dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside" @onclick="() => DriverSettingsOnClick(preset)">
|
||||
<small>@preset.driverSettings.Count() driver settings changed</small>
|
||||
</span>
|
||||
<form class="dropdown-menu">
|
||||
@if (DriverSettings != null)
|
||||
{
|
||||
<ul class="list-group p-0">
|
||||
@foreach (var setting in DriverSettings)
|
||||
{
|
||||
<li class="list-group-item py-0 px-1"><small>@setting.FriendlyName</small></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -258,6 +278,7 @@ else
|
||||
private NvPreset? CurrentGpuSettingsPreset;
|
||||
private NvGpuInfoDto? CurrentGpuInfo;
|
||||
private bool DitheringVisible;
|
||||
private List<NvSettingItemDto>? DriverSettings;
|
||||
|
||||
private PresetOrder PresetOrder;
|
||||
|
||||
@@ -371,4 +392,14 @@ else
|
||||
|
||||
Presets = Presets?.OrderPresetsBy(PresetOrder);
|
||||
}
|
||||
|
||||
private async Task DriverSettingsOnClick(NvPreset preset)
|
||||
{
|
||||
var driverSettings = await _rpcClientService.CallAsync<List<NvSettingItemDto>>("NvService", "GetDriverSettings", Type.Missing, true);
|
||||
|
||||
if (driverSettings != null)
|
||||
{
|
||||
DriverSettings = driverSettings.Where(s => s.Value != s.DefaultValue && s.State == 2).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ else
|
||||
|
||||
private async Task ElevationMethodInput(ChangeEventArgs e)
|
||||
{
|
||||
var value = e.Value != null ? (ElevationMethod)int.Parse((string)e.Value) : ElevationMethod.None;
|
||||
var value = e.Value != null ? Enum.Parse<ElevationMethod>((string)e.Value) : ElevationMethod.None;
|
||||
await _rpcClientService.CallAsync<bool>("OptionsService", "SetElevationMethod", value);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user