Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would use <code>FrameworkElement</code> (which extends <code>UIElement</code>) instead of <code>UIElement</code>, in order to use <code>ActualWidth</code> and <code>ActualHeight</code> properties</p> <p>Then create a static class which does some math <code>MouseUtils</code></p> <p>with those static fields</p> <pre><code> private static double _dContainerTop; private static double _dContainerBottom; private static double _dContainerLeft; private static double _dContainerRight; private static double _dCursorTop; private static double _dCursorLeft; private static double _dCursorRight; private static double _dCursorBottom; </code></pre> <p>and those static methods</p> <pre><code> private static void FindValues(FrameworkElement element, Visual rootVisual) { var containerTopLeft = container.TransformToAncestor(rootVisual).Transform(new Point(0, 0)); _dContainerTop = containerTopLeft.Y; _dContainerBottom = _dContainerTop + container.ActualHeight; _dContainerLeft = containerTopLeft.X; _dContainerRight = _dContainerLeft + container.ActualWidth; } </code></pre> <p>and</p> <pre><code> public static bool IsElementUnderRectCursor(FrameworkElement element, Point startPoint, Point endPoint, Visual rootVisual) { _dCursorTop=Math.Min(startPoint.Y, endPoint.Y); _dCursorBottom=Math.Max(startPoint.Y, endPoint.Y); _dCursorLeft=Math.Min(startPoint.X, endPoint.X); _dCursorRight=Math.Max(startPoint.X, endPoint.X); FindValues(container, rootVisual); if (_dContainerTop &lt; _dCursorTop|| _dCursorBottom&lt; _dContainerBottom ) { return false; } if (_dContainerLeft &lt; _dCursorLeft|| _dContainerRight &lt; _dCursorRight) { return false; } return true; } </code></pre> <p><code>Rootvisual</code> being your window for example;</p> <p>Then loop over <code>ObservableCollection&lt;FrameworkElement&gt; wells</code> and call that function <code>IsElementUnderRectCursor</code>.</p> <p>This is inspired from: <a href="http://geekswithblogs.net/mbcrump/archive/2011/07/04/kinecting-the-dots-adding-buttons-to-your-kinect-application.aspx" rel="nofollow">Kinecting the Dots</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload