100% cpu load in vista
Posted: Wed Oct 22, 2008 11:50 am
Hello,
if i put a simple tchart onto a form, then implement the code that i appended to this message, i get a 100% cpu load under windows vista
as soon as i move the mouse into the chart. In windows xp everything works fine, only moderate cpu load if i move the mouse
Am i doing something wrong? In Vista the tooltip flickers on and off it seems the chart is redrawn all the time.
Regards Klaus
if i put a simple tchart onto a form, then implement the code that i appended to this message, i get a 100% cpu load under windows vista
as soon as i move the mouse into the chart. In windows xp everything works fine, only moderate cpu load if i move the mouse
Am i doing something wrong? In Vista the tooltip flickers on and off it seems the chart is redrawn all the time.
Regards Klaus
Code: Select all
namespace TChartIssues
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
tChart1.Aspect.View3D = false;
Line line = new Line();
line.Title = "Test data";
line.Stacked = Steema.TeeChart.Styles.CustomStack.Overlap;
tChart1.Series.Add(line);
//add some random data:
Random rand = new Random();
for (int a = 0; a < 1000; a++)
{
line.Add(new DateTime(DateTime.Now.Ticks + (a * 9000000000)), rand.NextDouble());
}
}
private Steema.TeeChart.Tools.CursorTool m_CursorTool;
/// <summary>
/// Get the cursortool
/// </summary>
protected Steema.TeeChart.Tools.CursorTool CursorTool
{
get
{
if (m_CursorTool == null)
{
m_CursorTool = new Steema.TeeChart.Tools.CursorTool();
tChart1.Tools.Add(m_CursorTool);
m_CursorTool.FollowMouse = true;
m_CursorTool.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
m_CursorTool.ScopeStyle = Steema.TeeChart.Tools.ScopeCursorStyle.Empty;
}
return m_CursorTool;
}
}
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
return;
}
if (tChart1.Series.Count == 0)
return;
Axes axes = tChart1.Axes;
if (e.X < axes.Left.Position
|| e.X > axes.Bottom.IEndPos //.Right.Position
|| e.Y < axes.Top.Position
|| e.Y > axes.Bottom.Position)
{
toolTip1.Active = false;
return;
}
toolTip1.Active = true;
StringBuilder toolTipString = new StringBuilder();
bool origSnap = CursorTool.Snap;
CursorTool.Snap = true;
Series series = tChart1.Series[0];
//fastcursor seems to be buggy, does not support 'snap'
//CursorTool.FastCursor = false;
series = tChart1.Series[0];
CursorTool.Series = series;
int dataIndex = CursorTool.SnapToPoint();
if (dataIndex < 0)
return;
toolTipString.Append("Value below cursor on " + DateTime.FromOADate(series[dataIndex].X));
toolTipString.Append(Environment.NewLine);
toolTipString.Append(series[dataIndex].Y);
CursorTool.Snap = origSnap;
toolTip1.SetToolTip(this.tChart1, toolTipString.ToString());
}
}
}