using InABox.Wpf;
using System.Windows;

namespace InABox.WPF
{
    /// <summary>
    ///     Interaction logic for MemoEditor.xaml
    /// </summary>
    public partial class TextBoxDialog : ThemableWindow
    {
        public TextBoxDialog(string caption, string text)
        {
            InitializeComponent();
            Title = caption;
            Memo.Text = text;
        }

        public string Text
        {
            get => Memo.Text;
            set => Memo.Text = value;
        }

        private void OK_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            Close();
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }

        public static bool Execute(string caption, ref string text)
        {
            var editor = new TextBoxDialog(caption, text);
            if (editor.ShowDialog() == true)
            {
                text = editor.Memo.Text;
                return true;
            }

            return false;
        }
    }
}