0

I have a grid with a bunch of 'Path's on it called 'GraphPanel' and i'm trying to figure out which one the mouse is over when you click on the grid and then change it's 'fill' to GreenYellow, I'm using a static variable '_HitBox' the value is 2 (not that it matters)

System.Windows.Point P = e.GetPosition(GraphPanel);

 var PointsToColor = from children in GraphPanel.Children.OfType<Path>()
                               where children.Data is EllipseGeometry &&
                               P.X > (((EllipseGeometry)children.Data).Center.X - _HitBoxSize) && 
                               P.X < (((EllipseGeometry)children.Data).Center.X + _HitBoxSize) && 
                               P.Y > (((EllipseGeometry)children.Data).Center.Y - _HitBoxSize) && 
                               P.Y < (((EllipseGeometry)children.Data).Center.Y + _HitBoxSize)
                               select children;




           foreach (var p in PointsToColor)
           {
               p.Fill = Brushes.GreenYellow;
               break;
           }

Please Note:

1- It hits the p.Fill = Brushes.GreenYellow while debugging, but the point it hits for doesn't change color.

2- I was originally using IsMouseOver() which is a method built into each member of a grid, it was incredibly slow and (since there is other items on the grid overtop of the points like labels and stuff) if something was over top of the point clicked it wouldn't return true

3- I have also tried this (Thinking that a select statement doesn't return a reference) :

Path test = ((Path)GraphPanel.Children[GraphPanel.Children.IndexOf(p)]);
test.Fill = Brushes.GreenYellow;
GraphPanel.Children[GraphPanel.Children.IndexOf(p)] = test;

Which ran successfully, but again the color of the point's fill didn't change.

Also i've tried adding GraphPanel.UpdateLayout() After the change which didn't do anything either

4

1 回答 1

0

After eternity of research and determination and scouring the internet for any clues or ideas of what the actual f$!% is wrong with my code

.Fill is just a trick made by angry Microsoft developers who hate their life and want others to suffer an eternity of anguish

.Stroke is how you edit the fill.....

于 2012-10-15T16:32:15.847 回答