Skip to content

Commit 827157f

Browse files
committed
fix several issues, add remote controls to new UI
1 parent c6c7e1c commit 827157f

File tree

91 files changed

+4236
-2626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+4236
-2626
lines changed

ColorControl.UI/ColorControl.UI.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@
7272
<Content Update="wwwroot\helper.js">
7373
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7474
</Content>
75+
<Content Update="wwwroot\remotes\LG_FactorySVC.jpg">
76+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
77+
</Content>
78+
<Content Update="wwwroot\remotes\LG_MR20GA.jpg">
79+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
80+
</Content>
81+
<Content Update="wwwroot\remotes\LG_MR23GN.jpg">
82+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
83+
</Content>
84+
<Content Update="wwwroot\remotes\Samsung_AA81-00243A.jpg">
85+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
86+
</Content>
87+
<Content Update="wwwroot\remotes\Samsung_BN59-01315B.jpg">
88+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
89+
</Content>
7590
</ItemGroup>
7691

7792
</Project>

ColorControl.UI/Components/Layout/NavMenu.razor

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
@rendermode Constants.RenderMode
55

66
@inject RpcUiClientService _rpcClientService
7-
@inject AppState AppState
8-
@inject NavigationManager _navigationManager;
97

108
<div class="top-row ps-3 navbar navbar-dark">
119
<div class="container-fluid">

ColorControl.UI/Components/Pages/AMD/AmdPresetPage.razor

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
{
4949
<input class="form-check-input me-1" style="font-size: 1rem; visibility: hidden" type="checkbox">
5050
}
51-
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#displaySettings">
51+
<button class="accordion-button collapsed py-2" type="button" data-bs-toggle="collapse" data-bs-target="#displaySettings">
5252
Display
5353
</button>
5454
</span>
@@ -264,10 +264,7 @@
264264
</label>
265265
</div>
266266
}
267-
<div class="mb-2">
268-
<label class="form-range" for="sdrBrightness">SDR brightness (@Preset.SDRBrightness%)</label>
269-
<input class="form-range" type="range" min="0" max="100" @bind="Preset.SDRBrightness" id="sdrBrightness">
270-
</div>
267+
<NullableRangeInput TValue="int" @bind-Value="Preset.SDRBrightness" Id="sdrBrightness" Label="SDR brightness" Unit="%" />
271268
</div>
272269
</div>
273270
</div>

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
else
3030
{
31-
<div class="row mb-3">
31+
<div class="row mb-2">
3232
@if (!Displays.Any())
3333
{
3434
<span>No displays found</span>
@@ -54,6 +54,13 @@ else
5454
}
5555
else
5656
{
57+
<div class="row mb-3">
58+
<div class="form-check form-switch ms-3">
59+
<input class="form-check-input" type="checkbox" role="switch" id="usePerUserSettings" @bind="SelectedDisplay.UsePerUserSettings" @bind:after="AfterUsePerUseSettings">
60+
<label class="form-check-label" for="usePerUserSettings">Use my settings for this device</label>
61+
</div>
62+
</div>
63+
5764
<div class="mb-2 d-flex align-items-center">
5865
<h2>Display Associated Color profiles</h2>
5966
<div class="d-flex ms-auto">
@@ -320,4 +327,19 @@ else
320327

321328
await SelectedDisplayChanged();
322329
}
330+
331+
private async Task AfterUsePerUseSettings()
332+
{
333+
if (SelectedDisplay == null)
334+
{
335+
return;
336+
}
337+
338+
var result = await _rpcClientService.CallAsync<bool>("ColorProfileService", "SetUsePerUserDisplayProfiles", SelectedDisplay.DeviceName, SelectedDisplay.UsePerUserSettings);
339+
340+
if (result)
341+
{
342+
await RefreshDisplays();
343+
}
344+
}
323345
}

ColorControl.UI/Components/Pages/Game/GamePresetPage.razor

Lines changed: 226 additions & 263 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
@rendermode Constants.RenderMode
66

7-
<FieldsModal ModalId="@ModalId" Fields="Fields" Title="@Title" OnConfirm="ConfirmClick"></FieldsModal>
7+
<FieldsModal ModalId="@ModalId" Fields="Fields" Title="@Title" OnConfirm="ConfirmClick" NextModalId="@NextModalId"></FieldsModal>
88

99
@code {
1010
[Parameter]
@@ -19,6 +19,9 @@
1919
[Parameter]
2020
public string ModalId { get; set; } = "confirmModal";
2121

22+
[Parameter]
23+
public string? NextModalId { get; set; }
24+
2225
[Parameter]
2326
public List<FieldDefinition>? ExtraFields { get; set; }
2427

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
@rendermode Constants.RenderMode
66

7-
@inject NavigationManager _navigationManager;
8-
97
@if (Fields == null)
108
{
119
return;
@@ -106,16 +104,7 @@
106104
{
107105
var fieldId = $"fld_{Random.Shared.Next()}";
108106

109-
<div class="mb-2">
110-
<label class="form-range" for="@fieldId">@field.Label (Current value: @field.IntValue)</label>
111-
<input class="form-range" type="range" min="@((int)field.MinValue)" max="@((int)field.MaxValue)" @bind="field.IntValue" id="@fieldId">
112-
@if (field.SubLabel != null)
113-
{
114-
<div id="@(fieldId)_help" class="form-text">
115-
@field.SubLabel
116-
</div>
117-
}
118-
</div>
107+
<RangeInput TValue="int" @bind-Value="field.IntValue" Id="@fieldId" Label="@field.Label" Min="@((int)field.MinValue)" Max="@((int)field.MaxValue)" SubLabel="@field.SubLabel" />
119108
}
120109
}
121110

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
@using ColorControl.Shared.Common;
44

55
@rendermode Constants.RenderMode
6-
7-
@inject NavigationManager _navigationManager;
6+
@inject JSHelper jsHelper;
87

98
<div class="modal" id="@ModalId" tabindex="-1" data-bs-backdrop="static" data-bs-keyboard="false" @onfocus="ModalFocus">
109
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
@@ -41,6 +40,9 @@
4140
[Parameter]
4241
public string? ModalId { get; set; }
4342

43+
[Parameter]
44+
public string? NextModalId { get; set; }
45+
4446
[Parameter]
4547
public string? ConfirmCaption { get; set; } = "Yes";
4648

@@ -120,8 +122,13 @@
120122
}
121123
}
122124

123-
private void OnClose(MouseEventArgs e)
125+
private async Task OnClose(MouseEventArgs e)
124126
{
125127
IsVisible = false;
128+
129+
if (!string.IsNullOrEmpty(NextModalId))
130+
{
131+
await jsHelper.OpenModal(NextModalId);
132+
}
126133
}
127134
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@using ColorControl.Shared.Contracts
2+
@using ColorControl.Shared.EventDispatcher
3+
@using ColorControl.UI.Services;
4+
@using ColorControl.Shared.Common;
5+
6+
@* @rendermode Constants.RenderMode *@
7+
8+
@typeparam TValue where TValue : struct, IComparable, IFormattable, IConvertible, IComparable<TValue>, IEquatable<TValue>
9+
10+
@if (Id != null)
11+
{
12+
<div class="mb-2">
13+
<label class="form-label @(ExtraLabelStyling ?? "")" for="@Id">@Label (@Value@Unit)</label>
14+
<input class="form-range" type="range" min="@(Values?.Min() ?? Min)" max="@(Values?.Max() ?? Max)" @bind="Value" id="@Id" @oninput="e => RangeOnChange(e)">
15+
</div>
16+
}
17+
18+
@code {
19+
20+
[Parameter]
21+
public TValue? Value { get; set; }
22+
23+
[Parameter]
24+
public string? Label { get; set; }
25+
26+
[Parameter]
27+
public string? Unit { get; set; }
28+
29+
[Parameter]
30+
public string? Id { get; set; }
31+
32+
[Parameter]
33+
public TValue? Min { get; set; }
34+
35+
[Parameter]
36+
public TValue? Max { get; set; }
37+
38+
[Parameter]
39+
public List<TValue>? Values { get; set; }
40+
41+
[Parameter]
42+
public EventCallback<TValue?> ValueChanged { get; set; }
43+
44+
[Parameter]
45+
public Func<TValue?, string>? LabelStylingFunc { get; set; }
46+
47+
private string? ExtraLabelStyling;
48+
49+
protected override void OnParametersSet()
50+
{
51+
ExtraLabelStyling = LabelStylingFunc?.Invoke(Value);
52+
Min ??= (TValue)Convert.ChangeType(0, typeof(TValue));
53+
Max ??= (TValue)Convert.ChangeType(100, typeof(TValue));
54+
}
55+
56+
private async Task RangeOnChange(ChangeEventArgs eventArgs)
57+
{
58+
if (typeof(TValue) == typeof(int))
59+
{
60+
Value = (TValue)Convert.ChangeType(int.Parse(eventArgs.Value?.ToString() ?? "0"), typeof(TValue));
61+
62+
}
63+
else if (typeof(TValue) == typeof(uint))
64+
{
65+
Value = (TValue)Convert.ChangeType(uint.Parse(eventArgs.Value?.ToString() ?? "0"), typeof(TValue));
66+
}
67+
68+
await ValueChanged.InvokeAsync(Value);
69+
70+
ExtraLabelStyling = LabelStylingFunc?.Invoke(Value);
71+
}
72+
73+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
@using ColorControl.Shared.Contracts
2+
@using ColorControl.Shared.EventDispatcher
3+
@using ColorControl.UI.Services;
4+
@using ColorControl.Shared.Common;
5+
6+
@* @rendermode Constants.RenderMode *@
7+
8+
@typeparam TValue where TValue : struct, IComparable, IFormattable, IConvertible, IComparable<TValue>, IEquatable<TValue>
9+
10+
@if (Id != null)
11+
{
12+
<div class="mb-2">
13+
<label class="form-label @(ExtraLabelStyling ?? "")" for="@Id">@Label: @GetValueDisplay()@Unit</label>
14+
<input class="form-range" type="range" step="@Step" min="@(Values?.Min() ?? Min)" max="@(Values?.Max() ?? Max)" @bind="Value" id="@Id" @oninput="e => RangeOnChange(e)">
15+
@if (SubLabel != null)
16+
{
17+
<div id="@(Id)_help" class="form-text">
18+
@SubLabel
19+
</div>
20+
}
21+
</div>
22+
}
23+
24+
@code {
25+
26+
[Parameter]
27+
public TValue Value { get; set; }
28+
29+
[Parameter]
30+
public string? Label { get; set; }
31+
32+
[Parameter]
33+
public string? SubLabel { get; set; }
34+
35+
[Parameter]
36+
public string? Unit { get; set; }
37+
38+
[Parameter]
39+
public string? UnitString { get; set; }
40+
41+
[Parameter]
42+
public string? Id { get; set; }
43+
44+
[Parameter]
45+
public TValue? Min { get; set; }
46+
47+
[Parameter]
48+
public TValue? Max { get; set; }
49+
50+
[Parameter]
51+
public TValue? Step { get; set; }
52+
53+
[Parameter]
54+
public List<TValue>? Values { get; set; }
55+
56+
[Parameter]
57+
public EventCallback<TValue> ValueChanged { get; set; }
58+
59+
[Parameter]
60+
public Func<TValue, string>? LabelStylingFunc { get; set; }
61+
62+
[Parameter]
63+
public Func<TValue, string>? CustomLabelFunc { get; set; }
64+
65+
private string? ExtraLabelStyling;
66+
67+
protected override void OnParametersSet()
68+
{
69+
ExtraLabelStyling = LabelStylingFunc?.Invoke(Value);
70+
Min ??= (TValue)Convert.ChangeType(0, typeof(TValue));
71+
Max ??= (TValue)Convert.ChangeType(100, typeof(TValue));
72+
Step ??= (TValue)Convert.ChangeType(1, typeof(TValue));
73+
}
74+
75+
private string? GetValueDisplay()
76+
{
77+
if (CustomLabelFunc != null)
78+
{
79+
return CustomLabelFunc(Value);
80+
}
81+
82+
if (string.IsNullOrEmpty(UnitString))
83+
{
84+
return Value.ToString();
85+
}
86+
87+
if (Value is uint uintValue)
88+
{
89+
return uintValue.ToUnitString(UnitString);
90+
}
91+
if (Value is int intValue)
92+
{
93+
return intValue.ToSignedUnitString(UnitString);
94+
}
95+
96+
return Value.ToString();
97+
}
98+
99+
private async Task RangeOnChange(ChangeEventArgs eventArgs)
100+
{
101+
if (typeof(TValue) == typeof(int))
102+
{
103+
Value = (TValue)Convert.ChangeType(int.Parse(eventArgs.Value?.ToString() ?? "0"), typeof(TValue));
104+
105+
}
106+
else if (typeof(TValue) == typeof(uint))
107+
{
108+
Value = (TValue)Convert.ChangeType(uint.Parse(eventArgs.Value?.ToString() ?? "0"), typeof(TValue));
109+
}
110+
111+
await ValueChanged.InvokeAsync(Value);
112+
113+
ExtraLabelStyling = LabelStylingFunc?.Invoke(Value);
114+
}
115+
116+
}

0 commit comments

Comments
 (0)