DFLayoutLabel.cs 1.1 KB

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