private GazeTargetItem GetHitTarget(Point gazePoint) { GazeTargetItem invokable = null; if (!IsAlwaysActivated) { invokable = NonInvokeGazeTargetItem; } switch (Window.Current.CoreWindow.ActivationMode) { case CoreWindowActivationMode.ActivatedInForeground: case CoreWindowActivationMode.ActivatedNotForeground: var elements = VisualTreeHelper.FindElementsInHostCoordinates(gazePoint, null, false); var element = elements.FirstOrDefault(); invokable = null; if (element != null) { invokable = GazeTargetItem.GetOrCreate(element); while (element != null && !invokable.IsInvokable) { element = VisualTreeHelper.GetParent(element) as UIElement; if (element != null) { invokable = GazeTargetItem.GetOrCreate(element); } } } if (element == null || !invokable.IsInvokable) { invokable = NonInvokeGazeTargetItem; } else { Interaction interaction; do { interaction = GazeInput.GetInteraction(element); if (interaction == Interaction.Inherited) { element = GetInheritenceParent(element); } }while (interaction == Interaction.Inherited && element != null); if (interaction == Interaction.Inherited) { interaction = GazeInput.Interaction; } if (interaction != Interaction.Enabled) { invokable = NonInvokeGazeTargetItem; } } break; } return(invokable); }
/// <summary> /// Invoke the default action of the specified UIElement. /// </summary> public static void Invoke(UIElement element) { var item = GazeTargetItem.GetOrCreate(element); item.Invoke(); }