-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
5,498 additions
and
3,349 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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ProjectView>ProjectFiles</ProjectView> | ||
</PropertyGroup> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ProjectView>ProjectFiles</ProjectView> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> | ||
<StartArguments> | ||
</StartArguments> | ||
</PropertyGroup> | ||
</Project> |
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,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace CapsLockIndicatorV3 | ||
{ | ||
public class DarkModeForm : Form | ||
{ | ||
public event EventHandler DarkModeChanged; | ||
|
||
internal void OnDarkModeChanged() | ||
{ | ||
DarkModeChanged?.Invoke(this, EventArgs.Empty); | ||
} | ||
|
||
protected void ControlScheduleSetDarkMode(Control control, bool isDark) | ||
{ | ||
if (control.IsHandleCreated) | ||
Native.ControlSetDarkMode(control, isDark); | ||
else | ||
control.HandleCreated += (sender, e) => | ||
{ | ||
Native.ControlSetDarkMode(control, isDark); | ||
}; | ||
} | ||
} | ||
} |
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,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace CapsLockIndicatorV3 | ||
{ | ||
public static class DarkModeProvider | ||
{ | ||
public static bool IsDark => Environment.OSVersion.Version.Major >= 10 && SettingsManager.Get<bool>("darkMode"); | ||
|
||
private static List<DarkModeForm> registeredForms = new List<DarkModeForm>(); | ||
|
||
public static void RegisterForm(DarkModeForm form) | ||
{ | ||
registeredForms.Add(form); | ||
form.FormClosing += Form_FormClosing; | ||
form.OnDarkModeChanged(); | ||
} | ||
|
||
public static void SetDarkModeEnabled(bool enabled) | ||
{ | ||
SettingsManager.Set("darkMode", enabled); | ||
UpdateForms(); | ||
} | ||
|
||
private static void UpdateForms() | ||
{ | ||
foreach (var f in registeredForms) | ||
f.OnDarkModeChanged(); | ||
} | ||
|
||
private static void Form_FormClosing(object sender, FormClosingEventArgs e) | ||
{ | ||
registeredForms.Remove(sender as DarkModeForm); | ||
} | ||
} | ||
} |
Oops, something went wrong.