So i basically have a Stack Panel, And i’m using a foreach loop to iterate through the children, and all of the children are ‘path’ formats, but some are lines and some are ellipses (or were atleast, before converted to path)
My question is, how can i tell which ones are lines, and which ones are ellipses? , i’m using the isMouseOver event to check if the mouse is over Ellipses to make them change accordingly on MouseDown
private void GraphPanel_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
foreach (var x in GraphPanel.Children)
{
if (((Path)x).IsMouseOver)
{
var converter = new System.Windows.Media.BrushConverter();
var brush = (Brush)converter.ConvertFromString("#FFB1D100");
((Path)x).Stroke = brush;
((Path)x).StrokeThickness = 8;
}
else
{
((Path)x).Stroke = Brushes.Black;
((Path)x).StrokeThickness = 4;
}
}
}
}
You can check the type of the Path.Data property, which is a class derived from Geometry.
Besides some complex Geometry types, the basic derived Geometry types are EllipseGeometry, LineGeometry and RectangleGeometry.