|
@@ -1,5 +1,6 @@
|
|
|
using InABox.Wpf;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
|
|
|
namespace InABox.WPF
|
|
|
{
|
|
@@ -8,11 +9,16 @@ namespace InABox.WPF
|
|
|
/// </summary>
|
|
|
public partial class TextBoxDialog : ThemableWindow
|
|
|
{
|
|
|
- public TextBoxDialog(string caption, string text)
|
|
|
+
|
|
|
+ private readonly bool _allowblank;
|
|
|
+
|
|
|
+ public TextBoxDialog(string caption, string text, bool allowblank)
|
|
|
{
|
|
|
+ _allowblank = allowblank;
|
|
|
InitializeComponent();
|
|
|
Title = caption;
|
|
|
Memo.Text = text;
|
|
|
+ OK.IsEnabled = _allowblank || !string.IsNullOrWhiteSpace(Memo.Text);
|
|
|
}
|
|
|
|
|
|
public string Text
|
|
@@ -20,6 +26,11 @@ namespace InABox.WPF
|
|
|
get => Memo.Text;
|
|
|
set => Memo.Text = value;
|
|
|
}
|
|
|
+
|
|
|
+ private void Memo_OnTextChanged(object sender, TextChangedEventArgs e)
|
|
|
+ {
|
|
|
+ OK.IsEnabled = _allowblank || !string.IsNullOrWhiteSpace(Memo.Text);
|
|
|
+ }
|
|
|
|
|
|
private void OK_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
@@ -33,9 +44,9 @@ namespace InABox.WPF
|
|
|
Close();
|
|
|
}
|
|
|
|
|
|
- public static bool Execute(string caption, ref string text)
|
|
|
+ public static bool Execute(string caption, ref string text, bool allowblank = true)
|
|
|
{
|
|
|
- var editor = new TextBoxDialog(caption, text);
|
|
|
+ var editor = new TextBoxDialog(caption, text, allowblank);
|
|
|
if (editor.ShowDialog() == true)
|
|
|
{
|
|
|
text = editor.Memo.Text;
|
|
@@ -44,5 +55,6 @@ namespace InABox.WPF
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|