我正在评估Teechart 4.1.2012.2287,矩形工具有问题。我的项目是用VS2010编写的,使用VB.Net和framework 4.0。
如果放置一个矩形工具,并将位置单位设置为百分比(我需要这样做,以便在调整图表大小时矩形保持在大致相同的位置),当鼠标指针位于矩形上时,抓手不会显示。实际上,它确实错误地显示在相应的像素位置,而不是百分比位置。
这是bug还是我做错了什么?
我已经能够用下面的代码片段重现这个问题,并将它(TF02016130)添加到要调查的缺陷列表中。
tChart1.Aspect.View3D = false;
tChart1.Dock = DockStyle.Fill;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points()).FillSampleValues();
Steema.TeeChart.Tools.RectangleTool rectangle1 = new Steema.TeeChart.Tools.RectangleTool(tChart1.Chart);
rectangle1.Text = "My rectangle tool";
rectangle1.AutoSize = true;
rectangle1.PositionUnits = Steema.TeeChart.PositionUnits.Percent;
rectangle1.Shape.CustomPosition = true;
rectangle1.Shape.Left = 50;
rectangle1.Shape.Top = 50;
rectangle1.AllowDrag = true;
rectangle1.AllowResize = true;
rectangle1.AllowEdit = true;
同时,一个解决方法是使用AfterDraw事件和像素定位,如下所示:
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Tools.RectangleTool rectangle1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Dock = DockStyle.Fill;
tChart1.Series.Add(new Steema.TeeChart.Styles.Points()).FillSampleValues();
rectangle1 = new Steema.TeeChart.Tools.RectangleTool(tChart1.Chart);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
rectangle1.Text = "My rectangle tool";
rectangle1.AutoSize = true;
rectangle1.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
rectangle1.AllowDrag = true;
rectangle1.AllowResize = true;
rectangle1.AllowEdit = true;
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
rectangle1.Shape.CustomPosition = true;
rectangle1.Shape.Left = tChart1.Width / 2;
rectangle1.Shape.Top = tChart1.Height / 2;
}