Light and dark theme for your Eplan Electric P8 script windows (C#)

Updated: Nov 25
Eplan Electric P8 can run in a dark or a light color scheme, and a window you build yourself looks best when it matches. This post shows how a script reads Eplan's own setting and restyles your window to follow it (a few controls, such as the date picker, need special handling, which a later example covers). It is a good next step once you have built a first dialog.


What you will build
A demo window with a Dark mode check box. Tick it and the window restyles live: background, text, text box, drop-down, buttons, check boxes and even the title bar. A Match Eplan button reads the color scheme chosen in Eplan's options and sets the check box to match, and the window also matches Eplan automatically when it opens.
What you will learn
A palette: keeping all your colors in one place, one set for dark and one for light
Restyling every control with a loop that visits controls inside controls (recursion)
Why the standard check box is hard to see in dark mode, and how to draw your own
Coloring the Windows title bar with a few lines of P/Invoke
Reading one of Eplan's own settings with the Settings class
Before you start
Eplan Electric P8 with scripting available (the example was run in 2026.0.3)
Some C# experience helps; this is an intermediate example with comments throughout
The window is built with Windows Forms, a .NET window toolkit that Eplan scripts can use
How it works
The example includes helper classes named ThemeHelper, ThemePalette and ThemedCheckBox, all in the same file. Two lines do the work:
bool dark = ThemeHelper.IsEplanDark();
ThemeHelper.Apply(myForm, dark);Eplan keeps the choice in the setting USER.MF.GuiColorScheme: 0 means automatic (follows the Windows apps theme), 1 means dark, 2 means light. The script reads that setting, asks Windows when it is automatic, and falls back to dark if anything fails, so the window still has a consistent look.

Common mistakes
Guessing the scheme from screen pixels instead of reading the setting
Forgetting that some standard controls ignore colors, such as the date picker
Letting a styling problem stop the window from opening; the code is wrapped in try and catch
Try it yourself
Download the example: https://github.com/justin-walzengineering/Eplan-Scripting-GUI-Examples/tree/main/examples/04-light-dark-theme
In Eplan: File > Extras > Interfaces > Run, then select LightDarkTheme.cs.
Tested with Eplan Electric P8 2026.0.3 (run in Eplan with dark, light and automatic settings; automatic was run with Windows set to light mode, and with Windows set to dark mode it has not been tried).
If you would like to experiment, try it in a test project first.
Ideas to extend
Challenge: add a third palette, for example a high-contrast one
Use the same helper in every window you build
Save the user's choice (a later example shows how)
Key takeaways
Read Eplan's setting rather than guessing
Keep colors in one palette
Styling is cosmetic, so never let it stop your script
Community spotlight
Who or what: A short post about WPF add-ins with translations from Johann Weiher (Suplanus): https://suplanus.de/wpf-api-addins-mit-uebersetzungen/
Why it is worth a look: If you want to go beyond Windows Forms, it gives a starting point for an alternative window technology for Eplan.
Good to know: It suits readers who already write some C#. And also users who are new to C#.
Repository with all examples: https://github.com/justin-walzengineering/Eplan-Scripting-GUI-Examples
Maintained by Justin Walz, Walz Engineering. Questions and ideas for future examples are always welcome, and if you would like help with a script of your own, feel free to get in touch.



Comments