Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark Theme #2

Open
maforget opened this issue Jan 17, 2024 · 5 comments
Open

Dark Theme #2

maforget opened this issue Jan 17, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@maforget
Copy link
Owner

maforget commented Jan 17, 2024

Here is a placeholder for work on a Dark Theme.

Is it even possible with Winforms?

@maforget maforget added the enhancement New feature or request label Jan 17, 2024
@maforget
Copy link
Owner Author

Examples from the community.

ReeuChc
lHCt9kZ

A good Color is

this.BackColor = Color.FromArgb(32,32,32);
this.ForeColor = Color.White;

@Totengeist
Copy link
Contributor

I finally installed VS 2022 Community and got my first debug build working, so I'm going to try to take a look at this. As you said, this is a big codebase, and I'm still learning where everything is, but I've identified where the settings are and where the colors are being set. Now to find how the two might connect…

Would you want a predefined Dark Mode, or are you looking to support some user customization? Right now, I'm thinking we add a checkbox to the settings and set defaults in config.xml. Any savvy people could then mess with the colors there.

@maforget
Copy link
Owner Author

maforget commented Jan 29, 2024

Let em give you some pointers for having check a little bit and the problem I see with this. If you start with the MainForm and check the types of the Control. You end up with some Views like the ComicBrowserControl, ComicListLibraryBrowser ComicListFolderFilesBrowser. You find out both uses the ItemView & the TreeView that is in cYo.Common.WIndows.Forms. One View goes into a panel, that goes into another Control. Some types aren't even defined in the Designer, but into the code at some point. Very confusing, I haven't all mapped out the maze yet myself😂. Some even seems empty.

So you can go into ItemView & TreeView (TreeViewEx inherits from this one) and add a ForeGround Color there. Problem arrives where certain of these view also set a ForeGround color, hiding the one set my the underlying one. So if you remove these colors where they are set, you start getting something nice.

Problem arroses with the TabBar, i've googled a little bit and it seems it is not possible to set the color on this control. We will have to probably create a TabBar that inherits the original and override the OnPaint method.

Then there are the Forms, I would do something similar. Just create our own Form that we can set the color at this one place and not all over the place. I believe that a DarkForm already exists somewhere on the net when I checked years ago.

Problem I see with this is trying to not have to add hundreds of check all over the place to set the Dark Mode. We should keep them in the least possible places for easier editing. Maybe even just create our own Control type (All winforms element inherit from that).

I saw online ideas of going through the Controls collection that is supposed to contains all the control in the forms and changing the color there. Sometimes the Control, has many other Control under them in it's own Controls. It would be recursive. But I think this approach needs some fixing, because some Control aren't added in the Controls library on Initialization.

At that point I would settle with just a checkbox in the drop-down menu like Enable Dark Mode. If we do change the color that would be set in the ComicRack.ini. Just add a new property in the ExtendedSettings for it.

@maforget
Copy link
Owner Author

maforget commented Apr 3, 2024

I've found an elegant solution to the dark mode, this will probably be temporary though. So I don't know if there is any point pushing further. The solution is based on this:

https://github-com.translate.goog/NikolayXHD/Mtgdb/wiki/.NET-WinForms-easy-color-scheme?_x_tr_sl=auto&_x_tr_tl=en-US
There is an even better solution here based on the above:
gitextensions/gitextensions#7213

The reason it is temporary is that:

  1. It won't work with .NET 5+ (the above program gitextensions doesn't have it anymore since they upgraded to .NET 5+)
  2. A WAY better solution is coming (hopefully soon). In .NET 9, there should be a built-in solution to have winforms follow the system theme. Info here: [API Suggestion] Introduce Dark Mode and A11Y compatible Visual Styles for Apps targeting .NET 9 and Win 11 dotnet/winforms#7641 & Enable DarkMode Theming dotnet/winforms#10985

So I will probably just wait for the release with .NET 9 and in the mean time work on migrating to .NET. Most projects seem to like they are waiting for that.


My current WIP based on replacing the SystemColors has been uploaded to the fork darkMode. There is still some work to do:

You use it by starting with -dark (or Add UseDarkMode = true) to the ComicRack.ini file

  • Annoying white border around everything.
  • Progress bar not showing.
  • Some Controls like ComboBox aren't completely dark.
  • Some Controls like CheckedListBoxEx have the BackColor still white. This looks like TreeViewEx where even if the BackColor is already correct (because we changed the SystemColors), we still need to update it manually to force a redraw. Maybe there another way to force a redraw?
  • Some buttons are still in dark text on white backcolor.
  • Columns header are white text on white background.
  • Colors still needs to be tweaked right now everything is the same shade. Like the unselected tab vs selected are the same shade.

image

@maforget
Copy link
Owner Author

.NET 9 Finally has experimental Dark Mode support for winforms.

https://learn.microsoft.com/en-us/dotnet/desktop/winforms/whats-new/net90?view=netdesktop-9.0#dark-mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants