// *********************************************************************** // Assembly : HZH_Controls // Created : 2019-09-23 // // *********************************************************************** // // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // // // Blog: https://www.cnblogs.com/bfyx // GitHub:https://github.com/kwwwvagaa/NetWinformControl // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // // If you use this code, please keep this note. // *********************************************************************** using System.Drawing; namespace HZH_Controls.Controls { /// /// Class MarkText. /// public class MarkText { /// /// The mark text offect /// public static readonly int MarkTextOffect = 5; /// /// Gets or sets the curve key. /// /// The curve key. public string CurveKey { get; set; } /// /// Gets or sets the index. /// /// The index. public int Index { get; set; } /// /// Gets or sets the mark text. /// /// The mark text. public string Text { get; set; } private Color? textColor = null; public Color? TextColor { get { return textColor; } set { textColor = value; } } /// /// The position style /// private MarkTextPositionStyle positionStyle = MarkTextPositionStyle.Auto; /// /// Gets or sets the position style. /// /// The position style. public MarkTextPositionStyle PositionStyle { get { return positionStyle; } set { positionStyle = value; } } /// /// Calculates the index of the direction from data. /// /// The data. /// The index. /// MarkTextPositionStyle. public static MarkTextPositionStyle CalculateDirectionFromDataIndex(float[] data, int Index) { float num = (Index == 0) ? data[Index] : data[Index - 1]; float num2 = (Index == data.Length - 1) ? data[Index] : data[Index + 1]; if (num < data[Index] && data[Index] < num2) { return MarkTextPositionStyle.Left; } if (num > data[Index] && data[Index] > num2) { return MarkTextPositionStyle.Right; } if (num <= data[Index] && data[Index] >= num2) { return MarkTextPositionStyle.Up; } if (num >= data[Index] && data[Index] <= num2) { return MarkTextPositionStyle.Down; } return MarkTextPositionStyle.Up; } } }