Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PowerControlHub/PowerControlHub.vcxproj

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion PowerControlHubApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using PowerControlHubApp.Services;
using static PowerControlHubApp.Internal.Constants;
using static PowerControlHubApp.Resources.Localization.AppResources;

#if WINDOWS
using WinRT.Interop;
Expand Down Expand Up @@ -39,11 +40,12 @@ public App(

// Apply after InitializeComponent so Application.Resources is populated.
ThemeService.ApplySaved();
LanguageService.ApplySaved();
}

protected override Window CreateWindow(IActivationState activationState)
{
var window = new Window(new AppShell());
Window window = new Window(new AppShell());

#if WINDOWS
window.HandlerChanged += OnWindowHandlerChanged;
Expand Down
13 changes: 7 additions & 6 deletions PowerControlHubApp/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,43 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:PowerControlHubApp.Views"
xmlns:localization="clr-namespace:PowerControlHubApp.Resources.Localization"
Title="PowerControlHub"
Shell.NavBarIsVisible="False">

<ShellContent
x:Name="DashboardPage"
Title="Dashboard"
Title="{x:Static localization:AppResources.Dashboard}"
Route="DashboardPage"
ContentTemplate="{DataTemplate views:DashboardPage}" />

<ShellContent
x:Name="RelayConfigPage"
Title="Relays"
Title="{x:Static localization:AppResources.Relays}"
Route="RelayConfigPage"
ContentTemplate="{DataTemplate views:RelayConfigPage}" />

<ShellContent
x:Name="SensorConfigPage"
Title="Local Sensors"
Title="{x:Static localization:AppResources.LocalSensorsTitle}"
Route="SensorConfigPage"
ContentTemplate="{DataTemplate views:LocalSensorConfigPage}" />

<ShellContent
x:Name="ExternalSensorConfigPage"
Title="External Sensors"
Title="{x:Static localization:AppResources.ExternalSensors}"
Route="ExternalSensorConfigPage"
ContentTemplate="{DataTemplate views:ExternalSensorConfigPage}" />

<ShellContent
x:Name="SettingsPage"
Title="Settings"
Title="{x:Static localization:AppResources.Settings}"
Route="SettingsPage"
ContentTemplate="{DataTemplate views:SettingsPage}" />

<ShellContent
x:Name="SystemPage"
Title="System"
Title="{x:Static localization:AppResources.SystemTitle}"
Route="SystemPage"
ContentTemplate="{DataTemplate views:SystemPage}" />

Expand Down
2 changes: 1 addition & 1 deletion PowerControlHubApp/Converters/SingleOrArrayConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSeri
if (reader.TokenType == JsonTokenType.StartArray)
return JsonSerializer.Deserialize<T[]>(ref reader, options)!;

var single = JsonSerializer.Deserialize<T>(ref reader, options);
T single = JsonSerializer.Deserialize<T>(ref reader, options);
return [single!];
}

Expand Down
9 changes: 9 additions & 0 deletions PowerControlHubApp/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Used as binding in xaml", Scope = "member", Target = "~P:PowerControlHubApp.ViewModels.SystemViewModel.LanguageOptions")]
[assembly: SuppressMessage("Style", "CC0009:Avoid magic numbers (and un-named literals)", Justification = "<Pending>", Scope = "member", Target = "~M:PowerControlHubApp.Services.LanguageService.BuildAvailableCultures~System.Collections.Generic.List{System.Globalization.CultureInfo}")]
241 changes: 38 additions & 203 deletions PowerControlHubApp/Internal/Constants.cs

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions PowerControlHubApp/MainPage.xaml

This file was deleted.

24 changes: 0 additions & 24 deletions PowerControlHubApp/MainPage.xaml.cs

This file was deleted.

22 changes: 11 additions & 11 deletions PowerControlHubApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class MauiProgram

public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
MauiAppBuilder builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
Expand All @@ -26,7 +26,7 @@ public static MauiApp CreateMauiApp()
// Connections — each owns its own HttpClient (one persistent TCP socket)
builder.Services.AddSingleton<DashboardConnection>(sp =>
{
var connection = new DashboardConnection();
DashboardConnection connection = new DashboardConnection();
string ip = Preferences.Get(KeyDeviceIpAddress, string.Empty);
string port = Preferences.Get(KeyDeviceIpPort, DefaultDeviceIpPort);

Expand All @@ -48,7 +48,7 @@ public static MauiApp CreateMauiApp()
// Register ConfigConnection as the inner singleton
builder.Services.AddSingleton<ConfigConnection>(sp =>
{
var connection = new ConfigConnection(
ConfigConnection connection = new ConfigConnection(
sp.GetRequiredService<IMessageBus>(),
sp.GetRequiredService<ILogger<ConfigConnection>>());

Expand Down Expand Up @@ -78,7 +78,7 @@ public static MauiApp CreateMauiApp()
// Legacy service — kept as thin facade that delegates to the two connections
builder.Services.AddSingleton<PowerHubService>(sp =>
{
var service = new PowerHubService(
PowerHubService service = new PowerHubService(
sp.GetRequiredService<IDashboardConnection>(),
sp.GetRequiredService<IConfigConnection>(),
sp.GetRequiredService<IMessageBus>());
Expand All @@ -92,6 +92,7 @@ public static MauiApp CreateMauiApp()
builder.Services.AddSingleton<SensorMetaCache>();
builder.Services.AddSingleton<LogService>();
builder.Services.AddSingleton<ThemeService>();
builder.Services.AddSingleton<LanguageService>();
builder.Services.AddSingleton<RelayStore>();
builder.Services.AddSingleton<TimeSyncService>();

Expand All @@ -114,15 +115,14 @@ public static MauiApp CreateMauiApp()
builder.Services.AddTransient<NextionSettingsViewModel>();
builder.Services.AddTransient<XpdzToneSettingsViewModel>();

// Pages
builder.Services.AddSingleton<DashboardPage>();
builder.Services.AddSingleton<SettingsPage>();
builder.Services.AddSingleton<RelayConfigPage>();
builder.Services.AddSingleton<SystemPage>();
builder.Services.AddTransient<DashboardPage>();
builder.Services.AddTransient<SettingsPage>();
builder.Services.AddTransient<RelayConfigPage>();
builder.Services.AddTransient<SystemPage>();
builder.Services.AddTransient<RelayDetailPage>();
builder.Services.AddSingleton<ExternalSensorConfigPage>();
builder.Services.AddTransient<ExternalSensorConfigPage>();
builder.Services.AddTransient<ExternalSensorDetailPage>();
builder.Services.AddSingleton<LocalSensorConfigPage>();
builder.Services.AddTransient<LocalSensorConfigPage>();
builder.Services.AddTransient<LocalSensorDetailPage>();
builder.Services.AddTransient<TimeSettingsPage>();
builder.Services.AddTransient<LocationSettingsPage>();
Expand Down
1 change: 1 addition & 0 deletions PowerControlHubApp/Models/ExternalSensorConfigModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using static PowerControlHubApp.Internal.Constants;
using static PowerControlHubApp.Resources.Localization.AppResources;

namespace PowerControlHubApp.Models
{
Expand Down
19 changes: 10 additions & 9 deletions PowerControlHubApp/Models/Json/OtaStatusModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using static PowerControlHubApp.Internal.Constants;
using static PowerControlHubApp.Resources.Localization.AppResources;

namespace PowerControlHubApp.Models.Json;

Expand Down Expand Up @@ -29,23 +30,23 @@ public class OtaStatusModel
public string Auto { get; set; } = OtaAuto_Off;

public bool UpdateAvailable =>
string.Equals(State, OtaState_Available, StringComparison.OrdinalIgnoreCase);
String.Equals(State, OtaState_Available, StringComparison.OrdinalIgnoreCase);

public bool IsBusy =>
State is OtaState_Checking or OtaState_Downloading or OtaState_Rebooting;

public bool HasFailed =>
string.Equals(State, OtaState_Failed, StringComparison.OrdinalIgnoreCase);
String.Equals(State, OtaState_Failed, StringComparison.OrdinalIgnoreCase);

/// <summary>Human-readable label shown in the update banner.</summary>
public string BannerLabel => State switch
{
var s when string.Equals(s, OtaState_Available, StringComparison.OrdinalIgnoreCase) => string.Format(OtaLabel_Available, AvailableVersion, CurrentVersion),
var s when string.Equals(s, OtaState_Checking, StringComparison.OrdinalIgnoreCase) => OtaLabel_Checking,
var s when string.Equals(s, OtaState_Downloading, StringComparison.OrdinalIgnoreCase) => OtaLabel_Downloading,
var s when string.Equals(s, OtaState_Rebooting, StringComparison.OrdinalIgnoreCase) => OtaLabel_Rebooting,
var s when string.Equals(s, OtaState_Failed, StringComparison.OrdinalIgnoreCase) => OtaLabel_Failed,
var s when string.Equals(s, OtaState_UpToDate, StringComparison.OrdinalIgnoreCase) => string.Format(OtaLabel_Uptodate, CurrentVersion),
_ => string.Empty
string s when String.Equals(s, OtaState_Available, StringComparison.OrdinalIgnoreCase) => String.Format(OtaLabelAvailable, AvailableVersion, CurrentVersion),
string s when String.Equals(s, OtaState_Checking, StringComparison.OrdinalIgnoreCase) => OtaLabelChecking,
string s when String.Equals(s, OtaState_Downloading, StringComparison.OrdinalIgnoreCase) => OtaLabelDownloading,
string s when String.Equals(s, OtaState_Rebooting, StringComparison.OrdinalIgnoreCase) => OtaLabelRebooting,
string s when String.Equals(s, OtaState_Failed, StringComparison.OrdinalIgnoreCase) => OtaLabelFailed,
string s when String.Equals(s, OtaState_UpToDate, StringComparison.OrdinalIgnoreCase) => String.Format(OtaLabelUptodate, CurrentVersion),
_ => String.Empty
};
}
Loading
Loading