DFLayoutLabel.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. namespace InABox.Core
  2. {
  3. public class DFLayoutLabel : DFLayoutControl, IDFLayoutTextControl
  4. {
  5. [EditorSequence(0)]
  6. [MemoEditor]
  7. public string Caption { get; set; } = "";
  8. [EditorSequence("Style", 0)]
  9. public DFLayoutTextStyle Style => InitializeField(ref _style, nameof(Style));
  10. private DFLayoutTextStyle? _style;
  11. protected override string GetDescription()
  12. {
  13. return Caption;
  14. }
  15. protected override void LoadProperties()
  16. {
  17. base.LoadProperties();
  18. Caption = GetProperty("Caption", "");
  19. Style.LoadProperties(this);
  20. }
  21. protected override void SaveProperties()
  22. {
  23. base.SaveProperties();
  24. SetProperty("Caption", Caption);
  25. Style.SaveProperties(this);
  26. }
  27. public T GetStyleProperty<T>(string name, T defaultValue)
  28. {
  29. return GetProperty($"Style.{name}", defaultValue);
  30. }
  31. public void SetStyleProperty(string name, object? value)
  32. {
  33. SetProperty($"Style.{name}", value);
  34. }
  35. }
  36. }