Palette: capitalization inconsistency and enum discussion
See original GitHub issueFeature Suggestion
The recent palette refactor is great. It is almost a complete replacement for the wrapper I had in place so that users could select a palette. All that is missing is an enum to chose palettes from.
Code example
I took the public Palettes from here and used regex to make the enum.
Users can select their palette with a dropdown and the enum value gets saved/loaded from settings
private PaletteHost.Palettes _Palette = (PaletteHost.Palettes)Properties.Settings.Default.SEYR_Palette;
[
Category("User Parameters"),
Description("Choose from ScottPlot palettes"),
DisplayName("Plot Window Palette")
]
public PaletteHost.Palettes Palette
{
get => _Palette;
set
{
_Palette = value;
Properties.Settings.Default.SEYR_Palette = (int)_Palette;
Properties.Settings.Default.Save();
}
}
Mini-bug
The name matching method in my screenshot works (might be a performance hit, but I haven’t noticed so far) - but, I did notice that SnowStorm != Snowstorm. So, I just changed it to a lowercase s
in the enum.
Similarly, spaces get in the way with Colorblind Friendly
, but this works:
IPalette thisPalette = ScottPlotPalettes.Where(x => x.Name.Replace(" ","") == palette.ToString()).First();
Thoughts
I know this is all driven by old WinForms stuff, so no big deal if this is not addressed. I have been moving towards newer frameworks and SkiaSharp, so I am looking forward to ScottPlot 5!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Interesting! It doesn’t show up as a duplicate on my Windows system because windows filenames are case-insensitive. I’ll delete it from GitHub’s web interface, and that should do the trick
Actually, disregard this question… I think I was/am a little confused about exactly what your code was doing 😅
I think this is the core of this issue. It seems the WinForms features you’re using require an
enum
of palettes. I’m not inclined to add this to ScottPlot because it would have to be edited every time a Palette is added or removed, but your Palette host (with its included enum) looks like a good solution users can implement on their end 👍