Mouse Hit Test and NPaintCallback


Author
Message
Raul Kist
Raul Kist
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
Hi!

Does anyone knows how can I get a Hit Test result different from Axis when clicking over a NPaintCallback drawn polygon?

Or how can I identify this polygon without having to calculate if the mouse is inside or outside?

Thanks a lot =]
Raul Kist
Reply
Raul Kist
Raul Kist
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1
The problem is that if I draw something using a "public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)" from NPaintCallback the HitTest always returns a Axis as result.

This way I can't know what am I clicking on.

I already solved this using this code to calculate if the point is In or Out the polygon:

private static bool pointInPolygon(PointF point, List polygon)
{
int polySides = polygon.Count;
float x = point.X;
float y = point.Y;
int i, j = polySides - 1;
bool oddNodes = false;

for (i = 0; i < polySides; i++)
{
if ((polygon[i].Y < y && polygon[j].Y >= y || polygon[j].Y < y && polygon[i].Y >= y) && (polygon[i].X <= x || polygon[j].X <= x))
{
if (polygon[i].X + (y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) * (polygon[j].X - polygon[i].X) < x)
{
oddNodes = !oddNodes;
}
}
j = i;
}

return oddNodes;
}

The problem I'm having now is how to make the chart data appear over the OnAfterPaint drawn polygon...
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search