-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Form1.cs
35 lines (27 loc) · 1.12 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#nullable enable
using System;
using System.Drawing;
using System.Windows.Forms;
using Dark.Net;
namespace darknet_demo_winforms;
public partial class Form1: Form {
public Form1() {
InitializeComponent();
DarkNet.Instance.EffectiveCurrentProcessThemeIsDarkChanged += (_, isDarkTheme) => RenderTheme(isDarkTheme);
RenderTheme(DarkNet.Instance.EffectiveCurrentProcessThemeIsDark);
}
private void RenderTheme(bool isDarkTheme) {
BackColor = isDarkTheme ? Color.FromArgb(19, 19, 19) : Color.White;
ForeColor = isDarkTheme ? Color.White : Color.Black;
}
private void onDarkModeCheckboxChanged(object sender, EventArgs e) {
Theme theme = darkModeCheckbox.CheckState switch {
CheckState.Unchecked => Theme.Light,
CheckState.Checked => Theme.Dark,
CheckState.Indeterminate => Theme.Auto,
_ => Theme.Auto
};
DarkNet.Instance.SetCurrentProcessTheme(theme, Program.ThemeOptions);
Console.WriteLine($"Process theme is {theme}");
}
}