예제 #1
0
        public override void OnFrame(Controller controller)
        {
            // Get the most recent frame and report some basic information
            Frame frame = controller.Frame();

            //Get hand information
            Hand hand = frame.Hands[0];

            //get finger information
            FingerList fingers     = hand.Fingers;
            int        fingercount = fingers.Count;

            // Get gestures
            GestureList gestures = frame.Gestures();

            for (int i = 0; i < gestures.Count; i++)
            {
                Gesture gesture = gestures[i];

                switch (gesture.Type)
                {
                case Gesture.GestureType.TYPECIRCLE:
                    CircleGesture circle = new CircleGesture(gesture);
                    if (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4)
                    {
                        volume++;     //clockwise
                        if (volume > 100)
                        {
                            volume = 100;
                        }
                    }
                    else
                    {
                        volume--;     //anticlockwise
                        if (volume < 0)
                        {
                            volume = 0;
                        }
                    }
                    float newVolume = (float)(volume / 100.0);
                    setVolume(Convert.ToInt32(newVolume));

                    //volumeLabel.Text = Convert.ToString(newVolume);
                    break;

                case Gesture.GestureType.TYPEKEYTAP:     //Play a song
                    if (isPlaying == true)
                    {
                        song.stopPlaying();
                        isPlaying = false;
                    }
                    else
                    {
                        song.stopPlaying();
                        song.startPlaying();
                        isPlaying = true;
                    }
                    break;

                case Gesture.GestureType.TYPESCREENTAP:     //Stop a song
                    //FREE SPACE
                    break;

                case Gesture.GestureType.TYPESWIPE:
                    Vector myPalmPosition       = hand.PalmPosition;
                    double currentPalmPositionX = myPalmPosition.x;

                    if (currentPalmPositionX > lastXPosition) //Add in a +n value so its the swipe is a certian size
                    {
                        currentlyPlaying--;                   //Go back
                        currentlyPlaying = currentlyPlaying % tracksCount;
                        if (currentlyPlaying < 0)
                        {
                            currentlyPlaying = 0;
                        }                                                       //boundsCheckFix
                    }
                    else
                    {
                        currentlyPlaying++;     //Go Forward
                        currentlyPlaying = currentlyPlaying % tracksCount;
                        if (currentlyPlaying > tracksCount)
                        {
                            currentlyPlaying = tracksCount;
                        }                                                                           //boundsCheckFix
                    }
                    lastXPosition = currentPalmPositionX;
                    break;

                default:
                    break;
                }
            }
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     musicPlayer.setIsPlaying(true);
     musicPlayer.stopPlaying();
     musicPlayer.startPlaying();
 }