mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-14 04:35:07 -05:00
ColorScheme, ColorSchemeRegistry, ColorSchemeSerializer and the Schemes folder move into the toolkit-neutral library, keeping the OpenNest namespace, so the Avalonia app can share the built-in palettes, the scheme files and the recolour-on-open rule. ColorScheme is now pure colour data with a Version that changes with any colour. Its GDI+ pens and brushes move to GdiSchemeTools in the WinForms project (still one set per thread, rebuilt after a colour change), reached through scheme.Gdi(). The legacy part outline uses ColorShade.Dark, a port of ControlPaint.Dark's HLS arithmetic; a WinForms test compares the two across a colour sweep on Windows. The registry no longer walks Application.OpenForms: Apply raises Applied, and EditNestForm subscribes once to recolour every open nest window as before. The saved scheme is read under the same ActiveColorScheme setting (SavedSchemeName/ApplySaved for the shared user-settings file); WinForms still reads it through Settings.Default. Schemes/*.json now copies beside both desktop apps from OpenNest.Desktop. Pure scheme tests move to OpenNest.Desktop.Tests, with new ones for built-in round trips, scheme files, bad files, the saved name and the recolour rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using System.Drawing;
|
|
|
|
namespace OpenNest.Desktop.Tests;
|
|
|
|
public class ColorShadeTests
|
|
{
|
|
// Expected values from an independent transcription of WinForms' ControlPaint.HLSColor;
|
|
// OpenNest.WinForms.Tests compares against ControlPaint.Dark itself on Windows.
|
|
[Theory]
|
|
[InlineData(255, 127, 80, 113, 31, 0)]
|
|
[InlineData(0, 0, 0, 0, 0, 0)]
|
|
[InlineData(255, 255, 255, 85, 85, 85)]
|
|
[InlineData(205, 92, 92, 77, 23, 23)]
|
|
[InlineData(128, 128, 128, 42, 42, 42)]
|
|
[InlineData(90, 150, 200, 23, 50, 72)]
|
|
[InlineData(255, 0, 0, 85, 0, 0)]
|
|
[InlineData(12, 34, 250, 2, 11, 85)]
|
|
public void DarkMatchesTheWinFormsShade(int r, int g, int b, int er, int eg, int eb)
|
|
{
|
|
Assert.Equal(Color.FromArgb(er, eg, eb), ColorShade.Dark(Color.FromArgb(r, g, b)));
|
|
}
|
|
|
|
[Fact]
|
|
public void DarkIgnoresAlphaAndReturnsAnOpaqueColor()
|
|
{
|
|
// The WinForms selection fill: alpha 90 over (150, 200, 255).
|
|
Assert.Equal(Color.FromArgb(0, 65, 136), ColorShade.Dark(Color.FromArgb(90, 150, 200, 255)));
|
|
}
|
|
|
|
[Fact]
|
|
public void SchemesWithoutAPartOutlineDarkenTheFill()
|
|
{
|
|
var classic = ColorSchemeRegistry.Get("Classic");
|
|
var workshop = ColorSchemeRegistry.Get("Workshop");
|
|
|
|
Assert.Equal(Color.FromArgb(113, 31, 0), classic.GetPartOutlineColor(Color.Coral));
|
|
Assert.Equal(Color.FromArgb(48, 48, 48), workshop.GetPartOutlineColor(Color.Coral));
|
|
}
|
|
}
|