-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputBox.xaml.cs
More file actions
34 lines (30 loc) · 1.04 KB
/
InputBox.xaml.cs
File metadata and controls
34 lines (30 loc) · 1.04 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
using System.Windows;
using System.Windows.Input;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
namespace SecureAppVault
{
public partial class InputBox : Window
{
public string InputText { get; private set; } = string.Empty; // Initialize to an empty string
public InputBox(string prompt)
{
InitializeComponent();
PromptTextBlock.Text = prompt;
WindowStartupLocation = WindowStartupLocation.CenterScreen; // Center the window on the screen
Loaded += (sender, e) => InputTextBox.Focus(); // Set focus to the text box when the window is loaded
}
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
InputText = InputTextBox.Text;
DialogResult = true;
}
}
private void OkButton_Click(object sender, RoutedEventArgs e)
{
InputText = InputTextBox.Text;
DialogResult = true;
}
}
}