using InABox.Core;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace InABox.DynamicGrid
{
    public class DFFieldPlaceholderControl<TField> : DynamicFormControl<TField>
        where TField : DFLayoutField
    {
        protected override FrameworkElement Create()
        {
            var result = new Border();
            result.Child = new Label
            {
                Content = string.Format("[{0}]", Control.Name),
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment = VerticalAlignment.Center,
                FontWeight = FontWeights.DemiBold
            };
            var code = Control.Name; // GetPropertyValue<String>("Code");
            var variable = FormDesignGrid.Variables.FirstOrDefault(x => string.Equals(x.Code, code) && !x.Hidden);
            result.Background = variable != null ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Red);
            result.BorderBrush = BorderBrush;
            result.BorderThickness = new Thickness(0.75);
            return result;
        }
    }
}
