Basic principles for Night Mode?

0
0

Consider

public void ColorFormForNightMode ()
{
FlowLayoutPanel1.BackColor = Color.FromArgb(26, 26, 26);
lvIssues.BackColor = Color.FromArgb(26, 26, 26);
panBlankIssue.BackColor = Color.FromArgb(26, 26, 26);
panel6.BackColor = Color.FromArgb(26, 26, 26);
panIssueConversation.BackColor = Color.FromArgb(26, 26, 26);
this.Update();
}

This partially works, except Listviews stay white (minus unused portions). ListViewItems are all white, so and so is the panel. Panel6, with many controls on it, stays white, while panBlankIssue with no controls turns dark.

What considerations are needed to implement a “Night Mode” toggle for a form? Does the theme ever interfere with setting a control’s .BackColor and .ForeColor property?  Do I need to recreate the ListViewItems and set .BackColor there?  Just wondering if there is existing notes on this, otherwise I could attempt to use some WinForms Night Mode that I hacked together for a different project.

Thanks,

Andrew

  • You must to post comments
0
0

Hi Andrew,

It’s probably better if you create an alternative appearance in the theme if you want to implement a “dark theme”.
It is considerably faster than setting your own colors by code, all you have to do is set the AppearanceKey of the component, and it gives you much greater flexibility, especially if you want to tweak your settings in the future.

HTH,
Alaa

  • You must to post comments
0
0

OK so one thing that works. Recreate all the ListViewItems, setting the .BackColor, and setting the .BackColor() for all of the ListViewItem.ListViewSubItem objects.   The best way might be with a global form boolean, nightModeOn

public void CreateListViewItemFromIssue(ref ListViewItem li, ref issue iss)

{

//normal creation code here

 

//color for nightmode

foreach (ListViewItem.ListViewSubItem si in li.SubItems)
{
if (nightMode) { si.BackColor = Color.FromArgb(26, 26, 26); }
}

 

}

 

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.