diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index 999bb33d..fc3115d6 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/SunnyUI/Charts/UILineChartOption.cs b/SunnyUI/Charts/UILineChartOption.cs index ea03e8e8..2602c95e 100644 --- a/SunnyUI/Charts/UILineChartOption.cs +++ b/SunnyUI/Charts/UILineChartOption.cs @@ -305,6 +305,24 @@ namespace Sunny.UI return false; } + public bool GetNearestPointX(Point p, int offset, out double x, out double y, out int index) + { + x = 0; + y = 0; + index = -1; + if (PointsX.Count == 0) return false; + + index = PointsX.BinarySearchNearIndex(p.X); + if (p.X >= PointsX[index] - offset && p.X <= PointsX[index] + offset) + { + x = XData[index]; + y = YData[index]; + return true; + } + + return false; + } + public void Clear() { XData.Clear(); diff --git a/SunnyUI/Controls/UIListBox.cs b/SunnyUI/Controls/UIListBox.cs index 1acd5bce..dafa6002 100644 --- a/SunnyUI/Controls/UIListBox.cs +++ b/SunnyUI/Controls/UIListBox.cs @@ -69,6 +69,14 @@ namespace Sunny.UI timer.Start(); } + [DefaultValue(StringAlignment.Near)] + [Description("列表项高度"), Category("SunnyUI")] + public new StringAlignment TextAlignment + { + get => listbox.TextAlignment; + set => listbox.TextAlignment = value; + } + protected override void OnContextMenuStripChanged(EventArgs e) { base.OnContextMenuStripChanged(e); @@ -503,6 +511,18 @@ namespace Sunny.UI public event OnBeforeDrawItem AfterDrawItem; + private StringAlignment textAlignment = StringAlignment.Near; + + public StringAlignment TextAlignment + { + get => textAlignment; + set + { + textAlignment = value; + Invalidate(); + } + } + protected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); @@ -526,6 +546,7 @@ namespace Sunny.UI StringFormat sStringFormat = new StringFormat(); sStringFormat.LineAlignment = StringAlignment.Center; + sStringFormat.Alignment = textAlignment; bool isSelected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; Color backColor = isSelected ? ItemSelectBackColor : BackColor;