Skip to content

Commit

Permalink
fix issues with new UI, add color profiles, add sdr brightness for AMD
Browse files Browse the repository at this point in the history
  • Loading branch information
Maassoft committed Sep 1, 2024
1 parent 4d2ca8a commit f42a46e
Show file tree
Hide file tree
Showing 95 changed files with 12,267 additions and 10,143 deletions.
5 changes: 4 additions & 1 deletion ColorControl.UI/Blazor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ColorControl.Shared.Contracts;
using ColorControl.Shared.Services;
using ColorControl.UI.Services;

namespace ColorControl.UI;

Expand All @@ -15,6 +15,9 @@ public static void Start(Config? config = null)

builder.Services.AddSingleton<AppState>(new AppState { SelectedTheme = (config?.UseDarkMode ?? true) ? "dark" : "light" });
builder.Services.AddTransient<RpcUiClientService>();
builder.Services.AddTransient<JSHelper>();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSingleton<NotificationService>();
builder.WebHost.ConfigureKestrel(o => o.ListenAnyIP(config?.UiPort > 0 ? config.UiPort : 5000));

var app = builder.Build();
Expand Down
16 changes: 16 additions & 0 deletions ColorControl.UI/ColorControl.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@

<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\MHC2Gen\MHC2Gen.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="Components\Pages\ColorProfile\ColorProfilePage.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Components\Pages\Generic\FieldDefs.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
Expand All @@ -25,6 +29,9 @@
<Content Update="Components\Pages\Game\GameSummary.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Components\Pages\Generic\NotificationsComponent.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Components\Pages\Generic\TriggerInput.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
Expand Down Expand Up @@ -52,6 +59,15 @@
<Content Update="Components\Pages\Samsung\SamsungServiceMenu.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="wwwroot\app.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\favicon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\helper.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
26 changes: 19 additions & 7 deletions ColorControl.UI/Components/App.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
@using ColorControl.Shared.Contracts
@using ColorControl.Shared.Services
@using ColorControl.Shared.Common
@using ColorControl.Shared.Contracts
@using ColorControl.UI.Services
@using ColorControl.UI.Components.Pages.Generic
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage

@inject AppState AppState
@inject RpcUiClientService ClientService;
@inject NavigationManager _navigationManager;
@inject RpcUiClientService _rpcClientService
@inject NavigationManager _navigationManager
@inject NotificationService _notificationService
@inject ProtectedSessionStorage _sessionStorage

@implements IDisposable
@attribute [StreamRendering]

Expand All @@ -15,28 +22,33 @@
<base href="/" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="ColorControl.UI.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />

<HeadOutlet />
</head>

<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
<NotificationsComponent></NotificationsComponent>
</body>

</html>
@code {
private Config? Config;

protected override async Task OnInitializedAsync()
{
var config = await ClientService.CallAsync<Config>("OptionsService", "GetConfig");
Config ??= await _rpcClientService.CallAsync<Config>("OptionsService", "GetConfig");

var newTheme = config.UseDarkMode ? "dark" : "light";
var newTheme = Config?.UseDarkMode == true ? "dark" : "light";

if (newTheme != AppState.SelectedTheme)
{
AppState.SelectedTheme = config.UseDarkMode ? "dark" : "light";
AppState.SelectedTheme = Config?.UseDarkMode == true ? "dark" : "light";
_navigationManager.Refresh();
}

Expand Down
25 changes: 16 additions & 9 deletions ColorControl.UI/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using ColorControl.Shared.Contracts
@using ColorControl.Shared.Services;
@using ColorControl.UI.Services;
@using ColorControl.UI.Services

@rendermode InteractiveServer

Expand Down Expand Up @@ -28,28 +29,34 @@
@foreach (var module in modules.Where(m => m.IsActive))
{
<div class="nav-item px-3">
<NavLink class="nav-link px-3" href="@module.Link">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> @module.DisplayName
<NavLink class="nav-link px-3 align-items-baseline" href="@module.Link">
<span class="bi bi-@module.GetIconClass()" aria-hidden="true"></span> @module.DisplayName
</NavLink>
</div>
}
}

<div class="nav-item px-3">
<NavLink class="nav-link px-3" href="options">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Options
<NavLink class="nav-link px-3 align-items-baseline" href="options">
<span class="bi bi-gear-fill" aria-hidden="true"></span> Options
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link px-3" href="logging">
<span class="bi bi-list-logging-nav-menu" aria-hidden="true"></span> Logging
<NavLink class="nav-link px-3 align-items-baseline" href="ColorProfile">
<span class="bi bi-palette-fill" aria-hidden="true"></span> Color Profiles
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link px-3" href="info">
<span class="bi bi-list-logging-nav-menu" aria-hidden="true"></span> Info
<NavLink class="nav-link px-3 align-items-baseline" href="logging">
<span class="bi bi-list-columns-reverse" aria-hidden="true"></span> Logging
</NavLink>
</div>

<div class="nav-item px-3">
<NavLink class="nav-link px-3 align-items-baseline" href="info">
<span class="bi bi-info-circle-fill" aria-hidden="true"></span> Info
</NavLink>
</div>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion ColorControl.UI/Components/Layout/TopMenu.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@using ColorControl.Shared.Contracts
@using ColorControl.Shared.Services
@using ColorControl.UI.Services
@inherits LayoutComponentBase

@inject AppState AppState
Expand Down
6 changes: 3 additions & 3 deletions ColorControl.UI/Components/Pages/AMD/AmdPresetPage.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@using ColorControl.Shared.Contracts
@using ColorControl.Shared.Contracts.AMD
@using ColorControl.Shared.Services;
@using ColorControl.UI.Components.Pages.Generic
@using ColorControl.Shared.Common;
@using ColorControl.UI.Services

@rendermode InteractiveServer

@inject RpcUiClientService _rpcClientService

<div class="modal" id="presetModal" tabindex="-1" data-bs-backdrop="static" data-bs-keyboard="false" @onfocus="ModalOnFocus">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">@(Preset?.IsDisplayPreset == true ? $"Settings for display {Preset?.displayName}" : Preset?.id == 0 ? $"Settings for new preset" : $"Settings of preset {Preset?.IdOrName}")</h5>
Expand Down Expand Up @@ -316,7 +316,7 @@
selectedVirtualResolution = Preset?.DisplayConfig.Resolution?.GetVirtualString();
selectedRefreshRate = Preset?.DisplayConfig.RefreshRate?.ToString();

if (Preset?.IsDisplayPreset != true)
if (Preset?.IsDisplayPreset == false)
{
displayPresets = await _rpcClientService.CallAsync<List<AmdPreset>>("AmdService", "GetDisplayPresets");
}
Expand Down
4 changes: 2 additions & 2 deletions ColorControl.UI/Components/Pages/AMD/AmdSettings.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@using ColorControl.Shared.Contracts
@using ColorControl.Shared.Contracts.AMD
@using ColorControl.Shared.Services;
@using ColorControl.UI.Services;
@using ColorControl.Shared.Common;
@using ColorControl.UI.Components.Pages.Generic

@rendermode InteractiveServer
@inject RpcUiClientService _rpcClientService

<div class="modal" id="settingsModal" tabindex="-1" @onfocus="OnFocus">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">AMD settings</h5>
Expand Down
20 changes: 16 additions & 4 deletions ColorControl.UI/Components/Pages/AMD/AmdSummary.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@using ColorControl.Shared.Common
@using ColorControl.Shared.Contracts
@using ColorControl.Shared.Contracts.AMD
@using ColorControl.Shared.Services;
@using ColorControl.UI.Services;
@using ColorControl.UI.Components.Pages.Generic
@using ColorControl.UI.Generics
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
Expand Down Expand Up @@ -92,6 +92,10 @@ else
</div>
<div class="row mb-3">
<div class="col">
@if (!Presets.Any())
{
<span>No presets found</span>
}
<div class="list-group">
@foreach (var preset in Presets)
{
Expand All @@ -106,11 +110,21 @@ else
}
</h5>
</div>
<span>
<span class="d-none d-lg-block">
<button class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#confirmModal" @onclick="() => PresetOnDeleteClick(preset)" @onclick:preventDefault @onclick:stopPropagation>Delete</button>
<button class="btn btn-secondary btn-sm" data-bs-toggle="modal" data-bs-target="#presetModal" @onclick="() => PresetOnCloneClick(preset)" @onclick:preventDefault @onclick:stopPropagation>Clone</button>
<button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#presetModal" @onclick="() => PresetOnEditClick(preset)" @onclick:preventDefault @onclick:stopPropagation>Edit</button>
</span>
<div class="d-lg-none" @onclick:preventDefault @onclick:stopPropagation>
<button type="button" class="btn btn-outline-secondary" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-three-dots-vertical"></i>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#confirmModal" @onclick="() => PresetOnDeleteClick(preset)">Delete</a></li>
<li><a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#presetModal" @onclick="() => PresetOnCloneClick(preset)">Clone</a></li>
<li><a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#presetModal" @onclick="() => PresetOnEditClick(preset)">Edit</a></li>
</ul>
</div>
</div>
<p class="mb-1">@preset.DisplayConfig.Resolution.ToString() @@ @preset.DisplayConfig.RefreshRate.ToString()Hz @(preset.applyColorData ? preset.colorDepth : "")</p>
<small class="text-muted">@preset.shortcut</small>
Expand All @@ -124,7 +138,6 @@ else
@code {
private List<AmdPreset>? Presets;
private List<AmdPreset>? DisplayPresets;
private List<VirtualResolution>? Resolutions;

private AmdPreset? CurrentPreset;

Expand All @@ -134,7 +147,6 @@ else
{
await RefreshPresets();
DisplayPresets = await _rpcClientService.CallAsync<List<AmdPreset>>("AmdService", "GetDisplayPresets");
Resolutions = await _rpcClientService.CallAsync<List<VirtualResolution>>("AmdService", "GetAvailableResolutionsV2", DisplayPresets?.FirstOrDefault());
}

protected override async Task OnAfterRenderAsync(bool firstTime)
Expand Down
Loading

0 comments on commit f42a46e

Please sign in to comment.