Fix "pick" button crashing shit

This commit is contained in:
2025-08-31 20:30:13 +02:00
parent 1f314d5c4b
commit c4e9007f2b

View File

@@ -83,28 +83,7 @@ namespace DD2Switcher {
windowPanelForm.IsLast = (i == lastIndex);
windowPanelForm.UpdateDisplay();
windowPanelForm.PickClicked += (sender, index) => PickButton_Click(sender, new EventArgs());
windowPanelForm.UntrackClicked += (sender, index) => UntrackButton_Click(sender, new EventArgs());
windowsPanel.Controls.Add(windowPanelForm);
}
}
private string GetFirstLastText(int index) {
if (index == firstIndex && index == lastIndex) {
return "First & Last";
} else if (index == firstIndex) {
return "First";
} else if (index == lastIndex) {
return "Last";
}
return "";
}
private void PickButton_Click(object sender, EventArgs e) {
var button = (Button)sender;
int index = (int)button.Tag;
windowPanelForm.PickClicked += (sender, index) => {
if (firstIndex == -1) {
// First pick - set both first and last
firstIndex = index;
@@ -123,26 +102,32 @@ namespace DD2Switcher {
lastIndex = index;
}
}
RefreshWindowsList();
}
private void UntrackButton_Click(object sender, EventArgs e) {
var button = (Button)sender;
int index = (int)button.Tag;
// Remove from tracked windows
};
windowPanelForm.UntrackClicked += (sender, index) => {
UntrackWindow(index);
// Update first/last indices if needed
if (index == firstIndex) {
firstIndex = -1;
}
if (index == lastIndex) {
lastIndex = -1;
}
RefreshWindowsList();
};
windowsPanel.Controls.Add(windowPanelForm);
}
}
private string GetFirstLastText(int index) {
if (index == firstIndex && index == lastIndex) {
return "First & Last";
} else if (index == firstIndex) {
return "First";
} else if (index == lastIndex) {
return "Last";
}
return "";
}
private List<Process> GetTrackedWindows() {