internal void Reset(TimeSpan nextStateTime) { ElementState = PointerState.PreEnter; DetailedTime = TimeSpan.Zero; OverflowTime = TimeSpan.Zero; NextStateTime = nextStateTime; RepeatCount = 0; MaxDwellRepeatCount = GazeInput.GetMaxDwellRepeatCount(TargetElement); }
/* * private const string[] pointerStates = * { * "Exit", * "PreEnter", * "Enter", * "Fixation", * "Dwel", * "DwellRepeat" * }; */ private void RaiseGazePointerEvent(GazeTargetItem target, PointerState state, TimeSpan elapsedTime) { var control = target?.TargetElement; // assert(target != _rootElement); var gpea = new StateChangedEventArgs(control, state, elapsedTime); /* * if (control is Button buttonObj && buttonObj.Content != null) * { * var buttonText = buttonObj.Content as string; * Debug.WriteLine("GPE: {0} . {1}, {2}", buttonText, PointerStates[(int)state], elapsedTime); * } * else * { * Debug.WriteLine("GPE: 0x%08x . %s, %d", target != null ? target.GetHashCode() : 0, PointerStates[(int)state], elapsedTime); * } */ var gazeElement = target != null?GazeInput.GetGazeElement(control) : null; if (gazeElement != null) { gazeElement.RaiseStateChanged(control, gpea); } if (state == PointerState.Dwell) { var handled = false; if (gazeElement != null) { var args = new DwellInvokedRoutedEventArgs(); gazeElement.RaiseInvoked(control, args); handled = args.Handled; } if (!handled) { target.Invoke(); } } }
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); }
public override int GetMaxDwellRepeatCount() => GazeInput.GetMaxDwellRepeatCount(_element);
private void RaiseProgressEvent(DwellProgressState state) { // TODO: We should eliminate non-invokable controls before we arrive here! if (TargetElement is Page) { return; } if (_notifiedProgressState != state || state == DwellProgressState.Progressing) { var handled = false; var gazeElement = GazeInput.GetGazeElement(TargetElement); if (gazeElement != null) { handled = gazeElement.RaiseProgressFeedback(TargetElement, state, ElapsedTime - _prevStateTime, _nextStateTime - _prevStateTime); } if (!handled && state != DwellProgressState.Idle) { if (_feedbackPopup == null) { _feedbackPopup = GazePointer.Instance.GazeFeedbackPopupFactory.Get(); } var control = TargetElement as FrameworkElement; var transform = control.TransformToVisual(_feedbackPopup); var bounds = transform.TransformBounds(new Rect( new Point(0, 0), new Size((float)control.ActualWidth, (float)control.ActualHeight))); var rectangle = (Windows.UI.Xaml.Shapes.Rectangle)_feedbackPopup.Child; if (state == DwellProgressState.Progressing) { var progress = ((double)(ElapsedTime - _prevStateTime).Ticks) / (_nextStateTime - _prevStateTime).Ticks; if (progress >= 0 && progress < 1) { rectangle.Stroke = GazeInput.DwellFeedbackProgressBrush; rectangle.Width = (1 - progress) * bounds.Width; rectangle.Height = (1 - progress) * bounds.Height; _feedbackPopup.HorizontalOffset = bounds.Left + (progress * bounds.Width / 2); _feedbackPopup.VerticalOffset = bounds.Top + (progress * bounds.Height / 2); } } else { rectangle.Stroke = state == DwellProgressState.Fixating ? GazeInput.DwellFeedbackEnterBrush : GazeInput.DwellFeedbackCompleteBrush; rectangle.Width = bounds.Width; rectangle.Height = bounds.Height; _feedbackPopup.HorizontalOffset = bounds.Left; _feedbackPopup.VerticalOffset = bounds.Top; } _feedbackPopup.IsOpen = true; } else { if (_feedbackPopup != null) { GazePointer.Instance.GazeFeedbackPopupFactory.Return(_feedbackPopup); _feedbackPopup = null; } } } _notifiedProgressState = state; }