Try add forms for settings

This commit is contained in:
2025-08-31 20:08:31 +02:00
parent bad2313c18
commit baeadba638
6 changed files with 417 additions and 5 deletions

View File

@@ -10,6 +10,29 @@ namespace DD2Switcher {
internal static class Program {
private static int NumProc = 19;
private static Process[] windows = new Process[NumProc];
// Public access to tracked windows for the settings form
public static Process[] GetTrackedWindows() {
return windows;
}
public static void UntrackWindow(int index) {
if (index >= 0 && index < NumProc) {
windows[index] = null;
// Compact the array by shifting non-null elements to the left
for (int i = index; i < NumProc - 1; i++) {
windows[i] = windows[i + 1];
}
windows[NumProc - 1] = null;
// Update ActiveIndex if needed
if (ActiveIndex == index) {
ActiveIndex = -1;
} else if (ActiveIndex > index) {
ActiveIndex--;
}
}
}
private static int ActiveIndex = -1;
private static bool AltPressed = false;
@@ -246,6 +269,7 @@ namespace DD2Switcher {
}
private static void TabToPrevious() {
return;
try {
var foreground = GetForegroundProcess();
if (!ProcessTracked(foreground.Id)) {
@@ -288,7 +312,8 @@ namespace DD2Switcher {
[STAThread]
private static void Main() {
// AllocConsole();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var processes = Process.GetProcesses();
var currentProcess = Process.GetCurrentProcess();
@@ -356,8 +381,8 @@ namespace DD2Switcher {
}
}
// Console.CancelKeyPress += (sender, e) => { Process.GetCurrentProcess().Kill(); };
Application.Run();
// Run the WinForms application with Form1 as the main form
Application.Run(new Form1());
KeyboardHook.Stop();
}
}