Cursors
Posted: Mon Apr 13, 2009 5:14 pm
Are there any changes in version 4 to address cursor performance?
Steema Software - Customer Support Forums
https://407832.verdetrade-hk.tech/support/
https://407832.verdetrade-hk.tech/support/viewtopic.php?f=7&t=9566
Nothing else has been done on that field. That's why FastCursor property was implemented.while the regular cursor is choppy in movement when there are a large number of points due to the painting
Yes, this works fine with our current v4 sources and using code below. You can see that only the annotation tool is being repainted if you set FastCursor to false.One of the issues with fastcursor is that you may want to display information on the chart as the cursor is changing. With TeeChart you seem to be only able to paint all the screen and not a portion of the screen.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Tools.Annotation anno;
private Rectangle r1;
private void InitializeChart()
{
tChart1.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.DoubleBuffer;
tChart1.Aspect.View3D = false;
tChart1.Series.Add(typeof(Steema.TeeChart.Styles.Line));
tChart1[0].FillSampleValues(10000);
Steema.TeeChart.Tools.CursorTool cursor;
tChart1.Tools.Add(cursor = new Steema.TeeChart.Tools.CursorTool());
cursor.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
cursor.FollowMouse = true;
cursor.FastCursor = true; //try false
cursor.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(cursor_Change);
tChart1.Tools.Add(anno = new Steema.TeeChart.Tools.Annotation());
anno.AutoSize = false;
anno.Top = 10;
anno.Left = 10;
anno.Height = 20;
anno.Width = 110;
r1 = anno.Shape.ShapeBounds;
tChart1.AutoRepaint = false;
}
void cursor_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
{
anno.Text = e.XValue.ToString();
tChart1.Invalidate(r1);
}
Code: Select all
private Rectangle oldRect;
void cursor_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
{
anno.Text = e.XValue.ToString();
tChart1.Invalidate(r1);
Rectangle rect = tChart1.Chart.ChartRect;
Steema.TeeChart.Tools.CursorTool cursor = (Steema.TeeChart.Tools.CursorTool)sender;
int cursorPos = tChart1.Axes.Bottom.CalcPosValue(e.XValue - cursor.Pen.Width/2);
Rectangle r2 = new Rectangle(cursorPos, rect.Top, cursor.Pen.Width, rect.Height);
if (oldRect!=null) tChart1.Invalidate(oldRect);
tChart1.Invalidate(r2);
oldRect = r2;
}