Fix "pick" button crashing shit
This commit is contained in:
@@ -83,28 +83,7 @@ namespace DD2Switcher {
|
|||||||
windowPanelForm.IsLast = (i == lastIndex);
|
windowPanelForm.IsLast = (i == lastIndex);
|
||||||
windowPanelForm.UpdateDisplay();
|
windowPanelForm.UpdateDisplay();
|
||||||
|
|
||||||
windowPanelForm.PickClicked += (sender, index) => PickButton_Click(sender, new EventArgs());
|
windowPanelForm.PickClicked += (sender, index) => {
|
||||||
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;
|
|
||||||
|
|
||||||
if (firstIndex == -1) {
|
if (firstIndex == -1) {
|
||||||
// First pick - set both first and last
|
// First pick - set both first and last
|
||||||
firstIndex = index;
|
firstIndex = index;
|
||||||
@@ -123,26 +102,32 @@ namespace DD2Switcher {
|
|||||||
lastIndex = index;
|
lastIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshWindowsList();
|
RefreshWindowsList();
|
||||||
}
|
};
|
||||||
|
windowPanelForm.UntrackClicked += (sender, index) => {
|
||||||
private void UntrackButton_Click(object sender, EventArgs e) {
|
|
||||||
var button = (Button)sender;
|
|
||||||
int index = (int)button.Tag;
|
|
||||||
|
|
||||||
// Remove from tracked windows
|
|
||||||
UntrackWindow(index);
|
UntrackWindow(index);
|
||||||
|
|
||||||
// Update first/last indices if needed
|
|
||||||
if (index == firstIndex) {
|
if (index == firstIndex) {
|
||||||
firstIndex = -1;
|
firstIndex = -1;
|
||||||
}
|
}
|
||||||
if (index == lastIndex) {
|
if (index == lastIndex) {
|
||||||
lastIndex = -1;
|
lastIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshWindowsList();
|
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() {
|
private List<Process> GetTrackedWindows() {
|
||||||
|
Reference in New Issue
Block a user