crosshair tool, is there one? Visual studio 2008
I am doing some image sampling. What my question is, is there a 'crosshair' tool in visual studio? I want to have several instances on a single form, be able to move them around and then sample those points, obviously returning the color of the pixel at the center of the crosshair, is 开发者_运维问答there already a tool that will do this, before I go and write one?
Thanks, R.
I know of no crosshair, but the following procedure can be used twice to draw a crosshair. To remove it, simply draw it again as it uses XOR to make the procedure reversible.
ControlPaint.DrawReversibleLine().
You could just change the cursor:
private void btnSample_Click(object sender, EventArgs e) {
this.Cursor = Cursors.Cross;
}
protected override void OnMouseDown(MouseEventArgs e) {
if (this.Cursor == Cursors.Cross) {
this.Cursor = Cursors.Default;
// etc...
}
}
I would change the cursor to Cursor.cross. Then just paint indicators at the mousedown-points with GDI on the PictureBox's Graphic, sample the colors from those locations and then clear the PictureBox's Graphic when the operation is done.
精彩评论