private void AddGesture() { var eyeGesture = new EyeGesture() { Steps = new ObservableCollection <EyeGestureStep>() { new EyeGestureStep() } }; if (GestureList != null) { GestureList.Add(eyeGesture); } else { GestureList = new ObservableCollection <EyeGesture>() { eyeGesture } }; EyeGesture = eyeGesture; }
private bool PointAdvancesGesture(Point checkpoint, double moveDelta, ref EyeGesture gesture, ref EyeGestureStep step) { var result = false; if (step.type == EyeGestureStepTypes.Fixation) { if (moveDelta > step.Radius) { step.DwellStart = DateTime.Now; } else if (DateTime.Now > step.DwellStart + TimeSpan.FromMilliseconds(step.DwellTime)) { result = true; gesture.FixationPoint = checkpoint; } } else if (step.type == EyeGestureStepTypes.LookInDirection) { result = (checkpoint.X - gesture.PointStamp.X) / (Graphics.VirtualScreenWidthInPixels * step.X / 100d) > 1 && (checkpoint.Y - gesture.PointStamp.Y) / (Graphics.VirtualScreenHeightInPixels * step.Y / 100d) > 1; } else if (step.type == EyeGestureStepTypes.LookAtArea) { var left = step.Left * Graphics.VirtualScreenWidthInPixels / 100d; var top = step.Top * Graphics.VirtualScreenHeightInPixels / 100d; if (step.Round) { var xRadius = step.Width * Graphics.VirtualScreenWidthInPixels / 50d; var yRadius = step.Height * Graphics.VirtualScreenHeightInPixels / 50d; var xLength = checkpoint.X - (left + xRadius); var yLength = checkpoint.Y - (top + yRadius); if (Math.Pow(xLength, 2) / Math.Pow(xRadius, 2) + Math.Pow(yLength, 2) / Math.Pow(yRadius, 2) > 1) { step.DwellStart = DateTime.Now; } else if (DateTime.Now > step.DwellStart + TimeSpan.FromMilliseconds(step.DwellTime)) { result = true; } } else { var width = step.Width * Graphics.VirtualScreenWidthInPixels / 100d; var height = step.Height * Graphics.VirtualScreenHeightInPixels / 100d; if (checkpoint.X < left || checkpoint.X > left + width || checkpoint.Y < top || checkpoint.Y > top + height) { step.DwellStart = DateTime.Now; } else if (DateTime.Now > step.DwellStart + TimeSpan.FromMilliseconds(step.DwellTime)) { result = true; } } } else { if ((checkpoint - gesture.FixationPoint).Length > Graphics.VirtualScreenHeightInPixels * step.Width / 50d) { step.DwellStart = DateTime.Now; } else if (DateTime.Now > step.DwellStart + TimeSpan.FromMilliseconds(step.DwellTime)) { result = true; } } if (result) { gesture.PointStamp = checkpoint; gesture.TimeStamp = DateTime.Now; } return(result); }