예제 #1
0
        public void Return(GazeFeedbackControl control)
        {
            var popup = (Popup)control.Parent;

            popup.IsOpen = false;
            _cache.Add(popup);
        }
예제 #2
0
        public GazeFeedbackControl Get(FrameworkElement element, double left, double top, double width, double height)
        {
            Popup popup;
            GazeFeedbackControl control;

            if (_cache.Count != 0)
            {
                popup = _cache[0];
                _cache.RemoveAt(0);
                control = (GazeFeedbackControl)popup.Child;
            }
            else
            {
                control = new GazeFeedbackControl();

                popup = new Popup
                {
#if WINDOWS_UWP
#else
                    AllowsTransparency = true,
                    Placement          = PlacementMode.Absolute,
#endif
                    Child = control
                };
            }

#if WINDOWS_UWP
            var transform = element.TransformToVisual(popup);
            var bounds    = transform.TransformBounds(new Rect(
                                                          new Point(left, top),
                                                          new Size(width, height)));
#else
            var controlLeftTop     = element.PointToScreen(new Point(left, top));
            var controlRightBottom = element.PointToScreen(new Point(left + width, top + height));
            controlLeftTop     = new Point(controlLeftTop.X * _scalingX, controlLeftTop.Y * _scalingY);
            controlRightBottom = new Point(controlRightBottom.X * _scalingX, controlRightBottom.Y * _scalingY);
            var bounds = new Rect(controlLeftTop, controlRightBottom);
#endif

            popup.HorizontalOffset = bounds.Left;
            popup.VerticalOffset   = bounds.Top;
            control.Width          = bounds.Width;
            control.Height         = bounds.Height;

            control.SetState(DwellProgressState.Fixating, 0.0);
            popup.IsOpen = true;

            return(control);
        }
예제 #3
0
        protected override void ShowFeedback(DwellProgressState state, double progress)
        {
            if (state != DwellProgressState.Idle)
            {
                if (_feedbackPopup == null)
                {
                    _feedbackPopup = GetFeedbackControl();
                }

                _feedbackPopup.SetState(state, progress);
            }
            else
            {
                if (_feedbackPopup != null)
                {
                    GazeInput.GazeFeedbackPopupFactory.Return(_feedbackPopup);
                    _feedbackPopup = null;
                }
            }
        }