thanks dude.. you're a big help..
Main Topics
Browse All Topicsim working on a test application where on form load, a rotated rectangle will be drawn on panel control.. now, i want to add an event to that rectangle, a mouse hover event.. i want to change the color of the rectangle whenever the mouse moves over it.. and i also want to add a click event to that rectangle.. thanks..
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: Erick37Posted on 2005-09-24 at 20:22:19ID: 14952777
Try this...
rushes.Red , rc); ens.Black, rc); ens.Black, rc);
using System.Drawing;
using System.Drawing.Drawing2D;
// ...
// define the rectangle
private Rectangle rc = new Rectangle(20, 20, 40, 40);
// calculate center of rectangle
private int cx = 40; // rc.Left + (rc.Width / 2)
private int cy = 40; // rc.Top + (rc.Height / 2)
// our matrix
Matrix m = new Matrix();
// is the mouse in the rectangle?
private bool inRect;
private void panel1_Paint(object sender, PaintEventArgs e) // Panel paint event
{
// transform matrix
e.Graphics.Transform = m;
// draw either a filled or empty rectangle
if (inRect)
{
e.Graphics.FillRectangle(B
e.Graphics.DrawRectangle(P
}
else
{
e.Graphics.DrawRectangle(P
}
}
private void panel1_MouseMove(object sender, MouseEventArgs e) // panel mousemove event
{
bool bTest;
// make a point array out of the current mouse position
Point[] pt = {new Point(e.X, e.Y)};
// copy and invert matrix
Matrix mi;
mi = m.Clone();
mi.Invert();
// rotate adjust the mouse coords
mi.TransformPoints(pt);
// test to see if the rotated coords are in the rotated rect
bTest = rc.Contains(pt[0].X, pt[0].Y);
// Console.WriteLine("inRect = " + bTest.ToString());
if (inRect != bTest)
{
// something changed
panel1.Invalidate();
}
// save the result
inRect = rc.Contains(pt[0].X, pt[0].Y);
}
private void Form1_Load(object sender, EventArgs e) // form load event
{
// define the rotation at 35 degrees at the center of the rectangle
m.RotateAt(35, new Point(cx, cy));
}