473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

rectangle contains

Hi.

I have a program that creates an image and displays it to the
screen....pretty simple. I put it into a matrix so that I can rotate it. I
would also like to be able to know when I click on it so I am doing a
rectangle.contains. This works fine if the image isn't rotated. But if it
is, how can I get the rectangle.contains to rotate also? Thanks.

Dim im As Bitmap
im = bar.BuildMyImage
Dim mx As New Matrix
mx.Translate(StartPos.X, StartPos.Y)
mx.Rotate(Rotation)
G.Transform = mx
G.DrawImage(im, 0, 0, im.Width ,im.Height)
G.ResetTransform()

In my mouse onclick event:

Return New Rectangle(New Point(X1, Y1), New Size(im.width,
im.height)).Contains(p)

Nov 21 '05 #1
1 2092
Check out my article on backtracking the mouse in Windows Forms Tips and
Tricks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Rob T" <RT*********@DONTwalchemSPAM.com> wrote in message
news:ua**************@tk2msftngp13.phx.gbl...
Hi.

I have a program that creates an image and displays it to the
screen....pretty simple. I put it into a matrix so that I can rotate it.
I would also like to be able to know when I click on it so I am doing a
rectangle.contains. This works fine if the image isn't rotated. But if
it is, how can I get the rectangle.contains to rotate also? Thanks.

Dim im As Bitmap
im = bar.BuildMyImage
Dim mx As New Matrix
mx.Translate(StartPos.X, StartPos.Y)
mx.Rotate(Rotation)
G.Transform = mx
G.DrawImage(im, 0, 0, im.Width ,im.Height)
G.ResetTransform()

In my mouse onclick event:

Return New Rectangle(New Point(X1, Y1), New Size(im.width,
im.height)).Contains(p)

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
3
by: Ryan | last post by:
Hello, I'm trying to draw a rectangle on a web page which contains a picture. Following is the function for a similar windows application. private void ZoomIn_Click(object sender,...
3
by: | last post by:
I am having a hard time understanding the logic behind the Rectangle object. My problem has to do with the way the rectangle treats the "Width" property. For example, take the following rectangle...
1
by: Praveen | last post by:
Hello, I have a web page which will display the map of a city/place. I have a toolbar which contains 'zoom in' and 'zoom out' buttons. When the user clicks on zoom in/zoom out button, he should...
1
by: PJ6 | last post by:
I've Googled this but come up short... I have a non-rectangular region that contains a moveable rectangle. I want to restrict the rectangle's movement to have it always fully contained in this...
1
by: =?Utf-8?B?TUFC?= | last post by:
i m developing a wayfinding solution, i need to check if A rectangle bounds are touching B rectangle bounds. Arectangle.Contains(B rectangle) only checks if Brectangle is completely in the...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
2
by: John | last post by:
Hi there, I need to create a rectangle between two points so that I can check what is inside it using Contains(). The problem I am having is how to make the rectangle be able to cope with the...
1
by: kummu4help | last post by:
hi, i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.