maforget / ComicRackCE

A Community Edition for the legendary Comic Book Manager ComicRack. ComicRack is back from the dead.
GNU General Public License v2.0
330 stars 32 forks source link

Dark Theme #2

Open maforget opened 9 months ago

maforget commented 9 months ago

Here is a placeholder for work on a Dark Theme.

Is it even possible with Winforms?

maforget commented 9 months ago

Examples from the community.

ReeuChc lHCt9kZ

A good Color is

this.BackColor = Color.FromArgb(32,32,32);
this.ForeColor = Color.White;
Totengeist commented 9 months ago

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 commented 9 months ago

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 commented 7 months ago

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: https://github.com/gitextensions/gitextensions/pull/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: https://github.com/dotnet/winforms/issues/7641 & https://github.com/dotnet/winforms/pull/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

image