private void GetNewPictureFromServer(object sender, EventArgs e) { // if there is no user if (CurrentUserPresenceState != gazeStream.IsUserPresent) { CurrentUserPresenceState = gazeStream.IsUserPresent; UserPresenceChanged?.Invoke(gazeStream, CurrentUserPresenceState); } if (!gazeStream.IsUserPresent) { if (EmptyImage != null) { Image = EmptyImage; } // stop the robot // set current state as paSSIVE LastState = MoveGoalRectangles.Passive; CurrentGoalArea = MoveGoalRectangles.Passive; CurrentGazePoint = new Point(0, 0); return; } try { CurrentGazePoint = PointToClient(gazeStream.GazePoint); CurrentGoalRectangle = GazeRectangle.TestGazePoint(CurrentGazePoint); // change state only if gaze point was moved to new control area if (CurrentGoalRectangle != LastState) { if (CurrentGoalRectangle != MoveGoalRectangles.Passive) { LastState = CurrentGoalRectangle; MovementDirectionChanged?.Invoke(this, new MotionDirectionChangedArgs( GazeRectangle.TestGazePoint(CurrentGazePoint), CurrentGazePoint)); //Debug.WriteLine($"MovementDirectionChanged fired at {DateTime.Now.ToLongTimeString()} !!!"); } } DownloadRawPicture(); DecorateRawPicture(); OutputProcessedPicture(); } catch { return; } }
/// <summary> /// Class constructor /// </summary> /// <param name="newMovementArea">New direction of the gaze</param> /// <param name="gazePoint">New point of the gaze's fixation</param> public MotionDirectionChangedArgs(MoveGoalRectangles newMovementArea, Point gazePoint) { GazePoint = gazePoint; NewMovementArea = newMovementArea; }