Repository navigation
Expand file tree
/
Copy pathAddCurrentWindowsDialog.cs
More file actions
71 lines (63 loc) · 2.19 KB
/
Copy pathAddCurrentWindowsDialog.cs
File metadata and controls
71 lines (63 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using PabloDock.Models;
namespace PabloDock;
internal sealed class AddCurrentWindowsDialog : Form
{
private readonly ListView _windows = new();
public IReadOnlyList<DetectedWindow> SelectedWindows =>
_windows.CheckedItems.Cast<ListViewItem>()
.Select(item => (DetectedWindow)item.Tag!).ToArray();
public AddCurrentWindowsDialog(IReadOnlyList<DetectedWindow> available)
{
Text = "Add current windows";
FormBorderStyle = FormBorderStyle.FixedDialog;
StartPosition = FormStartPosition.CenterParent;
MinimizeBox = false;
MaximizeBox = false;
ShowInTaskbar = false;
ClientSize = new Size(650, 390);
Controls.Add(new Label
{
Text = "Select windows to add to this profile:",
AutoSize = true,
Location = new Point(12, 12)
});
_windows.Location = new Point(12, 38);
_windows.Size = new Size(626, 300);
_windows.View = View.Details;
_windows.CheckBoxes = true;
_windows.FullRowSelect = true;
_windows.Columns.Add("Window title", 350);
_windows.Columns.Add("Process", 120);
_windows.Columns.Add("Class", 130);
Controls.Add(_windows);
var add = new Button
{
Text = "Add selected", Enabled = false,
Location = new Point(461, 350), Width = 95
};
add.Click += (_, _) =>
{
if (_windows.CheckedItems.Count > 0)
{
DialogResult = DialogResult.OK;
}
};
_windows.ItemChecked += (_, _) => add.Enabled = _windows.CheckedItems.Count > 0;
Controls.Add(add);
var cancel = new Button
{
Text = "Cancel", DialogResult = DialogResult.Cancel,
Location = new Point(563, 350), Width = 75
};
Controls.Add(cancel);
AcceptButton = add;
CancelButton = cancel;
foreach (var window in available)
{
var item = new ListViewItem(window.Title) { Tag = window };
item.SubItems.Add(window.ProcessName);
item.SubItems.Add(window.ClassName);
_windows.Items.Add(item);
}
}
}