DFLayoutLabel.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 => InitializeField(ref _style, nameof(Style));
  14. private DFLayoutTextStyle? _style;
  15. protected override string GetDescription()
  16. {
  17. return Caption;
  18. }
  19. protected override void LoadProperties()
  20. {
  21. base.LoadProperties();
  22. Caption = GetProperty("Caption", "");
  23. Style.LoadProperties(this);
  24. }
  25. protected override void SaveProperties()
  26. {
  27. base.SaveProperties();
  28. SetProperty("Caption", Caption);
  29. Style.SaveProperties(this);
  30. }
  31. public T GetStyleProperty<T>(string name, T defaultValue)
  32. {
  33. return GetProperty($"Style.{name}", defaultValue);
  34. }
  35. public void SetStyleProperty(string name, object? value)
  36. {
  37. SetProperty($"Style.{name}", value);
  38. }
  39. }
  40. }