-
Notifications
You must be signed in to change notification settings - Fork 0
Json safe float/power control hub app start #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
819cc39
Json Safe float values
k3ldar 3d6b02a
Start of PowerControlHubApp early work in progress
k3ldar 99b7d86
Re-add VoltageSensorHandler
k3ldar 3cb0d8d
after initial compile
k3ldar 8b52484
Merge branch 'main' into jsonSafeFloat/PowerControlHubApp_Start
k3ldar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version = "1.0" encoding = "UTF-8" ?> | ||
| <Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:local="clr-namespace:PowerControlHubApp" | ||
| x:Class="PowerControlHubApp.App"> | ||
| <Application.Resources> | ||
| <ResourceDictionary> | ||
| <ResourceDictionary.MergedDictionaries> | ||
| <ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
| <ResourceDictionary Source="Resources/Styles/AppColorsLight.xaml" /> | ||
| <ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
| </ResourceDictionary.MergedDictionaries> | ||
| </ResourceDictionary> | ||
| </Application.Resources> | ||
| </Application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using PowerControlHubApp.Services; | ||
|
|
||
| namespace PowerControlHubApp | ||
| { | ||
| public partial class App : Application | ||
| { | ||
| public App(ThemeService themeService) | ||
| { | ||
| InitializeComponent(); | ||
| // Apply after InitializeComponent so Application.Resources is populated. | ||
| themeService.ApplySaved(); | ||
| } | ||
|
|
||
| protected override Window CreateWindow(IActivationState? activationState) | ||
| { | ||
| var window = new Window(new AppShell()); | ||
|
|
||
| #if WINDOWS | ||
| window.HandlerChanged += OnWindowHandlerChanged; | ||
| #endif | ||
|
|
||
| return window; | ||
| } | ||
|
|
||
| #if WINDOWS | ||
| private static void OnWindowHandlerChanged(object? sender, EventArgs e) | ||
| { | ||
| if (sender is not Window mauiWindow) | ||
| return; | ||
|
|
||
| // Detach — only needs to run once | ||
| mauiWindow.HandlerChanged -= OnWindowHandlerChanged; | ||
|
|
||
| if (mauiWindow.Handler?.PlatformView is not Microsoft.UI.Xaml.Window nativeWindow) | ||
| return; | ||
|
|
||
| var appWindow = nativeWindow.AppWindow; | ||
|
|
||
| // Restore saved position and size (stored in physical pixels) | ||
| int savedW = Preferences.Get("win_w", 0); | ||
| int savedH = Preferences.Get("win_h", 0); | ||
| int savedX = Preferences.Get("win_x", int.MinValue); | ||
| int savedY = Preferences.Get("win_y", int.MinValue); | ||
|
|
||
| if (savedW > 0 && savedH > 0) | ||
| appWindow.Resize(new Windows.Graphics.SizeInt32(savedW, savedH)); | ||
|
|
||
| if (savedX != int.MinValue && savedY != int.MinValue) | ||
| appWindow.Move(new Windows.Graphics.PointInt32(savedX, savedY)); | ||
|
|
||
| // Persist position/size whenever the window moves or is resized | ||
| appWindow.Changed += (aw, args) => | ||
| { | ||
| if (!args.DidPositionChange && !args.DidSizeChange) | ||
| return; | ||
|
|
||
| Preferences.Set("win_x", aw.Position.X); | ||
| Preferences.Set("win_y", aw.Position.Y); | ||
| Preferences.Set("win_w", aw.Size.Width); | ||
| Preferences.Set("win_h", aw.Size.Height); | ||
| }; | ||
| } | ||
| #endif | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <Shell | ||
| x:Class="PowerControlHubApp.AppShell" | ||
| xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:views="clr-namespace:PowerControlHubApp.Views" | ||
| Title="PowerControlHub" | ||
| Shell.NavBarIsVisible="False"> | ||
|
|
||
| <ShellContent | ||
| x:Name="DashboardPage" | ||
| Title="Dashboard" | ||
| Route="DashboardPage" | ||
| ContentTemplate="{DataTemplate views:DashboardPage}" /> | ||
|
|
||
| <ShellContent | ||
| x:Name="SettingsPage" | ||
| Title="Settings" | ||
| Route="SettingsPage" | ||
| ContentTemplate="{DataTemplate views:SettingsPage}" /> | ||
|
|
||
| </Shell> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace PowerControlHubApp | ||
| { | ||
| public partial class AppShell : Shell | ||
| { | ||
| public AppShell() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using System.Globalization; | ||
|
|
||
| namespace PowerControlHubApp.Converters; | ||
|
|
||
| /// <summary>Returns true when the integer value is greater than zero.</summary> | ||
| public class IntToBoolConverter : IValueConverter | ||
| { | ||
| public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => value is int i && i > 0; | ||
|
|
||
| public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <summary>Returns true when the integer value equals zero (inverse of IntToBoolConverter).</summary> | ||
| public class IntToInverseBoolConverter : IValueConverter | ||
| { | ||
| public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => value is not int i || i == 0; | ||
|
|
||
| public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <summary>Returns true when the string is non-empty.</summary> | ||
| public class StringToBoolConverter : IValueConverter | ||
| { | ||
| public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => value is string s && !string.IsNullOrEmpty(s); | ||
|
|
||
| public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => throw new NotImplementedException(); | ||
| } | ||
|
|
||
| /// <summary>Returns a green colour for true (connected) and a red colour for false (disconnected).</summary> | ||
| public class BoolToStatusColorConverter : IValueConverter | ||
| { | ||
| public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => value is true ? Color.FromArgb("#44cc44") : Color.FromArgb("#cc4444"); | ||
|
|
||
| public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => throw new NotImplementedException(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="PowerControlHubApp.MainPage"> | ||
|
|
||
| <ScrollView> | ||
| <VerticalStackLayout | ||
| Padding="30,0" | ||
| Spacing="25"> | ||
| <Image | ||
| Source="dotnet_bot.png" | ||
| HeightRequest="185" | ||
| Aspect="AspectFit" | ||
| SemanticProperties.Description="dot net bot in a submarine number ten" /> | ||
|
|
||
| <Label | ||
| Text="Hello, World!" | ||
| Style="{StaticResource Headline}" | ||
| SemanticProperties.HeadingLevel="Level1" /> | ||
|
|
||
| <Label | ||
| Text="Welcome to .NET Multi-platform App UI" | ||
| Style="{StaticResource SubHeadline}" | ||
| SemanticProperties.HeadingLevel="Level2" | ||
| SemanticProperties.Description="Welcome to dot net Multi platform App U I" /> | ||
|
|
||
| <Button | ||
| x:Name="CounterBtn" | ||
| Text="Click me" | ||
| SemanticProperties.Hint="Counts the number of times you click" | ||
| Clicked="OnCounterClicked" | ||
| HorizontalOptions="Fill" /> | ||
| </VerticalStackLayout> | ||
| </ScrollView> | ||
|
|
||
| </ContentPage> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| namespace PowerControlHubApp | ||
| { | ||
| public partial class MainPage : ContentPage | ||
| { | ||
| int count = 0; | ||
|
|
||
| public MainPage() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| private void OnCounterClicked(object? sender, EventArgs e) | ||
| { | ||
| count++; | ||
|
|
||
| if (count == 1) | ||
| CounterBtn.Text = $"Clicked {count} time"; | ||
| else | ||
| CounterBtn.Text = $"Clicked {count} times"; | ||
|
|
||
| SemanticScreenReader.Announce(CounterBtn.Text); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.