![]() |
|
|
| Subject:
How to detect whether cursor is over a Rotated/Translated Rectangle in .NET
Category: Computers > Programming Asked by: brother_bill-ga List Price: $25.00 |
Posted:
16 Mar 2005 16:10 PST
Expires: 20 Mar 2005 12:50 PST Question ID: 495844 |
|
| There is no answer at this time. |
|
| Subject:
Re: How to detect whether cursor is over a Rotated/Translated Rectangle in .NET
From: crythias-ga on 18 Mar 2005 13:14 PST |
If you're using HTML, you could put an <a href="#"> </a> around your image. Further, you could use an image map for a more discreet way. <img src="myrotatedpic.jpg" usemap="mymap"> Of course at that point you can put your OnMouseOver scripts. -- This is a free comment. |
| Subject:
Re: How to detect whether cursor is over a Rotated/Translated Rectangle in .NET
From: marimomo-ga on 19 Mar 2005 00:10 PST |
Try this
Dim myMatrix As New Matrix
Dim myInvMatrix As New Matrix
Dim rect As New Rectangle(120, 50, 140, 50)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim rotatePoint As New PointF(190.0F, 75.0F)
myMatrix.RotateAt(45, rotatePoint)
myInvMatrix.RotateAt(45, rotatePoint)
myInvMatrix.Invert()
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
TransformVectorsExample(e)
End Sub
Public Sub TransformVectorsExample(ByVal e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
Static Dim colorIdx As New Integer
e.Graphics.DrawRectangle(myPen, rect)
e.Graphics.Transform = myMatrix
If colorIdx = 0 Then
colorIdx = 1
e.Graphics.FillRectangle(Brushes.Blue, rect)
Else
colorIdx = 0
e.Graphics.FillRectangle(Brushes.Red, rect)
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim region As New Region
Dim polygon_path As New GraphicsPath(FillMode.Winding)
polygon_path.AddRectangle(rect)
polygon_path.Transform(myMatrix)
Dim polygon_region = New Region(polygon_path)
Dim pt As PointF() = {New PointF(e.X, e.Y)}
myInvMatrix.TransformPoints(pt)
If (rect.Contains(pt(0).X, pt(0).Y)) Then
Label1.Text = "in side"
Invalidate(polygon_region)
Else
Label1.Text = ""
End If
End Sub |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |