-
Nov 16th, 2022, 12:13 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Idea to represent a sort of "Dark mode" in VB.NET
Well, hi. You may already guess what I've done so far:
Code:
Me.BackColor = Color.Black
Me.ForeColor = Color.White
For dark mode and
Code:
Me.BackColor = Color.White
Me.ForeColor = Color.Black
for light mode in an super easy way. But always cheap is cheap... it achieved with some problems let's say side effects. "Me" literally contains all of the controls but somehow 1) UserControls does not follow the color changing commands. plus 2) Some controls like Tab Control tab headers are always white therefore, they don't follow the color neither.
What options you people recommend? Newer .NET frameworks may cover this feature already or calling a simple code to do that right? Or Parallel.For all controls to toggle their colour?
Last edited by pourkascheff; Nov 16th, 2022 at 12:16 AM.
-
Nov 16th, 2022, 12:31 AM
#2
Re: Idea to represent a sort of "Dark mode" in VB.NET
If you want to customise the look and feel of your app, you really ought to be using WPF rather than WinForms. It was built from the ground up to be customisable. If you want to stick with WinForms and it's not working with user controls then you'd have to throw in a recursive call. The tabs on a TabControl would take more work. On that, this is old but should still be applicable.
-
Nov 16th, 2022, 01:10 AM
#3
Re: Idea to represent a sort of "Dark mode" in VB.NET
Add interface for themed controls with one method that will set colors according theme. Implement the interface in every of your forms and controls. Create theme manager class and pass the root form and do what jmc said - scan recursively and if the control implements the theme interface - call the method to change the theme. This way you will have routine in each form and user control that you have to write and it will set the right colors of all standard controls in the form/user control.
-
Nov 16th, 2022, 01:19 AM
#4
Re: Idea to represent a sort of "Dark mode" in VB.NET
Small improvement could be to pass theme object with pre-defined colors (instead of dark/light parameter) so your forms and controls will be painted in these colors and you can quickly change the theme not only from light to dark but also to different color scheme - blue, red, green, lighter or darker variants of colors.
It is a lot of work to get everything right, but when it's ready you will get nice looking UI.
-
Nov 16th, 2022, 04:44 PM
#5
Re: Idea to represent a sort of "Dark mode" in VB.NET
I have gone the route of writing my WinForm applications such that the UI is written in a web language and the logic lives in the WinForm application. When the form loads, I load the web UI into a WebView2 and then communicate back and forth between the WebView2 and the WinForm application.
This isn't ideal for every situation, but I have been pleasantly surprised with how nice everything works.
In this situation, based on the CSS framework, it's pretty easy to toggle between a light and dark mode because the components are typically written such that the CSS supports it. For example, in Ionic it is simply a matter of adding/removing the .dark class to the body.
-
Nov 18th, 2022, 06:21 AM
#6
Thread Starter
Hyperactive Member
Re: Idea to represent a sort of "Dark mode" in VB.NET
Originally Posted by dday9
For example, in Ionic it is simply a matter of adding/removing the .dark class to the body.
Can you add a graphical/actual example from what you achieved or it will be removed since it is VB.NET not-related content?
-
Nov 18th, 2022, 10:27 AM
#7
Re: Idea to represent a sort of "Dark mode" in VB.NET
I'm not sure what you're asking for.
-
Jun 3rd, 2023, 12:15 PM
#8
Thread Starter
Hyperactive Member
Re: Idea to represent a sort of "Dark mode" in VB.NET
Last edited by pourkascheff; Jun 3rd, 2023 at 12:23 PM.
-
Jun 4th, 2023, 01:07 AM
#9
Re: Idea to represent a sort of "Dark mode" in VB.NET
Originally Posted by pourkascheff
This has WPF written all over it. Not that WinForms can't do, it might be just a tad bit more difficult.
-
Jun 11th, 2023, 01:37 PM
#10
Thread Starter
Hyperactive Member
Re: Idea to represent a sort of "Dark mode" in VB.NET
Oh thanks for following up! Niya, the code detective. I built it once, Referenced the output *.dll file in another project, and woala, a good looking meanwhile simple and maybe the FASTEST way to achieve a set of WinForm darkmode controls. I linked it for possible other's cases but for professional uses, DevExpress bundle might be my final chose since their skins are beautifully done and all (including dark ones) containing up to 4 grades of color accents (Consider 42,42,42 next to 68,68,68 then 91,91,91 and 170,170,170).
-
Jun 11th, 2023, 09:14 PM
#11
Re: Idea to represent a sort of "Dark mode" in VB.NET
Originally Posted by pourkascheff
and woala
For the record, the word is "voila". It is French for "there it is".
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|