Пример #1
0
        // functions for supporting target selection
        private void PrepareLocalTargets()
        {
            // set local region center as current average gaze position
            PointF center = this.fixationDetector.AveragedGazePosition;

            // collect local targets within in region, ordered by Y coordinates
            var selectedTargets = targets
                                  .Where(t => center.DistanceFrom(t.Position) < settings.LocalSelectionRegionRadius)
                                  .OrderBy(t => t.Position.Y);

            // find the closest target and its index
            var(minTarget, minIndex, _) = selectedTargets
                                          .Select((t, i) => (t, i, d: center.DistanceFrom(t.Position)))
                                          .Aggregate((min, next) => min.d < next.d ? min : next);

            this.localSelectionRegionCenter = center;
            this.localTargets        = selectedTargets.ToList();
            this.localSelectionIndex = minIndex;
            this.currentTarget       = minTarget;
            this.mouseDisplacement   = new Point(0, 0);
        }