关于图像的点击事件 [英] regarding click event of image
本文介绍了关于图像的点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
c正在拍摄图片...
现在我想以这样一种方式进行管理,以便在单击图像后应该在单击部分上显示十字...
这有什么解决办法?
plz建议
Adbvance中的TnX
c am having an image ...
now i want to manage in such a way so that after clicking on image it should show cross on the click part...
is thr any solution for that???
plz advice
TnX in Adbvance
推荐答案
假定您使用的是图片框(您不一定要这样做,但它会使此示例更容易),您需要处理两个事件:Picturebox.MouseClick和PictureBox.Paint.提供一个课程级别的Point,以便您知道中心在哪里以及:
Assuming you are using a picture box (you don''t have to and probably shouldn''t, but it makes this example easier) you need to handle two events: Picturebox.MouseClick, and PictureBox.Paint. Provide a class level Point so you know where the center is and:
private Point crossCentre;
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
crossCentre = e.Location;
pictureBox1.Invalidate();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
if (crossCentre != null)
{
int x = crossCentre.X;
int y = crossCentre.Y;
g.DrawLine(Pens.AntiqueWhite, x, y - 10, x, y + 10);
g.DrawLine(Pens.AntiqueWhite, x - 10, y, x + 10, y);
}
}
这篇关于关于图像的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文