我有一个WinForms应用程序,在TeeChart组件中绘制了许多行。请右击删除一行是可能的.
所有操作都很好,clickseries事件被捕获等等,但是用户发现在右击时很难命中这条线。问题是,是否有可能增加Line/FastLine对象可以单击的区域?也就是说,不要在屏幕上画更宽的线,就把线画得更宽。
Tnx预付
发布于 2015-10-08 13:50:26
是的,这是可能的。实现这一目标的关键是PointInLineTolerance法。要实现您的要求,可以将其与NearestPoint的工具GetNearestPoint法结合起来,如本例所示:
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(new Steema.TeeChart.Styles.Line()).FillSampleValues();
tChart1.MouseMove += TChart1_MouseMove;
}
private void TChart1_MouseMove(object sender, MouseEventArgs e)
{
var nearestPoint = new Steema.TeeChart.Tools.NearestPoint(tChart1[0]);
nearestPoint.Active = false;
var p = new Point(e.X, e.Y);
var index = nearestPoint.GetNearestPoint(p);
if (index != -1)
{
const int tolerance = 10;
var px = tChart1[0].CalcXPos(index);
var py = tChart1[0].CalcYPos(index);
var index2 = (index == tChart1[0].Count - 1) ? index - 1 : index + 1;
var qx = tChart1[0].CalcXPos(index2);
var qy = tChart1[0].CalcYPos(index2);
if (Steema.TeeChart.Drawing.Graphics3D.PointInLineTolerance(p, px, py, qx, qy, tolerance))
{
tChart1.Header.Text = "point " + index.ToString() + " clicked";
}
else
{
tChart1.Header.Text = "No point";
}
}另一种选择可能是使用与原始系列相同数据的不可见的假系列。
https://stackoverflow.com/questions/33014959
复制相似问题