moved to MVVM architecture

This commit is contained in:
2026-08-08 21:24:02 +05:00
parent a1ff8cc923
commit 3d614255d8
19 changed files with 565 additions and 346 deletions
@@ -0,0 +1,28 @@
using System.Runtime.InteropServices;
namespace CursorLang.Interop;
/// <summary>
/// Win32 API для определения раскладки активного окна.
/// </summary>
internal static class KeyboardLayoutNative
{
[DllImport("user32.dll")]
internal static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr lpdwProcessId);
[DllImport("user32.dll")]
private static extern IntPtr GetKeyboardLayout(uint idThread);
/// <summary>
/// Идентификатор локали для окна. Раскладка в Windows привязана к потоку,
/// поэтому так её видно у любого приложения, а не только у своего.
/// </summary>
internal static int GetLocaleIdOf(IntPtr hWnd)
{
uint threadId = GetWindowThreadProcessId(hWnd, IntPtr.Zero);
return (int)GetKeyboardLayout(threadId).ToInt64() & 0xFFFF;
}
}