public void RegisterGesture(IGesture gesture,GestureEventHandler callback) { if (!_registeredGestures.ContainsKey(gesture)) { _registeredGestures.Add(gesture,callback); } }
private void MouseDown(IGesture gesture, GameTime time, IInputDevice device) { if (RespondOnMouseDown) OnSelected(); _mouseDown = true; }
/// <summary> /// Initialiazes a new <see cref="RepeatGesture"/> instance /// with a <see cref="Form"/> instance. /// </summary> /// <param name="form"> /// Target <see cref="Form"/> /// </param> /// <param name="gesture"> /// The gesture to be repeated /// </param> /// <param name="repeatCount"> /// The number of repetition</param> public RepeatGesture(Form form, IGesture gesture, int repeatCount) : base(form) { if (gesture == null) throw new ArgumentNullException("gesture"); this.gesture = gesture; }
private void RunGesture(IGesture gesture) { ThreadRunner runner = new ThreadRunner(new ThreadStart(gesture.Start)); runner.Run(); if (runner.CatchedException != null) Assert.Fail(runner.CatchedException.ToString()); }
/// <summary> /// Edit gesture or add new one. /// </summary> public GestureDefinition(IGesture gesture, bool reName) : this() { _capturedPointPatterns = gesture.PointPatterns; GestureManager.Instance.GestureName = gesture.Name; if (reName) _existingGestureName = gesture.Name; this.ReName = reName; }
/// <summary> /// Adds a gesture to the gesture recognizer's set of gestures to recognize /// </summary> /// <param name="currentView">The current view to associate with the gesture</param> /// <param name="gesture">The gesture to add</param> public void AddGesture(IView currentView, IGesture gesture) { if (currentView != null) { if (!gestureMap.ContainsKey(currentView)) gestureMap.Add(currentView, new List<IGesture>()); gestureMap[currentView].Add(gesture); } gestures.Add(gesture); }
public GestureBuilderParameters(IGesture gesture, SkeletonRenderFrames skeletonRenderFrames, DateTime gestureStartTime, DateTime gestureEndTime, GestureBuilder.BuildStrategy buildStrategy) { this.gesture = gesture; this.skeletonRenderFrames = skeletonRenderFrames; this.gestureStartTime = gestureStartTime; this.gestureEndTime = gestureEndTime; this.buildStrategy = buildStrategy; }
public GestureEventArgs(IGesture gesture) { this.Gesture = gesture; }
private void MouseUp(IGesture gesture, GameTime time, IInputDevice device) { if (!RespondOnMouseDown && _mouseDown) OnSelected(); }
/// <summary> /// Creates a <see cref="Thread"/> for the /// <see cref="IGesture.Start"/> method and starts it. /// </summary> /// <param name="gesture"> /// The <see cref="IGesture"/> to execute /// </param> /// <returns> /// The started <see cref="Thread"/> instance /// </returns> public static Thread Start(IGesture gesture) { ThreadStart start = new ThreadStart(gesture.Start); Thread thread = new Thread(start); thread.Start(); return thread; }
/// <summary> /// Creates a new <see cref="RepeatGesture"/> with /// the gesture and the repeat count /// </summary> /// <param name="gesture"> /// Target <see cref="IGesture"/> instance /// </param> /// <param name="repeatCount"> /// Number of repetition /// </param> /// <returns> /// A <see cref="RepeatGesture"/> instance /// </returns> public RepeatGesture Repeat(IGesture gesture, int repeatCount) { if (gesture == null) throw new ArgumentNullException("gesture"); return new RepeatGesture(this.Form, gesture, repeatCount); }
private void NextOption(IGesture gesture, GameTime time, IInputDevice device) { SelectedOption++; }
public void PerformGesture(IGesture gesture) { // TODO Works only for default portrait orientation, need to take orientation into account var array = gesture.GetScreenPoints().ToArray(); foreach (var point in array.Take(array.Length - 1)) { this.MoveCursorTo(point); this.LeftButtonDown(); Thread.Sleep(gesture.PeriodBetweenPoints); } this.MoveCursorTo(array.Last()); this.LeftButtonUp(); }
private void PreviousOption(IGesture gesture, GameTime time, IInputDevice device) { PreviousOption(); }
public void RemoveGesture(IGesture gesture) { //removedGestures.Add(gesture); gestures.Remove(gesture); }
public GestureEvent(IGesture gesture) { _gesture = gesture; }
private void OnPreviousCommand(IGesture gesture, GameTime gameTime, IInputDevice device) { if (_commandScrollPointer == null) { _commandScrollPointer = _previousCommands.Last; WritePreviousCommand(); } else if (_commandScrollPointer.Previous != null) { _commandScrollPointer = _commandScrollPointer.Previous; WritePreviousCommand(); } }
private void OnNextCommand(IGesture gesture, GameTime gameTime, IInputDevice device) { if (_commandScrollPointer != null) { if (_commandScrollPointer.Next != null) { _commandScrollPointer = _commandScrollPointer.Next; WritePreviousCommand(); } else { _textBox.Text = ""; _commandScrollPointer = null; } } }
private void OnAutocomplete(IGesture gesture, GameTime gameTime, IInputDevice device) { if (_help.HasValue && _help.Value.PossibleCommands.Length > 0) { var h = _help.Value; string similarity = ""; int letter = 0; bool b = true; while (true) { char c = ' '; for (int i = 0; i < _help.Value.PossibleCommands.Length; i++) { if (letter >= _help.Value.PossibleCommands[i].Length) { b = false; break; } if (c == ' ') c = _help.Value.PossibleCommands[i][letter]; else { if (c != _help.Value.PossibleCommands[i][letter]) { b = false; break; } } } if (!b) break; similarity += c; letter++; } _textBox.Text = h.Command.Substring(0, h.TabStart) + similarity; } }
private void Select(IGesture gesture, GameTime time, IInputDevice device) { OnSelected(); }
private void NextOption(IGesture gesture, GameTime time, IInputDevice device) { NextOption(); }
/// <summary> /// Register passed gesture instance to be recognized by this API. Gesture can be any type implementing interface IGesture. /// This function should used for gestures, that require external datafile to load his configuration. /// </summary> /// <param name="gesture">Instance of gesture. Must impement IGesture interface.</param> /// <param name="gestureDataFile">Path to file containing gesture definition or configuration data.</param> /// <param name="forcedGestureRecognition">If true, thist gesture will be evaluated for every valid sequence and will be emited event for it. /// This means that event wil be emited for thist gesture every possible time not depending on his current likehood or if this event have maximal likehooh.</param> /// <returns>Returns passed gesture.</returns> /// <seealso cref="IGesture"/> /// <exception cref="KinectStateException">Gesture with this id already registered.</exception> /// <exception cref="GestureStateException">On some error in gesture initialization or loading.</exception> public IGesture RegisterGesture(IGesture gesture, string gestureDataFile, bool forcedGestureRecognition = false) { if (gestureStore.Select(gest => gest.Key.Id == gesture.Id).Contains(true)) throw new KinectStateException("Cannot register two gestures with same ID."); gestureStore.Add(gesture, forcedGestureRecognition); gesture.LoadData(gestureDataFile); players.RegisterGestureForAll(gesture, forcedGestureRecognition); return gesture; }
/// <summary> /// Processes a skeleton frame from the Kinect controller /// </summary> /// <param name="frame">The skeleton frame to process</param> public void ProcessSkeleton(SkeletonData skeleton) { if (activeGesture != null) { if (activeGesture.IsComplete(skeleton)) { if (GestureCompleted != null) { GestureCompleted.Invoke(this, new GestureEventArgs(activeGesture)); } activeGesture.Deactivate(); activeGesture = null; } else if (activeGesture.IsOut(skeleton)) { if (GestureLeft != null) { GestureLeft.Invoke(this, new GestureEventArgs(activeGesture)); } activeGesture.Deactivate(); activeGesture = null; } } if (activeGesture == null) { double maxScore = 0; IGesture maxGesture = null; foreach (IGesture gesture in gestures) { double score = gesture.GetTriggerScore(skeleton); if (score > Math.Max(maxScore, THRESHOLD)) { maxScore = score; maxGesture = gesture; } } if (maxGesture != null) { activeGesture = maxGesture; if (GestureStarted != null) { GestureStarted.Invoke(this, new GestureEventArgs(activeGesture)); } activeGesture.Activate(); } } }
public void Add(IGesture gesture) { if (gesture == null) throw new ArgumentNullException("gesture"); this.List.Add(gesture); }
public void DoGesture(IGesture gesture) { gesture.Perform(this); Pause(PauseDurationAfterPerformingGesture); }
public void AddGesture(IGesture gesture) { _gestures.Add(gesture); }
public void DoGesture(IGesture gesture) { // Irrelevant to actual devices }
public void RemoveGesture(IGesture gesture) { _gestures.Remove(gesture); }
private void PreviousOption(IGesture gesture, GameTime time, IInputDevice device) { SelectedOption--; }
/// <summary> /// /// </summary> /// <param name="gesture"></param> /// <returns></returns> public IDisposable Subscribe(IGesture gesture) { return Subscribe((IObserver<Skeleton[]>) gesture); }