DFLayoutEmbeddedImageProperties.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. namespace InABox.Core
  3. {
  4. public class DFLayoutEmbeddedImageProperties : DFLayoutFieldProperties<byte[]>
  5. {
  6. [CheckBoxEditor]
  7. public bool DisableLibrary { get; set; }
  8. public override string FormatValue(object value)
  9. {
  10. return value != null ? "Yes" : "";
  11. }
  12. public override object? ParseValue(object value)
  13. {
  14. if (value is byte[])
  15. return value;
  16. if (value is string)
  17. try
  18. {
  19. return Convert.FromBase64String(value as string);
  20. }
  21. catch (Exception e)
  22. {
  23. return null;
  24. }
  25. return null;
  26. }
  27. protected override void LoadProperties()
  28. {
  29. base.LoadProperties();
  30. DisableLibrary = GetProperty("DisableLibrary", false);
  31. }
  32. protected override void SaveProperties()
  33. {
  34. base.SaveProperties();
  35. SetProperty("DisableLibrary", DisableLibrary);
  36. }
  37. }
  38. }