Refactor the individual window panel into a separate form
This commit is contained in:
47
DD2Switcher/WindowPanelForm.cs
Normal file
47
DD2Switcher/WindowPanelForm.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user