A drawn line during mouse move disappears...
Posted: Tue Aug 14, 2007 3:18 pm
Hi,
I use the last version of tee chart (V 32.2763.26082 from july 27).
I have a simple code to draw a line joining one starting point and the point under the mouse when the mouse is moving on my chart.
The line is correctly drawn while the mouse is moving, but it disappears when the mouse stops moving, as if a refresh hidding it occured.
Could you tell me please, how to keep my drawn line when the mouse stop moving.
I join my code.
Thanks,
Anne-Lise
private bool mIsfirstlMouseUp = true;
private Point StartPos;
private Point StopPos;
private FastLine serie;
public Form1()
{
InitializeComponent();
serie = new FastLine();
serie.Add(1, 1);
serie.Add(2, 1);
serie.Add(3, 4);
serie.Add(4, 5);
serie.Add(5, 4);
serie.Add(6, 5);
serie.Add(7, ;
tChart1.AddSeries(serie);
}
private void tChart1_MouseUp(object sender, MouseEventArgs e)
{
if(mIsfirstlMouseUp)
{
mIsfirstlMouseUp = false;
StartPos.X = e.X;
StartPos.Y = e.Y;
}
else
{
mIsfirstlMouseUp = true;
StopPos.X = e.X;
StopPos.Y = e.Y;
MyDrawLine(StopPos,StopPos);
}
}
private void MyDrawLine(Point p1, Point p2)
{
Graphics3D g = tChart1.Graphics3D;
g.MoveTo(p1);
g.LineTo(p2,0);
}
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
serie.BeginUpdate();
serie.EndUpdate();
Point stopPoint = new Point(Convert.ToInt32(e.X), Convert.ToInt32(e.Y));
MyDrawLine(StartPos,stopPoint);
}
I use the last version of tee chart (V 32.2763.26082 from july 27).
I have a simple code to draw a line joining one starting point and the point under the mouse when the mouse is moving on my chart.
The line is correctly drawn while the mouse is moving, but it disappears when the mouse stops moving, as if a refresh hidding it occured.
Could you tell me please, how to keep my drawn line when the mouse stop moving.
I join my code.
Thanks,
Anne-Lise
private bool mIsfirstlMouseUp = true;
private Point StartPos;
private Point StopPos;
private FastLine serie;
public Form1()
{
InitializeComponent();
serie = new FastLine();
serie.Add(1, 1);
serie.Add(2, 1);
serie.Add(3, 4);
serie.Add(4, 5);
serie.Add(5, 4);
serie.Add(6, 5);
serie.Add(7, ;
tChart1.AddSeries(serie);
}
private void tChart1_MouseUp(object sender, MouseEventArgs e)
{
if(mIsfirstlMouseUp)
{
mIsfirstlMouseUp = false;
StartPos.X = e.X;
StartPos.Y = e.Y;
}
else
{
mIsfirstlMouseUp = true;
StopPos.X = e.X;
StopPos.Y = e.Y;
MyDrawLine(StopPos,StopPos);
}
}
private void MyDrawLine(Point p1, Point p2)
{
Graphics3D g = tChart1.Graphics3D;
g.MoveTo(p1);
g.LineTo(p2,0);
}
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
serie.BeginUpdate();
serie.EndUpdate();
Point stopPoint = new Point(Convert.ToInt32(e.X), Convert.ToInt32(e.Y));
MyDrawLine(StartPos,stopPoint);
}