private void MouseDown(IGesture gesture, GameTime time, IInputDevice device) { if (RespondOnMouseDown) OnSelected(); _mouseDown = true; }
public virtual void HandlePointerEvent(IPointerEvent evnt) { double scale = 1.0 / Zoom; IPointerEvent subEvnt = new PointerEventAdapter(evnt, (int)(0.5 + (evnt.RawX - Canvas.RawWidth / 2.0) * scale + CenterX), (int)(0.5 + (evnt.RawY - Canvas.RawHeight / 2.0) * scale + CenterY)); IGesture gest = gesture; if (gest != null) { switch (evnt.Type) { case PointerEventType.GestureStart: gest.GestureStart(subEvnt); break; case PointerEventType.GestureMove: gest.GestureMove(subEvnt); break; case PointerEventType.GestureEnd: gest.GestureComplete(subEvnt); break; } } }
void Reset() { if (gesture == null) { gesture = GetComponent <IGesture>(); } }
private void MouseUp(IGesture gesture, GameTime time, IInputDevice device) { if (!RespondOnMouseDown && mouseDown) { OnSelected(); } }
public static List <IGesture> GetRelatedGestures(this IEnumerable <IApplication> applications, IEnumerable <IGesture> gestures) { var result = new List <IGesture>(); foreach (var app in applications) { if (app.Actions == null) { continue; } foreach (var action in app.Actions) { if (action == null || string.IsNullOrEmpty(action.GestureName)) { continue; } IGesture gesture = gestures.FirstOrDefault(g => g.Name == action.GestureName); if (gesture != null && !result.Contains(gesture)) { result.Add(gesture); } } } return(result); }
/// <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; }
public void RegisterGesture(IGesture gesture,GestureEventHandler callback) { if (!_registeredGestures.ContainsKey(gesture)) { _registeredGestures.Add(gesture,callback); } }
private void RunGesture(IGesture gesture) { ThreadRunner runner = new ThreadRunner(new ThreadStart(gesture.Start)); runner.Run(); if (runner.CatchedException != null) Assert.Fail(runner.CatchedException.ToString()); }
private TrackingData RetrieveTrackingData(int skeletonID, Skeleton skel) { TrackingData result; trackingMapper.TryGetValue(skeletonID, out result); if (result == null) { IGesture[] gestures = new IGesture[] { new RHSWaveGesture(), new JumpGesture(skel) }; gestures[0].OnRecognized += OnWaveRecognized; /* Give the kalman filter some time to converge before firing events */ var kalman_wait_time = 1; // in seconds var dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += (sender, e) => { Debug.WriteLine("Delayed subscription on JUMP"); gestures[1].OnRecognized += OnJumpRecognized; dispatcherTimer.Stop(); }; dispatcherTimer.Interval = new TimeSpan(0, 0, kalman_wait_time); dispatcherTimer.Start(); result = new TrackingData(skeletonID, gestures); trackingMapper[skeletonID] = result; } return(result); }
public void ClickButtonTwo() { IGesture gesture = factory.MouseClick(form.button2); RunGesture(gesture); Assert.AreEqual(1, form.button2ClickCount); }
void RemoveGestureEvent( IGesture gesture ) { EventTouchBegan.RemoveListener( gesture.OnStart ); EventTouchMoved.RemoveListener( gesture.OnUpdate ); EventTouchStationary.RemoveListener( gesture.OnUpdate ); EventTouchEnd.RemoveListener( gesture.OnFinish ); }
void AddGestureEvent( IGesture gesture ) { EventTouchBegan.AddListener( gesture.OnStart ); EventTouchMoved.AddListener( gesture.OnUpdate ); EventTouchStationary.AddListener( gesture.OnUpdate ); EventTouchEnd.AddListener( gesture.OnFinish ); }
/// <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)); }
/// <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> /// 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); }
public void Add(IGesture gesture) { if (gesture == null) { throw new ArgumentNullException("gesture"); } this.List.Add(gesture); }
/// <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); }
private void MouseDown(IGesture gesture, GameTime time, IInputDevice device) { if (RespondOnMouseDown) { OnSelected(); } mouseDown = true; }
public void UnRegisterGesture(IGesture gesture) { if (gesture == null) { throw new ArgumentNullException("gesture"); } _bodyFrameReader.FrameArrived -= gesture.FrameArrived; _gestures.Remove(gesture); }
/// <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; }
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; }
private void RunGesture(IGesture gesture) { ThreadRunner runner = new ThreadRunner(new ThreadStart(gesture.Start)); runner.Run(); if (runner.CatchedException != null) { Assert.Fail(runner.CatchedException.ToString()); } }
void Reset() { _target = null; //_prevType = Gesture.Press; if (_activeState != null && _activeState != _idle) { _idle.Activate(); } _activeState = _idle; }
/// <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; }
public void ClickButtonOneAndTwo() { IGesture gesture1 = factory.MouseClick(form.button1); IGesture gesture2 = factory.MouseClick(form.button2); IGesture gesture = factory.Sequence(gesture1, gesture2); RunGesture(gesture); Assert.AreEqual(1, form.button1ClickCount); Assert.AreEqual(1, form.button2ClickCount); }
void OnGestureDone(IGesture a_Gesture, bool a_Error) { Dictionary <string, object> response = new Dictionary <string, object>(); response["event"] = "execute_done"; response["gestureId"] = a_Gesture.GetGestureId(); response["instanceId"] = a_Gesture.GetInstanceId(); response["error"] = a_Error; TopicClient.Instance.Publish("gesture-manager", Json.Serialize(response)); }
private void Init() { if (_isInited) { return; } _guiDrawer = new GUI.Drawer(); _guiDrawer.OnClose += () => _isShowingGUI = false; var gestureLeastLength = (Screen.width + Screen.height) / 4; _gesture = new CircleGesture(new TouchProvider(), gestureLeastLength); }
//! Callback for sensor-manager topic. void OnGestureManagerEvent(TopicClient.Payload a_Payload) { IDictionary json = Json.Deserialize(Encoding.UTF8.GetString(a_Payload.Data)) as IDictionary; bool bFailed = false; string gestureId = json["gestureId"] as string; string instanceId = json["instanceId"] as string; string gestureKey = gestureId + "/" + instanceId; string event_name = json["event"] as string; IGesture gesture = null; if (m_Gestures.ContainsKey(gestureKey)) { if (m_Gestures.TryGetValue(gestureKey, out gesture)) { if (event_name.CompareTo("execute_gesture") == 0) { if (!gesture.Execute(OnGestureDone, json["params"] as IDictionary)) { Log.Error("GestureManager", "Failed to execute gesture {0}", gestureId); bFailed = true; } } else if (event_name.CompareTo("abort_gesture") == 0) { if (!gesture.Abort()) { Log.Error("GestureManager", "Failed to abort gesture {0}", gestureId); bFailed = true; } } } else { Log.Error("GestureManager", "Failed to find gesture {0}", gestureKey); bFailed = true; } // if we failed, send the message back with a different event if (bFailed) { json["failed_event"] = event_name; json["event"] = "error"; TopicClient.Publish("gesture-manager", Json.Serialize(json)); } } else { //do nothing } }
public void RegisterGesture(IGesture gesture) { if (gesture == null) { throw new ArgumentNullException("gesture"); } if (_gestures.Contains(gesture)) { return; } _gestures.Add(gesture); _bodyFrameReader.FrameArrived += gesture.FrameArrived; }
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 BuildMovingGestureTree() { IGesture gesture = null; DateTime start = (DateTime)gestureStartTimeListBox.SelectedItem; DateTime end = (DateTime)gestureEndTimeListBox.SelectedItem; GestureBuilderParameters parameters = new GestureBuilderParameters(gesture, renderCanvas.SkeletonRenderFrames, start, end, GestureBuilder.BuildStrategy.StandardTolerance); GestureBuilder builder = new GestureBuilder(); movingGestureTree = builder.BuildMovingGestureTree(parameters); renderCanvas.SaveCanvasFrames("C:\\Users\\Robert\\Documents\\GitHub\\docs\\files\\render bin\\gesture_8_half_wave.xml"); Serializer.SerializeToXml <MovingGestureTree>(movingGestureTree, "C:\\Users\\Robert\\Documents\\GitHub\\docs\\files\\gesture bin\\gesture_7_half_wave.xml"); }
/// <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); } //addedGestures.Add(gesture); gestures.Add(gesture); }
private void GestureStart(IPointerEvent evnt, bool considerPoke) { IGesture newGesture = GetGesture(evnt, considerPoke); if (newGesture != null) { if (current != null) { current = null; evnt.RepaintCanvas(); } layoutCanvas.Gesture = newGesture; newGesture.GestureStart(evnt); } }
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 OnNextCommand(IGesture gesture, GameTime gameTime, IInputDevice device) { if (commandScrollPointer != null) { if (commandScrollPointer.Next != null) { commandScrollPointer = commandScrollPointer.Next; WritePreviousCommand(); } else { textBox.Text = ""; commandScrollPointer = null; } } }
private bool SaveGesture(IGesture gesture) { if (string.IsNullOrEmpty(gesture.Name)) { gesture.Name = GestureManager.GetNewGestureName(); } if (GestureManager.Instance.GestureExists(gesture.Name)) { GestureManager.Instance.DeleteGesture(gesture.Name); } GestureManager.Instance.AddGesture(gesture); GestureManager.Instance.SaveGestures(); return(true); }
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(); } }
public GestureEventArgs(IGesture gesture) { this.Gesture = gesture; }
public void AddGesture(IGesture gesture) { _gestures.Add(gesture); }
public void Add(IGesture gesture) { if (gesture == null) throw new ArgumentNullException("gesture"); this.List.Add(gesture); }
/// <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; }
public void DoGesture(IGesture gesture) { gesture.Perform(this); Pause(PauseDurationAfterPerformingGesture); }
public void RemoveGesture(IGesture gesture) { _gestures.Remove(gesture); }
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 MouseUp(IGesture gesture, GameTime time, IInputDevice device) { if (!RespondOnMouseDown && _mouseDown) OnSelected(); }
/// <summary> /// /// </summary> /// <param name="gesture"></param> /// <returns></returns> public IDisposable Subscribe(IGesture gesture) { return Subscribe((IObserver<Skeleton[]>) gesture); }
private void PreviousOption(IGesture gesture, GameTime time, IInputDevice device) { SelectedOption--; }
public void DoGesture(IGesture gesture) { // Irrelevant to actual devices }
/// <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); }
public GestureEvent(IGesture gesture) { _gesture = gesture; }
private void NextOption(IGesture gesture, GameTime time, IInputDevice device) { SelectedOption++; }
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 Select(IGesture gesture, GameTime time, IInputDevice device) { OnSelected(); }
public void RemoveGesture(IGesture gesture) { //removedGestures.Add(gesture); gestures.Remove(gesture); }
private void NextOption(IGesture gesture, GameTime time, IInputDevice device) { NextOption(); }
/// <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(); } } }
private void PreviousOption(IGesture gesture, GameTime time, IInputDevice device) { PreviousOption(); }