diff --git a/README.md b/README.md index d195a19..0d48bae 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Most AV kit ships set to DHCP, and on a bench or a fresh site there's usually no - **Several devices at once** behind a small switch, each with its own lease. - **Spots a USB adapter that has stopped receiving.** Some USB Ethernet adapters keep showing "connected" but quietly stop receiving after a few seconds, which looks exactly like a silent device. If nothing has come in for 20 seconds while the laptop keeps sending, the cable/link step says so and tells you to replug the adapter. Realtek RTL8152/8153 adapters on a driver older than 2019 (including Windows' own 2015 driver) are flagged as soon as you pick them, with where to get the newer driver. - **Wi-Fi and VPN overlap warnings**, with a one-click option to turn Wi-Fi off until you press Stop. -- **Dark and light themes**, with large status text you can read from arm's length. +- **Dark and light themes** and a choice of looks (rack faceplate, Frutiger Aero, Metal Heart), with large status text you can read from arm's length. **Phase 2: visibility** @@ -104,7 +104,7 @@ Each phase ends with a hardware test pass on real AV equipment before the next o | What | Where | |---|---| -| Your settings (last adapter, profile in use, theme) | `%LOCALAPPDATA%\ProDHCPServer\settings.json` | +| Your settings (last adapter, profile in use, look and theme) | `%LOCALAPPDATA%\ProDHCPServer\settings.json` | | Your profiles | `%LOCALAPPDATA%\ProDHCPServer\profiles.json` | | Adapter backup (only while a session runs, or after a crash) | `%ProgramData%\ProDHCPServer\adapter-backup.json` | diff --git a/src/ProDHCPServer.App/App.xaml b/src/ProDHCPServer.App/App.xaml index 27e628e..456c969 100644 --- a/src/ProDHCPServer.App/App.xaml +++ b/src/ProDHCPServer.App/App.xaml @@ -11,184 +11,15 @@ + - pack://application:,,,/Assets/Fonts/#Figtree - pack://application:,,,/Assets/Fonts/#League Spartan - pack://application:,,,/Assets/Fonts/#Figtree - Cascadia Mono, Consolas, Courier New - Segoe Fluent Icons, Segoe MDL2 Assets - - - 13 - 16 - 20 - 40 - 64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/ProDHCPServer.App/App.xaml.cs b/src/ProDHCPServer.App/App.xaml.cs index a6d0f7d..7a3dbce 100644 --- a/src/ProDHCPServer.App/App.xaml.cs +++ b/src/ProDHCPServer.App/App.xaml.cs @@ -27,7 +27,8 @@ protected override void OnStartup(StartupEventArgs e) base.OnStartup(e); var userFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ProDHCPServer"); var settingsStore = new SettingsStore(Path.Combine(userFolder, "settings.json")); - Theme.Apply(settingsStore.Load().Theme); + var startSettings = settingsStore.Load(); + Theme.Apply(startSettings.Theme, startSettings.Look); if (!Elevation.IsAdministrator()) { diff --git a/src/ProDHCPServer.App/Assets/Fonts/OFL-Orbitron.txt b/src/ProDHCPServer.App/Assets/Fonts/OFL-Orbitron.txt new file mode 100644 index 0000000..91ede45 --- /dev/null +++ b/src/ProDHCPServer.App/Assets/Fonts/OFL-Orbitron.txt @@ -0,0 +1,93 @@ +Copyright 2018 The Orbitron Project Authors (https://github.com/theleagueof/orbitron), with Reserved Font Name: "Orbitron" + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/ProDHCPServer.App/Assets/Fonts/Orbitron-Bold.ttf b/src/ProDHCPServer.App/Assets/Fonts/Orbitron-Bold.ttf new file mode 100644 index 0000000..3252adc Binary files /dev/null and b/src/ProDHCPServer.App/Assets/Fonts/Orbitron-Bold.ttf differ diff --git a/src/ProDHCPServer.App/Converters.cs b/src/ProDHCPServer.App/Converters.cs index ca50b70..7532a7a 100644 --- a/src/ProDHCPServer.App/Converters.cs +++ b/src/ProDHCPServer.App/Converters.cs @@ -1,6 +1,7 @@ using System.Globalization; using System.Windows; using System.Windows.Data; +using System.Windows.Markup; using ProDHCPServer.Core; using ProDHCPServer.Core.Status; @@ -36,6 +37,24 @@ public sealed class StateBrushConverter : IValueConverter public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } +/// +/// IsRunning → the Start/Stop button's Background or Foreground (the ConverterParameter): solid ink to start, a quiet +/// button to stop, since the status field already says the server is live. Looked up again after a look change. +/// +public sealed class RunningBrushConverter : IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + bool running = value is true; + var key = parameter as string == "Foreground" + ? (running ? "TextPrimary" : "AccentText") + : (running ? "RaisedBg" : "AccentBrush"); + return Application.Current.TryFindResource(key); + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); +} + /// StepState → a short word for screen readers and the colour-blind. public sealed class StateWordConverter : IValueConverter { @@ -100,13 +119,29 @@ public object Convert(object? value, Type targetType, object? parameter, Culture public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } -/// ActualHeight → a corner radius of half the height, so a Border is a true pill or circle at any size. -public sealed class PillRadiusConverter : IValueConverter +/// +/// A corner radius of a Border's height times the look's ButtonCornerScale, which the Border carries in its Tag +/// (0.5 makes a true pill or circle at any size, 0 a square). A fixed large radius would draw ovals in WPF, and the Tag +/// lets the radius follow a live look change. Used as CornerRadius="{local:CornerScale}". +/// +public sealed class CornerScaleExtension : MarkupExtension, IMultiValueConverter { - public static readonly PillRadiusConverter Instance = new(); + public override object ProvideValue(IServiceProvider serviceProvider) => new MultiBinding + { + Converter = this, + Bindings = + { + new Binding(nameof(FrameworkElement.ActualHeight)) { RelativeSource = RelativeSource.Self }, + new Binding(nameof(FrameworkElement.Tag)) { RelativeSource = RelativeSource.Self }, + }, + }.ProvideValue(serviceProvider); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => - new CornerRadius(value is double h && h > 0 ? h / 2 : 0); + public object Convert(object[] values, Type targetType, object? parameter, CultureInfo culture) + { + var height = values.Length > 0 && values[0] is double h ? h : 0; + var scale = values.Length > 1 && values[1] is double d ? d : 0.5; + return new CornerRadius(height > 0 ? height * scale : 0); + } - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException(); + public object[] ConvertBack(object value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotSupportedException(); } diff --git a/src/ProDHCPServer.App/MainWindow.xaml b/src/ProDHCPServer.App/MainWindow.xaml index c47d087..34fd4f9 100644 --- a/src/ProDHCPServer.App/MainWindow.xaml +++ b/src/ProDHCPServer.App/MainWindow.xaml @@ -12,7 +12,7 @@ Title="ProDHCPServer" Width="1320" Height="860" MinWidth="900" MinHeight="600" WindowStartupLocation="CenterScreen" Background="{DynamicResource WindowBg}" - FontFamily="{StaticResource TextFont}" + FontFamily="{DynamicResource TextFont}" Closing="OnClosing" SourceInitialized="OnSourceInitialized"> @@ -40,7 +40,8 @@ - + + @@ -87,12 +88,15 @@ ItemsSource="{Binding Settings.Profiles}" SelectedItem="{Binding Settings.SelectedProfile}" DisplayMemberPath="Display" IsEnabled="{Binding SettingsEditable}" ToolTip="The saved settings Start uses: subnet, pool, lease time and DHCP options" /> - + - + - + + - - + - -