TextBoxDialog.xaml.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using InABox.Wpf;
  2. using System.Windows;
  3. namespace InABox.WPF
  4. {
  5. /// <summary>
  6. /// Interaction logic for MemoEditor.xaml
  7. /// </summary>
  8. public partial class TextBoxDialog : ThemableWindow
  9. {
  10. public TextBoxDialog(string caption, string text)
  11. {
  12. InitializeComponent();
  13. Title = caption;
  14. Memo.Text = text;
  15. }
  16. public string Text
  17. {
  18. get => Memo.Text;
  19. set => Memo.Text = value;
  20. }
  21. private void OK_Click(object sender, RoutedEventArgs e)
  22. {
  23. DialogResult = true;
  24. Close();
  25. }
  26. private void Cancel_Click(object sender, RoutedEventArgs e)
  27. {
  28. DialogResult = false;
  29. Close();
  30. }
  31. public static bool Execute(string caption, ref string text)
  32. {
  33. var editor = new TextBoxDialog(caption, text);
  34. if (editor.ShowDialog() == true)
  35. {
  36. text = editor.Memo.Text;
  37. return true;
  38. }
  39. return false;
  40. }
  41. }
  42. }