// -----------------------------------------------------------------------
//
// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Input
{
using System;
using System.Collections.Generic;
using System.Linq;
public static class InputExtensions
{
public static IEnumerable GetInputElementsAt(this IInputElement element, Point p)
{
Contract.Requires(element != null);
if (element.Bounds.Contains(p) &&
element.IsVisible &&
element.IsHitTestVisible &&
element.IsEnabledCore)
{
p -= element.Bounds.Position;
if (element.VisualChildren.Any())
{
foreach (var child in element.VisualChildren.OfType())
{
foreach (var result in child.GetInputElementsAt(p))
{
yield return result;
}
}
}
yield return element;
}
}
}
}