命中测试示例 [英] Hit Test example

查看:64
本文介绍了命中测试示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在大约5分钟内写过这篇文章,有人可以看看它并且leme

知道这是做这样事情的好方法吗?控件上的每个项目

是一个对象,它有自己的渲染方法..这里是我项目的链接

源代码。
http://www.cyber-arts.com/download/hittestexample .zip


如果你有时间请给我一些建议。

谢谢:)这是第一次我试图这样做..我很惊讶我的想法

工作原样:)

I just wrote this in about 5 minutes, can someone have a look at it and leme
know it this is a good way to do things like this? each item on the control
is a object which has its own render method.. here''s a link to my project
source code.

http://www.cyber-arts.com/download/hittestexample.zip

please have a look at it if you have time and give me some suggestions.
thanks :) this is the first time i tried to do this.. im suprised my idea
worked as it is :)

推荐答案

对不起,我不知道我的日期是如何搞砸了......只是注意到了正确

现在

" Brian Henry" <峰; br ********** @ newsgroups.nospam>在消息中写道

news:ut ************** @ tk2msftngp13.phx.gbl ...
ugh sorry, i dont know how my date got messed up.. just noticed that right
now
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
我刚写了这个大约5分钟,有人可以看看它和
leme知道这是做这样的事情的好方法吗?
控件上的每个项目都是一个对象,它有自己的渲染方法..这里是我项目的链接
源代码。

http://www.cyber-arts.com/download/hittestexample.zip 谢谢:)这是我第一次尝试这样做..我很惊讶我的想法
工作因为它是:
I just wrote this in about 5 minutes, can someone have a look at it and leme know it this is a good way to do things like this? each item on the control is a object which has its own render method.. here''s a link to my project
source code.

http://www.cyber-arts.com/download/hittestexample.zip

please have a look at it if you have time and give me some suggestions.
thanks :) this is the first time i tried to do this.. im suprised my idea
worked as it is :)



嗨Brian,


我觉得设计还行。我们使用ArrayList存储

对象(提供每个条形或其他图形定义为对象)和

实现自己的绘图算法(例如不同形状的方法)

将使用不同的绘图方法)。在OnPaint事件处理程序中,我们将

调用arraylist中每个对象的draw方法。


至于控件的click事件,我认为我们可以使用

Cursor.Position获取鼠标的当前位置并循环播放arraylist

以了解鼠标点击的位置。

eg

Private Sub bartest_Click(ByVal sender As Object,ByVal e As

System.EventArgs)处理MyBase.Click

Dim pt As Point = PointToClient(Cursor.Position)

Debug.WriteLine(pt.X.ToString()&","& pt.Y.ToString())

Dim bi As BarItem

For each bi in barItemList

如果bi.rectangle.Contains(pt)那么

MsgBox(bi.orderNumb。 ToString()&"点击)

退出

结束如果

下一页

End Sub


祝你好运,


Peter Huang

微软在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有授予任何权利。

Hi Brian,

I think the design is just OK. We use an ArrayList to store the
objects(Provided every bar or other drawing is defined as an object) and
implement their own drawing algorithm(e.g. the method of different shape
will use different drawing method). In the OnPaint event handler we will
call the draw method of every objects in the arraylist.

As for the click event of the control I think we can use the
Cursor.Position to get the mouse''s current position and loop the arraylist
to know where is the mouse click on.
e.g.
Private Sub bartest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click
Dim pt As Point = PointToClient(Cursor.Position)
Debug.WriteLine(pt.X.ToString() & "," & pt.Y.ToString())
Dim bi As BarItem
For Each bi In barItemList
If bi.rectangle.Contains(pt) Then
MsgBox(bi.orderNumb.ToString() & " is clicked")
Exit For
End If
Next
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


感谢您为我查看:)

"" Peter黄"" <,V - ****** @ online.microsoft.com>在消息中写道

新闻:3T ************* @ cpmsftngxa10.phx.gbl ...
thanks for looking at it for me :)
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:3T*************@cpmsftngxa10.phx.gbl...
嗨Brian,
我觉得设计还行。我们使用ArrayList存储
对象(提供每个条形或其他图形定义为对象)并实现自己的绘图算法(例如不同形状的方法将使用不同的绘图方法)。在OnPaint事件处理程序中,我们将调用arraylist中每个对象的draw方法。

至于控件的click事件,我认为我们可以使用
Cursor。获取鼠标当前位置的位置并循环播放arraylist
以了解鼠标点击的位置。
例如私人Sub bartest_Click(ByVal发送者作为对象,ByVal e As
System.EventArgs)处理MyBase.Click
Dim pt As Point = PointToClient(Cursor.Position)
Debug.WriteLine(pt.X.ToString()&","& pt .Y.ToString())
Dim bi As BarItem
For Each bi in barItemList
如果bi.rectangle.Contains(pt)那么
MsgBox(bi.orderNumb.ToString( )&点击)
退出
结束如果
下一页
结束子

致以最好的问候,
Peter Huang
Microsoft在线合作伙伴支持

获得安全! - www.microsoft.com/security
此帖子提供按原样没有保证,也没有
权利。
Hi Brian,

I think the design is just OK. We use an ArrayList to store the
objects(Provided every bar or other drawing is defined as an object) and
implement their own drawing algorithm(e.g. the method of different shape
will use different drawing method). In the OnPaint event handler we will
call the draw method of every objects in the arraylist.

As for the click event of the control I think we can use the
Cursor.Position to get the mouse''s current position and loop the arraylist
to know where is the mouse click on.
e.g.
Private Sub bartest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Click
Dim pt As Point = PointToClient(Cursor.Position)
Debug.WriteLine(pt.X.ToString() & "," & pt.Y.ToString())
Dim bi As BarItem
For Each bi In barItemList
If bi.rectangle.Contains(pt) Then
MsgBox(bi.orderNumb.ToString() & " is clicked")
Exit For
End If
Next
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.



这篇关于命中测试示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆