EDN Admin
Well-known member
<p style="margin:0in; font-family:Verdana; font-size:11pt I would like to draw a full-screen crosshairs cursor on a chart that has a lot of information. I have tried some solutions that have been suggested in another thread but they are a bit slow. The crosshairs
follows the cursor with a time lag. Any help would be appreciated?
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt Thank you.
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt Here is the basic drawing code. Im using ZedGraphControl to draw the chart.
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt public partial class Form1 : Form
<p style="margin:0in; font-family:Verdana; font-size:11pt {
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
public static ZedGraphControl zedGraphControl1 = new ZedGraphControl();
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
int mouseX = 0;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
int mouseY = 0;
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
private bool ZedGraph_MouseMove(ZedGraphControl sender, MouseEventArgs e)
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
{
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
sender.Refresh();
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
Pen blackPen = new Pen(Color.Black, 1);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
Graphics g = sender.CreateGraphics();
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
// Get the coordinates that define crosshairs.
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formLeft = this.Left;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formTop = this.Top ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formRight = this.Right ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formBottom = this.Bottom ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
mouseX = e.X ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
mouseY = e.Y ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
// Draw line on screen.
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen,0,mouseY,mouseX,mouseY );
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen, mouseX, 0, mouseX,mouseY);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen, formRight, mouseY, mouseX, mouseY);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen, mouseX, formBottom,mouseX, mouseY);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
<p style="margin:0in 0in 0in 0.375in; font-family:Verdana; font-size:11pt // A bool return value is required by ZedGraphControl.ZedMouseEventHandler.
<p style="margin:0in 0in 0in 0.375in; font-family:Verdana; font-size:11pt return false;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
}
<p style="margin:0in; font-family:Verdana; font-size:11pt }
View the full article
follows the cursor with a time lag. Any help would be appreciated?
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt Thank you.
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt Here is the basic drawing code. Im using ZedGraphControl to draw the chart.
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt public partial class Form1 : Form
<p style="margin:0in; font-family:Verdana; font-size:11pt {
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
public static ZedGraphControl zedGraphControl1 = new ZedGraphControl();
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
int mouseX = 0;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
int mouseY = 0;
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
private bool ZedGraph_MouseMove(ZedGraphControl sender, MouseEventArgs e)
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
{
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
sender.Refresh();
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
Pen blackPen = new Pen(Color.Black, 1);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
Graphics g = sender.CreateGraphics();
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
// Get the coordinates that define crosshairs.
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formLeft = this.Left;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formTop = this.Top ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formRight = this.Right ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
float formBottom = this.Bottom ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
mouseX = e.X ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
mouseY = e.Y ;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
// Draw line on screen.
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen,0,mouseY,mouseX,mouseY );
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen, mouseX, 0, mouseX,mouseY);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen, formRight, mouseY, mouseX, mouseY);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
g.DrawLine(blackPen, mouseX, formBottom,mouseX, mouseY);
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
<p style="margin:0in 0in 0in 0.375in; font-family:Verdana; font-size:11pt // A bool return value is required by ZedGraphControl.ZedMouseEventHandler.
<p style="margin:0in 0in 0in 0.375in; font-family:Verdana; font-size:11pt return false;
<p style="margin:0in; font-family:Verdana; font-size:11pt <span style="
}
<p style="margin:0in; font-family:Verdana; font-size:11pt }
View the full article