using InABox.Core;
using Syncfusion.Windows.Shared;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace InABox.DynamicGrid
{
    public class DFStringControl : DynamicFormFieldControl<DFLayoutStringField, DFLayoutStringFieldProperties, string>
    {
        private TextBox Text = null!; // late-initialising

        protected override FrameworkElement Create()
        {
            Text = new TextBox();
            Text.Text = Field.Properties.Default;
            Text.HorizontalContentAlignment = HorizontalAlignment.Left;
            Text.VerticalContentAlignment = VerticalAlignment.Center;
            Text.TextChanged += (sender, e) => ChangeField();
            return Text;
        }

        public override string GetValue() => Text.Text;

        public override void SetValue(string? value) => Text.Text = value;

        protected override bool IsEmpty() => string.IsNullOrWhiteSpace(Text.Text);
    }
}
