question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Palette: capitalization inconsistency and enum discussion

See original GitHub issue

Feature 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.

Capture

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:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
swhardencommented, Dec 21, 2022

This wasn’t fixed correctly I guess, this file is now duplicated:

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

1reaction
swhardencommented, Aug 16, 2022

Would your task be easier if you called ScottPlot.Palette.GetPalettes() instead of creating a custom enum?

Actually, disregard this question… I think I was/am a little confused about exactly what your code was doing 😅

All that is missing is an enum to chose palettes from.

Users can select their palette with a dropdown and the enum value gets saved/loaded from settings

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 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enum constants: UPPERCASE or CameCase?
For enum constants, it's OK to use either uppercase underscore-separated names ( enum class Color { RED, GREEN } ) or regular camel-humps ......
Read more >
Should an Enum start with a 0 or a 1?
Framework Design Guidelines: ✔️ DO provide a value of zero on simple enums. Consider calling the value something like "None.
Read more >
Consistent capitalisation of enum values/constants #7270
Rolling on from some discussion in #7247 it's been pointed out that as it stands there is no convention for the naming of...
Read more >
Coding Standard | Unreal Engine 4.27 Documentation
All code and comments should use U.S. English spelling and grammar. The first letter of each word in a name (such as type...
Read more >
Untitled
Dart lowercase Dart Tutorial - GeeksforGeeks file_names - Dart WebThe error is very self explaining. The name of your files should be in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found