-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProcessSelectionWindow.xaml.cs
More file actions
54 lines (47 loc) · 1.46 KB
/
Copy pathProcessSelectionWindow.xaml.cs
File metadata and controls
54 lines (47 loc) · 1.46 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
using System;
using System.Collections.Generic;
using System.Windows;
namespace WpfApp1
{
public partial class ProcessSelectionWindow : Window
{
public string SelectedProcessName { get; private set; }
public ProcessSelectionWindow(List<ProcessItem> processes)
{
InitializeComponent();
ProcessListBox.ItemsSource = processes;
}
public void RefreshList()
{
ProcessListBox.Items.Refresh();
}
private void Select_Click(object sender, RoutedEventArgs e)
{
if (ProcessListBox.SelectedItem is ProcessItem selected)
{
SelectedProcessName = selected.Name;
DialogResult = true;
Close();
}
else
{
System.Windows.MessageBox.Show("Please select a process.", "No Selection", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
private void ProcessListBox_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Select_Click(sender, e);
}
}
public class ProcessItem
{
public string Name { get; set; }
public string MemoryUsage { get; set; }
public System.Windows.Media.ImageSource Icon { get; set; }
}
}