elvirbrk / NoteHighlight2016

Source code syntax highlighting for OneNote 2016 and OneNote for O365 . NoteHighlight 2013 port for OneNote 2016 (32-bit and 64-bit)
GNU General Public License v2.0
3.79k stars 393 forks source link

OneNote Dark mode compatibility #109

Closed natbrood closed 3 years ago

natbrood commented 4 years ago

It's been a while since Microsoft allowed people to use the night theme of OneNote. As of right now, to get the proper color, I need to switch back to light mode and then, after importing, I need to switch back to dark mode.

Could dark mode compatibility be a future option?

ahmet-cetinkaya commented 4 years ago

I think it should be added as well.

iamhammer commented 4 years ago

I would love to see Dark Mode support also.

If the Office Theme is set to Black (Dark Mode) there is an additional option in the View Tab on the ribbon. It's in the Page Setup group and is labeled Switch Background. image

This will toggle the page contents and colors between light and dark mode but not change the chrome of the application or effect the Office Theme at large (as used by other Office Apps).

image

The registry value for this is found at Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\OneNote\General\DarkModeCanvasLightsOn

Changing the DarkModeCanvasLightsOn registry value does toggle the Switch Background option. So if NoteHightlight would:

  1. Check this value
  2. If DarkModeCanvasLightsOn = 0 (off, display page content in dark mode) set it to 1 (Lights On, display page content in light mode)
  3. Run the normal highlighting process
  4. If DarkModeCanvasLightsOn was originally = 0, after highlighting set back to 0
  5. All of the colors should be correctly configured and displayed now in either mode.

One other thing to account for though is that setting the registry value for DarkModeCanvasLightsOn will make an immediate change (just like clicking the button in the View tab), except it will not apply to the OneNote Outline Elements that have an insertion point.

image Above: An example of a page that was selected when LightsOn was changed from 0 to 1 via the registry. The page background changed from black to white, but the actual textbox and it's contents that contained the insertion point remained unchanged.

image Above: An example of a page that had selected text when LightsOn was changed from 1 to 0 via the registry. The same effect as above but additionally the paragraph that contained the selected text has it's font colors augmented.

NickolasJohnson commented 4 years ago

So, this is a bit strange but if you switch the background to light mode, then use notehighlight and the bright style, then switch back to darkmode it looks fine. If you stay in dark mode, then use notehightlight, it makes the text all way too dark. Pic below for comparison. image

Sahil-h-3me commented 4 years ago

So, this is a bit strange but if you switch the background to light mode, then use notehighlight and the bright style, then switch back to darkmode it looks fine. If you stay in dark mode, then use notehightlight, it makes the text all way too dark. Pic below for comparison. image

Strange when I tried that it didn't do anything. Also I'm finding even with turning off dark mode the colours are really washed out and hard to read. I'm using OneNote 2016.

roflbofl322 commented 4 years ago

The work around for this is to click "Switch background" -> write down the code -> switch back to dark mode. image image

Sahil-h-3me commented 4 years ago

Super weird work around but it works when you switch to light mode, write the code and then switch back to dark. Is there any plans to update this so we don't have to do that?

iamhammer commented 3 years ago

What happened to the comments by @wuwao1 from Sep 6th, about a Dark Mode fix they'd made? Did it run afoul as their fix was replacing an assembly instead of issuing a pull request?

wuwao1 commented 3 years ago

@iamhammer ,Based on your comment, I wrote the following code,FYR.Thanks.

///////////////////////////////////////////////////////////////////////////////////////// private void shellExcuteStr(string boolDarkModeCanvasLightsOn) { Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); string strCMD = boolDarkModeCanvasLightsOn; p.StandardInput.WriteLine(strCMD + " & exit"); p.StandardInput.AutoFlush = true; p.WaitForExit(); p.Close(); } /////////////////////////////////////////////////////////////////////////////////////////////////// string boolDarkModeCanvasLightsOn1 = @"reg add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\OneNote\General /v DarkModeCanvasLightsOn /t REG_DWORD /d 1 /f"; shellExcuteStr(boolDarkModeCanvasLightsOn1); ////////////////////////////////////////////////////////////////////////////////////////////////////// string boolDarkModeCanvasLightsOn = @"reg add HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\OneNote\General /vDarkModeCanvasLightsOn /t REG_DWORD /d 0 /f"; shellExcuteStr(boolDarkModeCanvasLightsOn);

As for the code I modified, the personal test results were not very good and were not submitted, so I deleted them.

elvirbrk commented 3 years ago

Dark mode support added to version 3.7