MarkText.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // ***********************************************************************
  2. // Assembly : HZH_Controls
  3. // Created : 2019-09-23
  4. //
  5. // ***********************************************************************
  6. // <copyright file="MarkText.cs">
  7. // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
  8. // </copyright>
  9. //
  10. // Blog: https://www.cnblogs.com/bfyx
  11. // GitHub:https://github.com/kwwwvagaa/NetWinformControl
  12. // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
  13. //
  14. // If you use this code, please keep this note.
  15. // ***********************************************************************
  16. using System.Drawing;
  17. namespace HZH_Controls.Controls
  18. {
  19. /// <summary>
  20. /// Class MarkText.
  21. /// </summary>
  22. public class MarkText
  23. {
  24. /// <summary>
  25. /// The mark text offect
  26. /// </summary>
  27. public static readonly int MarkTextOffect = 5;
  28. /// <summary>
  29. /// Gets or sets the curve key.
  30. /// </summary>
  31. /// <value>The curve key.</value>
  32. public string CurveKey
  33. {
  34. get;
  35. set;
  36. }
  37. /// <summary>
  38. /// Gets or sets the index.
  39. /// </summary>
  40. /// <value>The index.</value>
  41. public int Index
  42. {
  43. get;
  44. set;
  45. }
  46. /// <summary>
  47. /// Gets or sets the mark text.
  48. /// </summary>
  49. /// <value>The mark text.</value>
  50. public string Text
  51. {
  52. get;
  53. set;
  54. }
  55. private Color? textColor = null;
  56. public Color? TextColor
  57. {
  58. get { return textColor; }
  59. set { textColor = value; }
  60. }
  61. /// <summary>
  62. /// The position style
  63. /// </summary>
  64. private MarkTextPositionStyle positionStyle = MarkTextPositionStyle.Auto;
  65. /// <summary>
  66. /// Gets or sets the position style.
  67. /// </summary>
  68. /// <value>The position style.</value>
  69. public MarkTextPositionStyle PositionStyle
  70. {
  71. get { return positionStyle; }
  72. set { positionStyle = value; }
  73. }
  74. /// <summary>
  75. /// Calculates the index of the direction from data.
  76. /// </summary>
  77. /// <param name="data">The data.</param>
  78. /// <param name="Index">The index.</param>
  79. /// <returns>MarkTextPositionStyle.</returns>
  80. public static MarkTextPositionStyle CalculateDirectionFromDataIndex(float[] data, int Index)
  81. {
  82. float num = (Index == 0) ? data[Index] : data[Index - 1];
  83. float num2 = (Index == data.Length - 1) ? data[Index] : data[Index + 1];
  84. if (num < data[Index] && data[Index] < num2)
  85. {
  86. return MarkTextPositionStyle.Left;
  87. }
  88. if (num > data[Index] && data[Index] > num2)
  89. {
  90. return MarkTextPositionStyle.Right;
  91. }
  92. if (num <= data[Index] && data[Index] >= num2)
  93. {
  94. return MarkTextPositionStyle.Up;
  95. }
  96. if (num >= data[Index] && data[Index] <= num2)
  97. {
  98. return MarkTextPositionStyle.Down;
  99. }
  100. return MarkTextPositionStyle.Up;
  101. }
  102. }
  103. }