DFLayoutOptionFieldProperties.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. namespace InABox.Core
  2. {
  3. public class DFLayoutOptionFieldProperties : DFLayoutFieldProperties<string, string?>
  4. {
  5. [EditorSequence(-995)]
  6. [TextBoxEditor]
  7. public override string Default { get; set; }
  8. public DFLayoutOptionFieldProperties()
  9. {
  10. Options = "";
  11. OptionType = DFLayoutOptionType.Combo;
  12. }
  13. [MemoEditor]
  14. [EditorSequence(1)]
  15. public string Options { get; set; }
  16. [EnumLookupEditor(typeof(DFLayoutOptionType))]
  17. [EditorSequence(2)]
  18. public DFLayoutOptionType OptionType { get; set; }
  19. protected override void LoadProperties()
  20. {
  21. base.LoadProperties();
  22. Options = GetProperty("Options", "");
  23. OptionType = GetProperty("OptionType", DFLayoutOptionType.Combo);
  24. }
  25. protected override void SaveProperties()
  26. {
  27. base.SaveProperties();
  28. SetProperty("Options", Options);
  29. SetProperty("OptionType", OptionType);
  30. }
  31. public override string? DeserializeValue(DFLoadStorageEntry entry)
  32. {
  33. return entry.GetValue<string>();
  34. }
  35. public override void SerializeValue(DFSaveStorageEntry entry, string? value)
  36. {
  37. entry.SetValue(value);
  38. }
  39. public override string GetValue(string? value)
  40. {
  41. return value ?? Default;
  42. }
  43. public override string FormatValue(string? value)
  44. {
  45. return value ?? string.Empty;
  46. }
  47. }
  48. }