-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFindWindow.xaml.cs
49 lines (39 loc) · 1.51 KB
/
FindWindow.xaml.cs
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
using System.Windows;
using System.Windows.Controls;
namespace RedundantFileRemover {
public partial class FindWindow : Window {
public static MainWindow MainInstance { private get; set; }
public FindWindow() {
InitializeComponent();
}
private void closeButton_Click(object sender, RoutedEventArgs e) {
Close();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
e.Cancel = true;
Visibility = Visibility.Hidden;
}
private void findKey_TextChanged(object sender, TextChangedEventArgs e) {
findButton.IsEnabled = findKey.Text.Trim().Length != 0;
}
private void findButton_Click(object sender, RoutedEventArgs e) {
FindKey();
}
private void findKey_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == System.Windows.Input.Key.Enter) {
FindKey();
}
}
private void FindKey() {
foreach (ListBoxItem item in MainInstance.logs.Items) {
if (item.Content.ToString().Contains(findKey.Text)) {
Close();
MainInstance.logs.SelectedItem = item;
MainInstance.logs.ScrollIntoView(item);
return;
}
}
MessageBox.Show(this, "Key not found", "No key found with the specified name", MessageBoxButton.OK);
}
}
}