port from perforce
This commit is contained in:
57
intromat/Intromat/Views/UserInputWindow.xaml.cs
Normal file
57
intromat/Intromat/Views/UserInputWindow.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Intromat.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for UserInputWindow.xaml
|
||||
/// </summary>
|
||||
public partial class UserInputWindow
|
||||
{
|
||||
public UserInputWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public string? Result { get; set; }
|
||||
|
||||
public static string? Show(Window? owner, string? header, string? title = null, string? defaultValue = null)
|
||||
{
|
||||
var window = new UserInputWindow
|
||||
{
|
||||
Owner = owner,
|
||||
Title = title ?? "Intromat",
|
||||
Header = { Text = header ?? "Enter value:" }
|
||||
};
|
||||
if (defaultValue != null)
|
||||
window.Input.Text = window.Result = defaultValue;
|
||||
window.Input.SelectAll();
|
||||
window.Input.Focus();
|
||||
return window.ShowDialog() == true ? window.Result : null;
|
||||
}
|
||||
|
||||
private void Input_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
Result = Input.Text;
|
||||
}
|
||||
|
||||
private void ButtonOK_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void UserInputWindow_OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (DialogResult != true)
|
||||
Result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user