DFLayoutOptionFieldProperties.cs 1.4 KB

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