-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix issue #425: "No byte order mark on save" option throws stream c…
…losed exception add unit test - Apply dark mode to window titlebar
- Loading branch information
1 parent
260fe2e
commit 06e7304
Showing
7 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace XmlNotepad | ||
{ | ||
internal enum DWMWINDOWATTRIBUTE : uint | ||
{ | ||
DWMWA_NCRENDERING_ENABLED, | ||
DWMWA_NCRENDERING_POLICY, | ||
DWMWA_TRANSITIONS_FORCEDISABLED, | ||
DWMWA_ALLOW_NCPAINT, | ||
DWMWA_CAPTION_BUTTON_BOUNDS, | ||
DWMWA_NONCLIENT_RTL_LAYOUT, | ||
DWMWA_FORCE_ICONIC_REPRESENTATION, | ||
DWMWA_FLIP3D_POLICY, | ||
DWMWA_EXTENDED_FRAME_BOUNDS, | ||
DWMWA_HAS_ICONIC_BITMAP, | ||
DWMWA_DISALLOW_PEEK, | ||
DWMWA_EXCLUDED_FROM_PEEK, | ||
DWMWA_CLOAK, | ||
DWMWA_CLOAKED, | ||
DWMWA_FREEZE_REPRESENTATION, | ||
DWMWA_PASSIVE_UPDATE_MODE, | ||
DWMWA_USE_HOSTBACKDROPBRUSH, | ||
DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19, | ||
DWMWA_USE_IMMERSIVE_DARK_MODE = 20, | ||
DWMWA_WINDOW_CORNER_PREFERENCE = 33, | ||
DWMWA_BORDER_COLOR, | ||
DWMWA_CAPTION_COLOR, | ||
DWMWA_TEXT_COLOR, | ||
DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, | ||
DWMWA_SYSTEMBACKDROP_TYPE, | ||
DWMWA_LAST | ||
}; | ||
|
||
|
||
internal static class Win32Helpers | ||
{ | ||
[DllImport("Dwmapi")] | ||
static extern int DwmSetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE dwAttribute, ref int attrValue, uint cbAttribute); | ||
|
||
internal static bool UseImmersiveDarkMode(IntPtr handle, bool enabled) | ||
{ | ||
if (IsWindows10OrGreater(17763)) | ||
{ | ||
var attribute = DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1; | ||
if (IsWindows10OrGreater(18985)) | ||
{ | ||
attribute = DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE; | ||
} | ||
|
||
int useImmersiveDarkMode = enabled ? 1 : 0; | ||
return DwmSetWindowAttribute(handle, attribute, | ||
ref useImmersiveDarkMode, sizeof(int)) == 0; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private static bool IsWindows10OrGreater(int build = -1) | ||
{ | ||
return Environment.OSVersion.Version.Major >= 10 && | ||
Environment.OSVersion.Version.Build >= build; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters