Skip to content

Commit 94f5cae

Browse files
Randall FlaggRandall Flagg
authored andcommitted
Moved the last dllimport from CORE to UI
1 parent aa5a3ac commit 94f5cae

8 files changed

Lines changed: 39 additions & 50 deletions

File tree

src/LogExpert.Core/Config/ColorMode.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,5 @@ private static void SetBrightMode()
7474
InactiveTabColor = LessBrightBackgroundColor;
7575
DarkModeEnabled = false;
7676
}
77-
78-
#region TitleBarDarkMode
79-
[DllImport("dwmapi.dll")]
80-
private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize);
81-
82-
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
83-
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
84-
85-
public static bool UseImmersiveDarkMode(nint handle, bool enabled)
86-
{
87-
88-
var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
89-
if (IsWindows10OrGreater(18985))
90-
{
91-
attribute = DWMWA_USE_IMMERSIVE_DARK_MODE;
92-
}
93-
94-
int useImmersiveDarkMode = enabled ? 1 : 0;
95-
return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
96-
97-
}
98-
99-
private static bool IsWindows10OrGreater(int build = -1)
100-
{
101-
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build;
102-
}
103-
104-
#endregion TitleBarDarkMode
105-
10677
}
10778
}

src/LogExpert.UI/Controls/LogWindow/TimeSpreadigControl.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
using LogExpert.Classes;
2-
using LogExpert.Core.Classes;
1+
using LogExpert.Core.Classes;
32
using LogExpert.Core.EventArguments;
4-
using LogExpert.UI.Controls.LogWindow;
3+
using LogExpert.UI.Extensions;
54
using NLog;
65

7-
using System;
8-
using System.Collections.Generic;
9-
using System.Drawing;
10-
using System.Windows.Forms;
11-
126
namespace LogExpert.UI.Controls.LogWindow
137
{
148
internal partial class TimeSpreadingControl : UserControl

src/LogExpert.UI/Dialogs/ChooseIconDlg.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using LogExpert.Core.Classes;
2-
1+
using LogExpert.UI.Extensions;
32
using System.Runtime.Versioning;
43

54
namespace LogExpert.UI.Dialogs;

src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindow.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using LogExpert.Core.Config;
1+
using LogExpert.Core.Classes;
2+
using LogExpert.Core.Config;
23
using LogExpert.Core.Entities;
34
using LogExpert.Core.Interface;
45
using LogExpert.Dialogs;
6+
using LogExpert.UI.Extensions;
57
using LogExpert.UI.Extensions.Forms;
68
using NLog;
79
using System.Reflection;
@@ -159,7 +161,7 @@ public LogTabWindow(string[] fileNames, int instanceNumber, bool showInstanceNum
159161
public void ChangeTheme(Control.ControlCollection container)
160162
{
161163
ColorMode.LoadColorMode(ConfigManager.Settings.Preferences.darkMode);
162-
ColorMode.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled);
164+
Win32.UseImmersiveDarkMode(Handle, ColorMode.DarkModeEnabled);
163165

164166
#region ApplyColorToAllControls
165167
foreach (Control component in container)

src/LogExpert.UI/Dialogs/LogTabWindow/LogTabWindowPrivate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using LogExpert.Dialogs;
1010
using LogExpert.PluginRegistry.FileSystem;
1111
using LogExpert.UI.Dialogs;
12+
using LogExpert.UI.Extensions;
1213
using System.ComponentModel;
1314
using System.Diagnostics;
1415
using System.Runtime.InteropServices;

src/LogExpert.UI/Dialogs/LogTabWindow/SettingsDialog.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66
using LogExpert.Core.Interface;
77
using LogExpert.UI.Controls.LogTabWindow;
88
using LogExpert.UI.Dialogs;
9-
10-
using System;
11-
using System.Collections.Generic;
12-
using System.Drawing;
13-
using System.IO;
9+
using LogExpert.UI.Extensions;
1410
using System.Runtime.InteropServices;
1511
using System.Text;
16-
using System.Windows.Forms;
1712

1813
namespace LogExpert.Dialogs;
1914

src/LogExpert.UI/Extensions/Win32.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
using System.Runtime.InteropServices;
33
using System.Runtime.Versioning;
44

5-
namespace LogExpert.Core.Classes
5+
namespace LogExpert.UI.Extensions
66
{
77
[SupportedOSPlatform("windows")]
8-
public static class Win32
8+
internal static class Win32
99
{
1010
#region Fields
1111

@@ -115,6 +115,34 @@ private static extern uint ExtractIconEx(string fileName,
115115
uint numIcons
116116
);
117117

118+
#region TitleBarDarkMode
119+
[DllImport("dwmapi.dll")]
120+
private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize);
121+
122+
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
123+
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
124+
125+
public static bool UseImmersiveDarkMode(nint handle, bool enabled)
126+
{
127+
128+
var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
129+
if (IsWindows10OrGreater(18985))
130+
{
131+
attribute = DWMWA_USE_IMMERSIVE_DARK_MODE;
132+
}
133+
134+
int useImmersiveDarkMode = enabled ? 1 : 0;
135+
return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
136+
137+
}
138+
139+
private static bool IsWindows10OrGreater(int build = -1)
140+
{
141+
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build;
142+
}
143+
144+
#endregion TitleBarDarkMode
145+
118146
#endregion
119147
}
120148
}

src/LogExpert.UI/LogExpert.UI.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
<ItemGroup>
2525
<EmbeddedResource Remove="Dialogs\LogTabWindow\LogTabWindowEventHandlers.resx" />
26-
<EmbeddedResource Remove="Dialogs\LogTabWindow\LogTabWindowPrivate.resx" />
2726
<EmbeddedResource Remove="Dialogs\LogTabWindow\LogTabWindowPublic.resx" />
2827
<EmbeddedResource Remove="Controls\LogWindow\LogWindowEventHandlers.resx" />
2928
<EmbeddedResource Remove="Controls\LogWindow\LogWindowPrivate.resx" />

0 commit comments

Comments
 (0)