DFLayoutStringFieldProperties.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. namespace InABox.Core
  2. {
  3. public class DFLayoutStringFieldProperties : DFLayoutFieldProperties<string, string?>
  4. {
  5. [EditorSequence(3)]
  6. [CheckBoxEditor(Caption = "Allow Wrap?")]
  7. public bool TextWrapping { get; set; } = false;
  8. [EditorSequence(4)]
  9. [CheckBoxEditor(Caption = "Popup Editor?")]
  10. public bool PopupEditor { get; set; } = false;
  11. public override string? DeserializeValue(DFLoadStorageEntry entry)
  12. {
  13. return entry.GetValue<string>();
  14. }
  15. public override void SerializeValue(DFSaveStorageEntry entry, string? value)
  16. {
  17. entry.SetValue(value);
  18. }
  19. public override string GetValue(string? value)
  20. {
  21. return value ?? Default;
  22. }
  23. public override string FormatValue(string? value)
  24. {
  25. return value ?? "";
  26. }
  27. protected override void LoadProperties()
  28. {
  29. base.LoadProperties();
  30. PopupEditor = GetProperty(nameof(PopupEditor), false);
  31. TextWrapping = GetProperty(nameof(TextWrapping), false);
  32. }
  33. protected override void SaveProperties()
  34. {
  35. base.SaveProperties();
  36. SetProperty(nameof(PopupEditor), PopupEditor);
  37. SetProperty(nameof(TextWrapping), TextWrapping);
  38. }
  39. }
  40. }