DFLayoutLabel.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Drawing;
  5. namespace InABox.Core
  6. {
  7. public class DFLayoutLabel : DFLayoutControl, IDFLayoutTextControl
  8. {
  9. [EditorSequence(0)]
  10. [MemoEditor]
  11. public string Caption { get; set; }
  12. [EditorSequence("Style", 0)]
  13. public DFLayoutTextStyle Style { get; set; }
  14. protected override void Init()
  15. {
  16. base.Init();
  17. Caption = "";
  18. Style = new DFLayoutTextStyle();
  19. }
  20. protected override string GetDescription()
  21. {
  22. return Caption;
  23. }
  24. protected override void LoadProperties()
  25. {
  26. base.LoadProperties();
  27. Caption = GetProperty("Caption", "");
  28. Style.LoadProperties(this);
  29. }
  30. protected override void SaveProperties()
  31. {
  32. base.SaveProperties();
  33. SetProperty("Caption", Caption);
  34. Style.SaveProperties(this);
  35. }
  36. public T GetStyleProperty<T>(string name, T defaultValue)
  37. {
  38. return GetProperty($"Style.{name}", defaultValue);
  39. }
  40. public void SetStyleProperty(string name, object? value)
  41. {
  42. SetProperty($"Style.{name}", value);
  43. }
  44. }
  45. }