コード例 #1
0
 public void RegisterGesture(IGesture gesture,GestureEventHandler callback)
 {
     if (!_registeredGestures.ContainsKey(gesture))
     {
         _registeredGestures.Add(gesture,callback);
     }
 }
コード例 #2
0
ファイル: Button.cs プロジェクト: xoxota99/Myre
        private void MouseDown(IGesture gesture, GameTime time, IInputDevice device)
        {
            if (RespondOnMouseDown)
                OnSelected();

            _mouseDown = true;
        }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
 private void RunGesture(IGesture gesture)
 {
     ThreadRunner runner = new ThreadRunner(new ThreadStart(gesture.Start));
     runner.Run();
     if (runner.CatchedException != null)
         Assert.Fail(runner.CatchedException.ToString());
 }
コード例 #5
0
 /// <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;
 }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
        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;
        }
コード例 #8
0
 public GestureEventArgs(IGesture gesture)
 {
     this.Gesture = gesture;
 }
コード例 #9
0
ファイル: Button.cs プロジェクト: ylyking/Myre
 private void MouseUp(IGesture gesture, GameTime time, IInputDevice device)
 {
     if (!RespondOnMouseDown && _mouseDown)
         OnSelected();
 }
コード例 #10
0
ファイル: GestureFactory.cs プロジェクト: timonela/mb-unit
 /// <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;
 }
コード例 #11
0
ファイル: GestureFactory.cs プロジェクト: timonela/mb-unit
        /// <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);

        }
コード例 #12
0
 private void NextOption(IGesture gesture, GameTime time, IInputDevice device)
 {
     SelectedOption++;
 }
コード例 #13
0
        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();
        }
コード例 #14
0
ファイル: Menu.cs プロジェクト: ylyking/Myre
 private void PreviousOption(IGesture gesture, GameTime time, IInputDevice device)
 {
     PreviousOption();
 }
コード例 #15
0
 public void RemoveGesture(IGesture gesture)
 {
     //removedGestures.Add(gesture);
     gestures.Remove(gesture);
 }
コード例 #16
0
 public GestureEvent(IGesture gesture)
 {
     _gesture = gesture;
 }
コード例 #17
0
ファイル: CommandConsole.cs プロジェクト: ylyking/Myre
 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();
     }
 }
コード例 #18
0
ファイル: CommandConsole.cs プロジェクト: ylyking/Myre
 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;
         }
     }
 }
コード例 #19
0
ファイル: CommandConsole.cs プロジェクト: ylyking/Myre
        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;
            }
        }
コード例 #20
0
ファイル: Button.cs プロジェクト: ylyking/Myre
 private void Select(IGesture gesture, GameTime time, IInputDevice device)
 {
     OnSelected();
 }
コード例 #21
0
ファイル: Menu.cs プロジェクト: ylyking/Myre
 private void NextOption(IGesture gesture, GameTime time, IInputDevice device)
 {
     NextOption();
 }
コード例 #22
0
        /// <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;
        }
コード例 #23
0
 /// <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();
         }
     }
 }
コード例 #24
0
ファイル: GestureCollection.cs プロジェクト: timonela/mb-unit
 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);
 }
コード例 #26
0
 public void AddGesture(IGesture gesture)
 {
     _gestures.Add(gesture);
 }
 public void DoGesture(IGesture gesture)
 {
     // Irrelevant to actual devices
 }
コード例 #28
0
 public void RemoveGesture(IGesture gesture)
 {
     _gestures.Remove(gesture);
 }
コード例 #29
0
 private void PreviousOption(IGesture gesture, GameTime time, IInputDevice device)
 {
     SelectedOption--;
 }
コード例 #30
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="gesture"></param>
 /// <returns></returns>
 public IDisposable Subscribe(IGesture gesture)
 {
     return Subscribe((IObserver<Skeleton[]>) gesture);
 }