namespace InABox.Core
{
    public class DFLayoutOptionFieldProperties : DFLayoutFieldProperties<string>
    {
        public DFLayoutOptionFieldProperties()
        {
            Options = "";
            OptionType = DFLayoutOptionType.Combo;
        }

        [MemoEditor]
        [EditorSequence(1)]
        public string Options { get; set; }

        [EnumLookupEditor(typeof(DFLayoutOptionType))]
        [EditorSequence(2)]
        public DFLayoutOptionType OptionType { get; set; }

        protected override void LoadProperties()
        {
            base.LoadProperties();
            Options = GetProperty("Options", "");
            OptionType = GetProperty("OptionType", DFLayoutOptionType.Combo);
        }

        protected override void SaveProperties()
        {
            base.SaveProperties();
            SetProperty("Options", Options);
            SetProperty("OptionType", OptionType);
        }

        public override object ParseValue(object value)
        {
            return value?.ToString();
        }

        public override string FormatValue(object value)
        {
            return value?.ToString() ?? "";
        }
    }
}