Skip to content

Commit 1821920

Browse files
committed
first iteration of darkrmode, needs to be adapted to the cellpainting
1 parent 1eb4b18 commit 1821920

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/LogExpert.UI/Controls/BufferedDataGridView.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.ComponentModel;
12
using System.Drawing.Drawing2D;
23
using System.Runtime.Versioning;
34

@@ -6,7 +7,6 @@
67
using LogExpert.UI.Controls;
78

89
using NLog;
9-
using System.ComponentModel;
1010

1111
namespace LogExpert.Dialogs;
1212

@@ -246,6 +246,7 @@ private void PaintOverlays (PaintEventArgs e)
246246
foreach (var overlay in _overlayList.Values)
247247
{
248248
var textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300);
249+
249250
Rectangle rectBubble = new(overlay.Position, new Size((int)textSize.Width, (int)textSize.Height));
250251
rectBubble.Offset(60, -(rectBubble.Height + 40));
251252
rectBubble.Inflate(3, 3);
@@ -254,6 +255,7 @@ private void PaintOverlays (PaintEventArgs e)
254255
myBuffer.Graphics.SetClip(rectBubble, CombineMode.Union); // Bubble to clip
255256
myBuffer.Graphics.SetClip(rectTableHeader, CombineMode.Exclude);
256257
e.Graphics.SetClip(rectBubble, CombineMode.Union);
258+
257259
RectangleF textRect = new(rectBubble.X, rectBubble.Y, rectBubble.Width, rectBubble.Height);
258260
myBuffer.Graphics.FillRectangle(_brush, rectBubble);
259261
//myBuffer.Graphics.DrawLine(_pen, overlay.Position, new Point(rect.X, rect.Y + rect.Height / 2));

src/LogExpert/Program.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Text;
99
using System.Windows.Forms;
1010

11-
1211
using LogExpert.Classes;
1312
using LogExpert.Classes.CommandLine;
1413
using LogExpert.Config;
@@ -96,6 +95,7 @@ private static void Main (string[] args)
9695
}
9796

9897
SetCulture();
98+
SetDarkMode();
9999

100100
_ = PluginRegistry.PluginRegistry.Instance.Create(ConfigManager.Instance.ConfigDir, ConfigManager.Instance.Settings.Preferences.PollingInterval);
101101

@@ -152,7 +152,7 @@ or ArgumentException
152152
_logger.Error($"IpcClientChannel error: {ex}");
153153
errMsg = ex;
154154
counter--;
155-
155+
156156
// Use Task.Delay instead of Thread.Sleep for non-blocking wait
157157
if (counter > 0)
158158
{
@@ -204,6 +204,20 @@ or ArgumentNullException
204204
}
205205
}
206206

207+
[SupportedOSPlatform("windows")]
208+
private static void SetDarkMode ()
209+
{
210+
var darkModeEnabled = ConfigManager.Instance.Settings.Preferences.DarkMode;
211+
if (darkModeEnabled)
212+
{
213+
Application.SetColorMode(SystemColorMode.Dark);
214+
}
215+
else
216+
{
217+
Application.SetColorMode(SystemColorMode.System);
218+
}
219+
}
220+
207221
[SupportedOSPlatform("windows")]
208222
private static void SetCulture ()
209223
{
@@ -428,4 +442,4 @@ private static void CurrentDomain_UnhandledException (object sender, UnhandledEx
428442
}
429443

430444
#endregion
431-
}
445+
}

0 commit comments

Comments
 (0)