EllipseAnnotation.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="EllipseAnnotation.cs" company="OxyPlot">
  3. // Copyright (c) 2014 OxyPlot contributors
  4. // </copyright>
  5. // <summary>
  6. // This is a Avalonia wrapper of OxyPlot.EllipseAnnotation
  7. // </summary>
  8. // --------------------------------------------------------------------------------------------------------------------
  9. using Avalonia;
  10. namespace OxyPlot.Avalonia
  11. {
  12. /// <summary>
  13. /// This is a Avalonia wrapper of OxyPlot.EllipseAnnotation
  14. /// </summary>
  15. public class EllipseAnnotation : ShapeAnnotation
  16. {
  17. /// <summary>
  18. /// Identifies the <see cref="X"/> dependency property.
  19. /// </summary>
  20. public static readonly StyledProperty<double> XProperty = AvaloniaProperty.Register<EllipseAnnotation, double>(nameof(X), 0.0);
  21. /// <summary>
  22. /// Identifies the <see cref="Y"/> dependency property.
  23. /// </summary>
  24. public static readonly StyledProperty<double> YProperty = AvaloniaProperty.Register<EllipseAnnotation, double>(nameof(Y), 0.0);
  25. /// <summary>
  26. /// Initializes static members of the <see cref="EllipseAnnotation"/> class.
  27. /// </summary>
  28. static EllipseAnnotation()
  29. {
  30. TextColorProperty.OverrideDefaultValue<EllipseAnnotation>(MoreColors.Automatic);
  31. TextColorProperty.Changed.AddClassHandler<EllipseAnnotation>(AppearanceChanged);
  32. XProperty.Changed.AddClassHandler<EllipseAnnotation>(DataChanged);
  33. YProperty.Changed.AddClassHandler<EllipseAnnotation>(DataChanged);
  34. WidthProperty.Changed.AddClassHandler<EllipseAnnotation>(DataChanged);
  35. HeightProperty.Changed.AddClassHandler<EllipseAnnotation>(DataChanged);
  36. }
  37. /// <summary>
  38. /// Initializes a new instance of the <see cref="EllipseAnnotation" /> class.
  39. /// </summary>
  40. public EllipseAnnotation()
  41. {
  42. InternalAnnotation = new Annotations.EllipseAnnotation();
  43. }
  44. /// <summary>
  45. /// Gets or sets the X.
  46. /// </summary>
  47. public double X
  48. {
  49. get
  50. {
  51. return GetValue(XProperty);
  52. }
  53. set
  54. {
  55. SetValue(XProperty, value);
  56. }
  57. }
  58. /// <summary>
  59. /// Gets or sets the Y.
  60. /// </summary>
  61. public double Y
  62. {
  63. get
  64. {
  65. return GetValue(YProperty);
  66. }
  67. set
  68. {
  69. SetValue(YProperty, value);
  70. }
  71. }
  72. /// <summary>
  73. /// Creates the internal annotation object.
  74. /// </summary>
  75. /// <returns>The annotation.</returns>
  76. public override Annotations.Annotation CreateModel()
  77. {
  78. SynchronizeProperties();
  79. return InternalAnnotation;
  80. }
  81. /// <summary>
  82. /// Synchronizes the properties.
  83. /// </summary>
  84. public override void SynchronizeProperties()
  85. {
  86. base.SynchronizeProperties();
  87. var a = (Annotations.EllipseAnnotation)InternalAnnotation;
  88. a.X = X;
  89. a.Width = Width;
  90. a.Y = Y;
  91. a.Height = Height;
  92. }
  93. }
  94. }