如何在 C# 中创建热点? [英] How to create HotSpot in C#?
本文介绍了如何在 C# 中创建热点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 winform 应用程序中创建一个图像热点.我遵循了HERE发布的解决方案,但我不知道应该把坐标使此方法起作用:
I want to create a hotspot on image in my winform application. I followed the solution posted HERE, but I don't know where I should put the coordinates to make this method work:
protected override void OnMouseMove(MouseEventArgs mouseEvent)
{
string X = mouseEvent.X.ToString();
string Y = mouseEvent.Y.ToString();
}
我应该把坐标放在哪里?我有两个坐标 (X,Y): 110, 45
Where should I put the coordinates? I have two coordinates (X,Y): 110, 45
推荐答案
如果您想响应鼠标悬停在 矩形 在图像中:
If you want to respond to the mouse being over a rectangle within the image:
private Rectangle _hotspot = new Rectangle(20, 30, 10, 10);
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (_hotspot.Contains(e.Location))
{
// respond to the mouse being in the hotspot
}
}
}
这篇关于如何在 C# 中创建热点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文