-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathInputBox.xaml.cs
56 lines (49 loc) · 1.53 KB
/
InputBox.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
50
51
52
53
54
55
56
using System;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Input;
namespace FSClient {
/// <summary>
/// Interaction logic for InputBox.xaml
/// </summary>
public partial class InputBox : Window {
public InputBox() {
InitializeComponent();
Loaded += InputBox_Loaded;
}
void InputBox_Loaded(object sender, RoutedEventArgs e) {
txtInput.Focus();
}
public static string GetInput(String title, String desc, String default_value) {
InputBox box = new InputBox();
box.lblDesc.Content = desc;
box.Title = title;
AutomationProperties.SetName(box.txtInput, desc);
box.txtInput.Text = default_value;
if (box.ShowDialog() != true)
return null;
return box.txtInput.Text;
}
public static string[] GetTwoInput(String title, String desc, String label1, String default_value1, String label2, String default_value2) {
InputBox box = new InputBox();
box.lblDesc.Content = desc;
box.Title = title;
box.rowInput.Height = new GridLength(60);
box.Height = 170;
AutomationProperties.SetName(box.txtInput, desc);
box.txtInput.Text = default_value1;
box.txtInput2.Text = default_value2;
if(box.ShowDialog() != true)
return null;
return new[] { box.txtInput.Text, box.txtInput2.Text };
}
private void btnOk_Click(object sender, RoutedEventArgs e) {
DialogResult = true;
Close();
}
private void btnCancel_Click(object sender, RoutedEventArgs e) {
DialogResult = false;
Close();
}
}
}