Refactor the individual window panel into a separate form

This commit is contained in:
2025-08-31 20:27:45 +02:00
parent f234279135
commit 1f314d5c4b
5 changed files with 320 additions and 73 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace DD2Switcher {
public partial class WindowPanelForm : UserControl {
public event EventHandler<int> PickClicked;
public event EventHandler<int> UntrackClicked;
public int WindowIndex { get; set; }
public Process WindowProcess { get; set; }
public bool IsFirst { get; set; }
public bool IsLast { get; set; }
public WindowPanelForm() {
InitializeComponent();
}
public void UpdateDisplay() {
if (WindowProcess != null) {
indexLabel.Text = $"Index: {WindowIndex}";
nameLabel.Text = $"Name: {WindowProcess.ProcessName}";
pidLabel.Text = $"PID: {WindowProcess.Id}";
titleLabel.Text = $"Title: {WindowProcess.MainWindowTitle}";
if (IsFirst && IsLast) {
firstLastLabel.Text = "First & Last";
} else if (IsFirst) {
firstLastLabel.Text = "First";
} else if (IsLast) {
firstLastLabel.Text = "Last";
} else {
firstLastLabel.Text = "";
}
}
}
private void pickButton_Click(object sender, EventArgs e) {
PickClicked?.Invoke(this, WindowIndex);
}
private void untrackButton_Click(object sender, EventArgs e) {
UntrackClicked?.Invoke(this, WindowIndex);
}
}
}