public bool EllipseContains(Ellipse ellipse, System.Windows.Point location) { var pos = ellipse.TransformToAncestor(CanvasInfo).Transform(new System.Windows.Point(0, 0)); var center = new System.Windows.Point(pos.X + ellipse.Width / 2, pos.Y + ellipse.Height / 2); var radiusX = ellipse.Width / 2; var radiusY = ellipse.Height / 2; if (radiusX <= 0.0 || radiusY <= 0.0) return false; var normalized = new System.Windows.Point(location.X - center.X, location.Y - center.Y); return ((normalized.X * normalized.X) / (radiusX * radiusX)) + ((normalized.Y * normalized.Y) / (radiusY * radiusY)) <= 1.0; }
private void AddMinionDebugOverlay(CardEntity entity, Ellipse entityEllipse) { entityEllipse.Stroke = new SolidColorBrush(Colors.Red); entityEllipse.StrokeThickness = 1; var lbl = new Label {Content = entity.Entity.Card.Name, Foreground = Brushes.White}; _debugBoardObjects.Add(lbl); CanvasInfo.Children.Add(lbl); var pos = entityEllipse.TransformToAncestor(CanvasInfo).Transform(new System.Windows.Point(0, 0)); Canvas.SetTop(lbl, pos.Y + 10); Canvas.SetLeft(lbl, pos.X + 10); }