AngleAxis.cs 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="AngleAxis.cs" company="OxyPlot">
  3. // Copyright (c) 2014 OxyPlot contributors
  4. // </copyright>
  5. // <summary>
  6. // This is a Avalonia wrapper of OxyPlot.AngleAxis.
  7. // </summary>
  8. // --------------------------------------------------------------------------------------------------------------------
  9. using Avalonia;
  10. namespace OxyPlot.Avalonia
  11. {
  12. using OxyPlot.Axes;
  13. /// <summary>
  14. /// This is a Avalonia wrapper of OxyPlot.AngleAxis.
  15. /// </summary>
  16. public class AngleAxis : LinearAxis
  17. {
  18. /// <summary>
  19. /// Identifies the <see cref="StartAngle"/> dependency property.
  20. /// </summary>
  21. public static readonly StyledProperty<double> StartAngleProperty = AvaloniaProperty.Register<AngleAxis, double>(nameof(StartAngle), 0d);
  22. /// <summary>
  23. /// Identifies the <see cref="EndAngle"/> dependency property.
  24. /// </summary>
  25. public static readonly StyledProperty<double> EndAngleProperty = AvaloniaProperty.Register<AngleAxis, double>(nameof(EndAngle), 360d);
  26. /// <summary>
  27. /// Initializes static members of the <see cref = "AngleAxis" /> class.
  28. /// </summary>
  29. static AngleAxis()
  30. {
  31. MajorGridlineStyleProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata<LineStyle>(LineStyle.Solid));
  32. MinorGridlineStyleProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata<LineStyle>(LineStyle.Solid));
  33. PositionProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata<AxisPosition>(AxisPosition.None));
  34. TickStyleProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata<TickStyle>(TickStyle.None));
  35. IsPanEnabledProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata<bool>(false));
  36. IsZoomEnabledProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata<bool>(false));
  37. StartAngleProperty.Changed.AddClassHandler<AngleAxis>(AppearanceChanged);
  38. EndAngleProperty.Changed.AddClassHandler<AngleAxis>(AppearanceChanged);
  39. PositionProperty.Changed.AddClassHandler<AngleAxis>(AppearanceChanged);
  40. TickStyleProperty.Changed.AddClassHandler<AngleAxis>(AppearanceChanged);
  41. }
  42. /// <summary>
  43. /// Initializes a new instance of the <see cref = "AngleAxis" /> class.
  44. /// </summary>
  45. public AngleAxis()
  46. {
  47. InternalAxis = new Axes.AngleAxis();
  48. MajorGridlineStyle = LineStyle.Solid;
  49. MinorGridlineStyle = LineStyle.Solid;
  50. }
  51. /// <summary>
  52. /// Gets or sets the start angle (degrees).
  53. /// </summary>
  54. public double StartAngle
  55. {
  56. get { return GetValue(StartAngleProperty); }
  57. set { SetValue(StartAngleProperty, value); }
  58. }
  59. /// <summary>
  60. /// Gets or sets the end angle (degrees).
  61. /// </summary>
  62. public double EndAngle
  63. {
  64. get { return GetValue(EndAngleProperty); }
  65. set { SetValue(EndAngleProperty, value); }
  66. }
  67. /// <summary>
  68. /// Synchronizes the properties.
  69. /// </summary>
  70. protected override void SynchronizeProperties()
  71. {
  72. base.SynchronizeProperties();
  73. var a = (Axes.AngleAxis)InternalAxis;
  74. a.StartAngle = StartAngle;
  75. a.EndAngle = EndAngle;
  76. a.FractionUnitSymbol = FractionUnitSymbol;
  77. }
  78. }
  79. }