예제 #1
0
        private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;

            //just one of the >2 hands is the active one
            if (!kinectPointerPoint.Properties.IsEngaged)
            {
                return;
            }

            Point pointRelativeToKinectRegion = new Point(kinectPointerPoint.Position.X * kinectRegion.ActualWidth, kinectPointerPoint.Position.Y * kinectRegion.ActualHeight);

            //CANVAS INTERACTION
            if (!isMenuOpen)
            {
                if ((kinectPointerPoint.Properties.HandType == HandType.RIGHT && rHand == UserSettings.Instance.GESTURE_MOVE) || (kinectPointerPoint.Properties.HandType == HandType.LEFT && lHand == UserSettings.Instance.GESTURE_MOVE))
                {
                    myCanvas.updateStrokes(pointRelativeToKinectRegion, SketchCanvas.UserAction.Move);
                }
                else if ((kinectPointerPoint.Properties.HandType == HandType.RIGHT && rHand == UserSettings.Instance.GESTURE_DRAW) || (kinectPointerPoint.Properties.HandType == HandType.LEFT && lHand == UserSettings.Instance.GESTURE_DRAW))
                {
                    myCanvas.updateStrokes(pointRelativeToKinectRegion, SketchCanvas.UserAction.Draw);
                }
                else if ((kinectPointerPoint.Properties.HandType == HandType.RIGHT && rHand == UserSettings.Instance.GESTURE_RUBBER) || (kinectPointerPoint.Properties.HandType == HandType.LEFT && lHand == UserSettings.Instance.GESTURE_RUBBER))
                {
                    myCanvas.updateStrokes(pointRelativeToKinectRegion, SketchCanvas.UserAction.Cancel);
                }
            }
        }
예제 #2
0
 private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs e)
 {
     if (bodies.Length != null && bodies.Length != 0)
     {
         handPointer = e.CurrentPoint;
     }
 }
        private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;

            if (kinectPointerPoint.Properties.IsEngaged)
            {
                // PointerPoints come with X/Y positions from 0.0 to 1.0
                // To calculate the corresponding point in pixels, we multiple by width/height of KinectRegion
                Point pointRelativeToKinectRegion = new Point(
                    kinectPointerPoint.Position.X * _kinectRegion.ActualWidth,
                    kinectPointerPoint.Position.Y * _kinectRegion.ActualHeight);

                Point relativeToElement = _kinectRegion.TranslatePoint(pointRelativeToKinectRegion, _interactiveElement);
                bool  insideElement     = (relativeToElement.X >= 0 && relativeToElement.X < _interactiveElement.ActualWidth &&
                                           relativeToElement.Y >= 0 && relativeToElement.Y < _interactiveElement.ActualHeight);
                if (insideElement)
                {
                    if (!_isHandPointerEntered)
                    {
                        _isHandPointerEntered = true;
                        _handPointerEnter?.Invoke(_interactiveElement, null);
                    }
                }
                else
                {
                    if (_isHandPointerEntered)
                    {
                        _isHandPointerEntered = false;
                        _handPointerLeave?.Invoke(_interactiveElement, null);
                    }
                }
            }
        }
예제 #4
0
        void ThisAddIn_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            //if (this.slideShow != null)
            {
                //Change la position du curseur en fonction de la position des mains
                if (e.CurrentPoint.Properties.HandType == HandType.RIGHT)
                {
                    Win32.SetCursorPos((int)(e.CurrentPoint.Position.X * 1920), (int)(e.CurrentPoint.Position.Y * 1080));

                    Debug.WriteLine(e.CurrentPoint.Properties.HandReachExtent);

                    if (e.CurrentPoint.Properties.HandReachExtent > 0.5f)
                    {
                        //TODO lancer le clique down + ctrl -> pointeur
                        Win32.sendDown();
                    }
                    else
                    {
                        //TODO lancer le clique up -> pointeur
                        Win32.sendUp();
                    }
                }

                //TODO erreur application occupée lors du clique droit sur le slide en cours
                //this.pointerPosition.X = e.CurrentPoint.Properties.UnclampedPosition.X * this.Application.ActivePresentation.SlideMaster.Width;
                //this.pointerPosition.Y = e.CurrentPoint.Properties.UnclampedPosition.Y * this.Application.ActivePresentation.SlideMaster.Height;
                //this.slideShow.View.PointerType = PpSlideShowPointerType.ppSlideShowPointerAutoArrow;
            }
        }
예제 #5
0
        //########################################################### EVENEMENTS ###########################################################

        /// <summary>
        /// Evénement déclenché lorsqu'un pointeur de Kinect bougé
        /// </summary>
        /// <remarks>Fonctionne pour 1 seul personne uniquement. Kinect ne doit en détecter qu'une seule et unique</remarks>
        /// <param name="sender">L'objet déclenchant</param>
        /// <param name="args">Les arguments de l'événement contenant, notamment, la position actuel du curseur</param>
        void kinectCore_PointerMoved(KinectCoreWindow sender, KinectPointerEventArgs args)
        {
            //Un point selong l'axe X-Y (en %)
            KinectPointerPoint point = args.CurrentPoint;


            //Cette condition permet de contourner certain problème qui apparaissent.
            //En effet, cet événement est appelé 2 fois par personne, une fois pour la main droite et une fois pour la main gauche
            //On a donc 2 points de curseur par personne
            //N'utiliser que la main droite permet d'éviter que les deux mains bougent le curseur
            if (point.Properties.HandType == HandType.RIGHT) //On n'utilise que la main droite
            {
                //Calcule du diametre de la ligne
                double diameter = CURSOR_DIAMETER;
                diameter *= Math.Pow(point.Properties.HandReachExtent + 0.5, 3);

                //Traduit les positions données par Kinect (en %) en position en pixel
                double currentPosX = point.Position.X * this.cursorMoveCanvas.ActualWidth;
                double currentPosY = point.Position.Y * this.cursorMoveCanvas.ActualHeight;

                //Calcule la position du curseur
                this.cursorPosition.PosX = currentPosX - CURSOR_DIAMETER / 2;
                this.cursorPosition.PosY = currentPosY - CURSOR_DIAMETER / 2;

                if (point.Properties.HandReachExtent > 0.5) //Lorsqu'on commence à appuyer, on dessine
                {
                    if (this.lastPosition != null)          //Si le dernier point appuyé existe, on peut dessiner. Sinon, on attends le prochain "tour"
                    {
                        //Ajout la ligne entre le dernier point et le point courant
                        Line lineToAdd = new Line()
                        {
                            //La position initiale de la ligne, tirée du dernier point
                            X1 = lastPosition.Value.X,
                            Y1 = lastPosition.Value.Y,
                            //La position finale de la ligne, tirée du point courant
                            X2 = currentPosX,
                            Y2 = currentPosY,

                            //Design de la ligne
                            StrokeThickness = diameter,       //Le diamètre de la ligne a été calculé
                            Stroke          = this.drawBrush, //La couleur stockée en local est utilisée
                            //La ligne commence et finis par un cercle.
                            StrokeStartLineCap = PenLineCap.Round,
                            StrokeEndLineCap   = PenLineCap.Round
                        };


                        //On ajoute la ligne dans le canvas de dessin
                        this.drawCanvas.Children.Add(lineToAdd);
                    }

                    //Met à jour la dernière position du point. La ligne à dessiner se fera à partir de ce point
                    this.lastPosition = new Point(currentPosX, currentPosY);
                }
                else //Si on n'appuie pas/plus, on ne dessine pas
                {
                    this.lastPosition = null;
                }
            } //FIN - main droite
        }     //FIN - kinectCore_PointerMoved
예제 #6
0
        void kinectCore_PointerEntered(KinectCoreWindow sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint point = args.CurrentPoint;

            if (point.Properties.HandType == HandType.RIGHT)
            {
            }
        }
예제 #7
0
 private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
 {
     if (crowdController.mainBody != null)
     {
         if (args.CurrentPoint.Properties.BodyTrackingId == crowdController.mainBody.TrackingId)
         {
             kinectPointerPoint = args.CurrentPoint;
         }
     }
 }
예제 #8
0
        private void drawArea_PointerMove(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;

            if (args.CurrentPoint.Properties.HandType == engagement.Draw(kinectPointerPoint.Properties.BodyTrackingId))
            {
                Point currentPoint = new Point(kinectPointerPoint.Position.X * drawArea.ActualWidth, kinectPointerPoint.Position.Y * drawArea.ActualHeight);                 // MouseControl.GetCursorPosition();
                // Draw(currentPoint);
                Console.WriteLine("kinect point " + drawArea.ActualWidth + " " + drawArea.ActualHeight);
            }
        }
예제 #9
0
        /// <summary>
        /// Handles kinect pointer events
        /// </summary>
        /// <param name="sender">the KinectCoreWindow</param>
        /// <param name="args">Kinect pointer args</param>
        private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;

            if (lastTime == TimeSpan.Zero || lastTime != kinectPointerPoint.Properties.BodyTimeCounter)
            {
                lastTime = kinectPointerPoint.Properties.BodyTimeCounter;
                mainScreen.Children.Clear();
            }

            RenderPointer(kinectPointerPoint.Properties.IsEngaged,
                          kinectPointerPoint.Position.X,
                          kinectPointerPoint.Position.Y,
                          kinectPointerPoint.Properties.BodyTrackingId,
                          kinectPointerPoint.Properties.HandType);
        }
예제 #10
0
        void kinectCore_PointerMoved(KinectCoreWindow sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint point = args.CurrentPoint;


            if (point.Properties.HandType == HandType.RIGHT)
            {
                //Diamètre du cercle
                double diameter = 30;
                diameter = diameter * Math.Pow(point.Properties.HandReachExtent + 0.5, 3);


                this.posX = point.Position.X * CursorMove.ActualWidth - 15;
                this.posY = point.Position.Y * CursorMove.ActualHeight - 15;

                if (point.Properties.HandReachExtent > 0.5)
                {
                    //Add line
                    if (lastPosition != null)
                    {
                        Line line = new Line()
                        {
                            X1 = lastPosition.Value.X, Y1 = lastPosition.Value.Y, X2 = posX + 15, Y2 = posY + 15, StrokeThickness = diameter, Stroke = this.drawBrush, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round
                        };
                        Debug.WriteLine(line.Y1);
                        CursorMove.Children.Insert(0, line);
                    }

                    //Update the last position
                    lastPosition = new Point(posX + 15, posY + 15);



                    //Add ellipse --> DRAWING Lines is better
                    //Ellipse form = new Ellipse() { Height = diameter, Width = diameter, Margin = new Thickness(posX + 15 - diameter/2, posY+15-diameter/2, 0, 0), Fill = new SolidColorBrush(Colors.Red), Opacity=1f };
                    //CursorMove.Children.Insert(0,form);
                }
                else
                {
                    lastPosition = null;
                }
            }


            //INdique qu'on a traité le point
            args.Handled = true;
        }
예제 #11
0
        /// <summary>
        /// Handles kinect pointer events
        /// </summary>
        /// <param name="sender">the KinectCoreWindow</param>
        /// <param name="args">Kinect pointer args</param>
        private static void KinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;

            if (lastTime == TimeSpan.Zero || lastTime != kinectPointerPoint.Properties.BodyTimeCounter)
            {
                lastTime = kinectPointerPoint.Properties.BodyTimeCounter;
            }

            if (kinectPointerPoint.Properties.IsEngaged)
            {
                hand.posX       = kinectPointerPoint.Position.X;
                hand.posY       = kinectPointerPoint.Position.Y;
                engagedBodyId   = kinectPointerPoint.Properties.BodyTrackingId;
                engagedHandType = kinectPointerPoint.Properties.HandType;
                SendPointerInfo();
            }
        }
예제 #12
0
        private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;

            if (lastTime == TimeSpan.Zero || lastTime != kinectPointerPoint.Properties.BodyTimeCounter)
            {
                lastTime = kinectPointerPoint.Properties.BodyTimeCounter;
                mainScreen.Children.Clear();
                //mainScreen.Children.Add(manoLeft);
                mainScreen.Children.Add(imgHandRight);
            }

            RenderPointer(kinectPointerPoint.Position,
                          kinectPointerPoint.Properties.UnclampedPosition,
                          kinectPointerPoint.Properties.HandReachExtent,
                          kinectPointerPoint.Properties.BodyTimeCounter,
                          kinectPointerPoint.Properties.BodyTrackingId,
                          kinectPointerPoint.Properties.HandType);
        }
        /// <summary>
        /// Handles kinect pointer events
        /// </summary>
        /// <param name="sender">the KinectCoreWindow</param>
        /// <param name="args">Kinect pointer args</param>
        private void kinectCoreWindow_PointerMoved(KinectCoreWindow sender, KinectPointerEventArgs args)
        {
            if (showKinect)
            {
                KinectPointerPoint kinectPointerPoint = args.CurrentPoint;
                if (lastTime == 0 || lastTime != kinectPointerPoint.Timestamp)
                {
                    lastTime = kinectPointerPoint.Timestamp;
                    mainScreen.Children.Clear();
                }

                RenderPointer(kinectPointerPoint.Properties.IsEngaged,
                              kinectPointerPoint.Position,
                              kinectPointerPoint.Properties.UnclampedPosition,
                              kinectPointerPoint.Properties.HandReachExtent,
                              kinectPointerPoint.Properties.BodyTimeCounter,
                              kinectPointerPoint.Properties.BodyTrackingId,
                              kinectPointerPoint.Properties.HandType);
            }
        }
        void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            var kinectPointerPoint = e.CurrentPoint;
            var timeOfPointer = kinectPointerPoint.Properties.BodyTimeCounter;
            if (timeOfPointer == TimeSpan.Zero)
            {
                this.lastFrameTime = timeOfPointer;
            }
            else if (timeOfPointer == this.lastFrameTime)
            {
                this.pointerPoints.Add(kinectPointerPoint);
            }
            else
            {
                TrackEngagedPlayersViaHandInScreen();

                // reached the start of a new set of pointerPoints (0-12 each frame, 0-6 people x 2 hands)
                this.pointerPoints.Clear();
                this.pointerPoints.Add(kinectPointerPoint);
                this.lastFrameTime = timeOfPointer;
            }
        }
예제 #15
0
        void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            var kinectPointerPoint = e.CurrentPoint;
            var timeOfPointer      = kinectPointerPoint.Properties.BodyTimeCounter;

            if (timeOfPointer == TimeSpan.Zero)
            {
                this.lastFrameTime = timeOfPointer;
            }
            else if (timeOfPointer == this.lastFrameTime)
            {
                this.pointerPoints.Add(kinectPointerPoint);
            }
            else
            {
                TrackEngagedPlayersViaHandInScreen();

                this.pointerPoints.Clear();
                this.pointerPoints.Add(kinectPointerPoint);
                this.lastFrameTime = timeOfPointer;
            }
        }
예제 #16
0
        void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            var kinectPointerPoint = e.CurrentPoint;
            var timeOfPointer      = kinectPointerPoint.Properties.BodyTimeCounter;

            if (timeOfPointer == TimeSpan.Zero)
            {
                this.lastFrameTime = timeOfPointer;
            }
            else if (timeOfPointer == this.lastFrameTime)
            {
                this.pointerPoints.Add(kinectPointerPoint);
            }
            else
            {
                TrackEngagedPlayersViaHandInScreen();

                // reached the start of a new set of pointerPoints (0-12 each frame, 0-6 people x 2 hands)
                this.pointerPoints.Clear();
                this.pointerPoints.Add(kinectPointerPoint);
                this.lastFrameTime = timeOfPointer;
            }
        }
예제 #17
0
        private void KWin_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            if (state == 2)
            {
                if (mainHandId == 0 && e.CurrentPoint.Properties.IsPrimary &&
                e.CurrentPoint.Properties.IsEngaged)
                {
                    mainHandId = e.CurrentPoint.PointerId;
                    lastMainHandId = mainHandId;
                    ShowButtonsOnTrailer();
                }

                if (e.CurrentPoint.PointerId == mainHandId)
                {
                    CheckPointInButton(e.CurrentPoint.Position.X, e.CurrentPoint.Position.Y);
                }
                if (e.CurrentPoint.PointerId == mainHandId && !e.CurrentPoint.Properties.IsEngaged)
                {
                    mainHandId = 0;
                    HideButtonsOnTrailer();
                }
            } else if (state == 3)
            {
                if (mainHandId == 0 && e.CurrentPoint.Properties.IsPrimary &&
                                e.CurrentPoint.Properties.IsEngaged)
                {
                    mainHandId = e.CurrentPoint.PointerId;
                    lastMainHandId = mainHandId;
                }

                if (e.CurrentPoint.PointerId == mainHandId)
                {
                    CheckPointInThirdButtons(e.CurrentPoint.Position.X, e.CurrentPoint.Position.Y);
                }
                if (e.CurrentPoint.PointerId == mainHandId && !e.CurrentPoint.Properties.IsEngaged)
                {
                    mainHandId = 0;
                }
            }
            else if (state == 4)
            {
                if (mainHandId == 0 && e.CurrentPoint.Properties.IsPrimary &&
                                e.CurrentPoint.Properties.IsEngaged)
                {
                    mainHandId = e.CurrentPoint.PointerId;

                    if(lastMainHandId==0)
                        lastMainHandId = mainHandId;
                }

                if (e.CurrentPoint.PointerId == mainHandId)
                {
                    CheckPointInFourthButtons(e.CurrentPoint.Position.X, e.CurrentPoint.Position.Y);
                }
                if (e.CurrentPoint.PointerId == mainHandId && !e.CurrentPoint.Properties.IsEngaged)
                {
                    mainHandId = 0;
                }
            }
        }
예제 #18
0
        private void KWin_PointerExited(object sender, KinectPointerEventArgs e)
        {
            /*
            if(e.CurrentPoint.PointerId== lastMainHandId)
            {
                InformationBackButton();
                lastMainHandId = 0;
            }
            */

            idle.label.Opacity = 0;
        }
예제 #19
0
 private void KWin_PointerEntered(object sender, KinectPointerEventArgs e)
 {
     idle.label.Opacity = 1;
 }
예제 #20
0
 private void OnKinectPointerEntered(object sender, KinectPointerEventArgs e)
 {
     MessageBox.Show("kinect entered");
 }
예제 #21
0
 /// <summary>
 /// Page timer code to flip back to home if no one is using the board
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnKinectPointerExited(object sender, KinectPointerEventArgs e)
 {
     isKinectActive = false;
     pageTimer.Start();
 }
예제 #22
0
        void kinectCore_PointerMoved(KinectCoreWindow sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint point = args.CurrentPoint;


            if (point.Properties.HandType == HandType.RIGHT)
            {
                //Diamètre du cercle
                double diameter = 30;
                diameter = diameter * Math.Pow(point.Properties.HandReachExtent + 0.5, 3);


                this.posX = point.Position.X * CursorMove.ActualWidth - 15;
                this.posY = point.Position.Y * CursorMove.ActualHeight - 15;

                if (point.Properties.HandReachExtent > 0.5)
                {
                    //Add line
                    if (lastPosition != null)
                    {
                        Line line = new Line()
                        {
                            X1 = lastPosition.Value.X, Y1 = lastPosition.Value.Y, X2 = posX + 15, Y2 = posY + 15, StrokeThickness = diameter, Stroke = this.drawBrush, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round
                        };
                        CursorMove.Children.Insert(0, line);
                    }

                    //Update the last position
                    this.lastPosition = new Point(posX + 15, posY + 15);


                    //Add ellipse --> DRAWING Lines is better
                    //Ellipse form = new Ellipse() { Height = diameter, Width = diameter, Margin = new Thickness(posX + 15 - diameter/2, posY+15-diameter/2, 0, 0), Fill = new SolidColorBrush(Colors.Red), Opacity=1f };
                    //CursorMove.Children.Insert(0,form);


                    //--- TEST --- Connect with Joé
                    #region connectJoe
                    JObject position = new JObject();
                    position["x"]     = (int)Math.Round(point.Position.X * 900, 0);
                    position["y"]     = (int)Math.Round(point.Position.Y * 600, 0);
                    position["color"] = "#00A8E2";

                    socketIO.Emit("usrCanvasClick", position);
                    #endregion
                    //<----- FIN TEST
                }
                else
                {
                    lastPosition = null;
                }
            }

            //Changement de couleur avec la main gauche --> N'est pas une bonne façon de faire

            /*
             * if(point.Properties.HandType == HandType.LEFT)
             * {
             *  //Modifie la couleur qui sera mise
             *  //Pour avoir toute les couleurs, transformation d'un entier en une couleur
             *  int intColor = (int)(0xFFFFFF * point.Position.Y); //Toute la gamme de couleur
             *  byte[] bytColor = BitConverter.GetBytes(intColor); //Retourne un tableau de byte correspondant
             *
             *  Debug.WriteLine(intColor);
             *
             *  Color colToPaint = new Color();
             *  colToPaint.A = 255;
             *  colToPaint.B = (byte)(intColor>>16 & 0xFF);
             *  colToPaint.G = (byte)(intColor>>8 & 0xFF);
             *  colToPaint.R = (byte)(intColor & 0xFF);
             *
             *  this.btnColorChoice.Background = new SolidColorBrush(colToPaint);
             *
             *  if (point.Properties.HandReachExtent > 0.5)
             *  {
             *      this.drawBrush = this.btnColorChoice.Background;
             *      storyChangedColor.Begin();
             *  }
             * }*/

            //Indique qu'on a traité le point
            args.Handled = true;
        }
예제 #23
0
 public void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
 {
     //TODO: move mouse. Based on previous hand position. changes in hand state should disable movement for a short time?
     KinectPointerPoint kinectPointerPoint = args.CurrentPoint;
     unclampedPoint=kinectPointerPoint.Properties.UnclampedPosition;
 }
예제 #24
0
        /// <summary>
        /// Lorsque une main/pointeur bouge sur l'écran
        /// </summary>
        /// <param name="sender">L'appelant</param>
        /// <param name="args">Les arguments</param>
        void kinectCore_PointerMoved(KinectCoreWindow sender, KinectPointerEventArgs args)
        {
            //Le point kinect et le point déduit sur l'interface
            KinectPointerPoint currentPointerPoint = args.CurrentPoint;
            Point currentPixelPoint = new Point()
            {
                X = (int)(currentPointerPoint.Position.X * app.kinectRegion.ActualWidth),
                Y = (int)(currentPointerPoint.Position.Y * app.kinectRegion.ActualHeight)
            };


            if (currentPointerPoint.Properties.IsEngaged) //Vérifie le point actuellement utilisé
            {
                //Dans le cas ou le point est dans le canvas, on peut commencer à dessiner
                if (isPointInCanvas(currentPixelPoint))
                {
                    //Lorsqu'on est dans le canvas, on cache la main pour pouvoir dessiner
                    // TODO

                    #region dessin


                    //Diamètre du cercle changeant avec la pression
                    double diameter = 30;
                    diameter = diameter * Math.Pow(currentPointerPoint.Properties.HandReachExtent + 0.5, 3);

                    //Les deux possiion à dessiner
                    double posX = currentPixelPoint.X - getPointDrawCanvasPosition().X - 15;
                    double posY = currentPixelPoint.Y - getPointDrawCanvasPosition().Y - 15;

                    if (currentPointerPoint.Properties.HandReachExtent > 0.5) // Plus que 50 cm de l'épaule
                    {
                        //Add line
                        if (lastPoint != null)
                        {
                            Line line = new Line()
                            {
                                X1 = this.lastPoint.Value.X,
                                Y1 = this.lastPoint.Value.Y,
                                X2 = posX + 15,
                                Y2 = posY + 15,

                                StrokeThickness    = diameter,
                                Stroke             = btnColor.Background,
                                StrokeStartLineCap = PenLineCap.Round,
                                StrokeEndLineCap   = PenLineCap.Round
                            };

                            drawCanvas.Children.Add(line);
                        }

                        //Update the last position
                        this.lastPoint = new Point(posX + 15, posY + 15);
                    }
                    else
                    {
                        //Si on est moins que 0.5cm, on met le dernier point à null pour ne plus dessiner
                        lastPoint = null;
                    }

                    #endregion //----Dessin
                }
                else //Si on est hors du champ de dessin
                {
                    //On affiche le pointeur
                }
            }

            //Indique que le point a bien été géré
            args.Handled = true;
        }
예제 #25
0
        /// <summary>
        /// Méthode appelée lorsque le pointeur kinect, c'est à dire la main, a bougé.
        /// </summary>
        /// <param name="sender">L'objet appelant</param>
        /// <param name="e">Les arguments de l'évenements</param>
        private void KinectPowerPoint_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            KinectPointerPoint point = e.CurrentPoint;

            //On vérifie si on doit afficher le pointeur----

            if (this.slideShow != null)
            {
                lock (this.pointerLock)
                {
                    if (this.pointer != null)
                    {
                        #region Engagement "tendre le bras" avec HandReachExtent
                        //*
                        if (KinectCoreWindow.KinectManualEngagedHands.Count == 0) //On vérifie que personne n'est engagé
                        {
                            //Quand on montre du doigt, le doigt est a une certaine distance du coude. On peut l'utiliser pour activer le pointeur
                            if (point.Properties.HandReachExtent > FLT_POINTER_DISTANCE_ENGAGEMENT)
                            {
                                this.pointer.Visible = Office.MsoTriState.msoTrue;
                                KinectCoreWindow.SetKinectOnePersonManualEngagement(new BodyHandPair(point.Properties.BodyTrackingId, point.Properties.HandType));
                            }
                        }
                        else //Si une personne est engagée, on peut peut-être la désengager
                        {
                            if (point.Properties.IsEngaged) //Le point courant doit être engagé pour désengager
                            {
                                if (point.Properties.HandReachExtent <= FLT_POINTER_DISTANCE_DISENGAGEMENT)
                                {
                                    KinectCoreWindow.SetKinectOnePersonManualEngagement(null);
                                    this.pointer.Visible = Office.MsoTriState.msoFalse;
                                }
                            }
                        }
                        //*/

                        //Change la position du curseur en fonction de la position des mains
                        if (KinectCoreWindow.KinectManualEngagedHands.Count > 0 && point.Properties.IsEngaged && this.pointer != null)
                        {
                            PointF position = point.Properties.UnclampedPosition;
                            RectF  size     = new RectF {
                                X = 0, Y = 0, Width = this.Application.ActivePresentation.SlideMaster.Width, Height = this.Application.ActivePresentation.SlideMaster.Height
                            };


                            //This.pointer == null -> Problème de thread ? :/
                            this.pointer.Left    = Math.Min(Math.Max(position.X * size.Width, size.X), size.Width - this.pointer.Width);
                            this.pointer.Top     = Math.Min(Math.Max(position.Y * size.Height, size.Y), size.Height - this.pointer.Height);
                            this.pointer.Visible = Office.MsoTriState.msoTrue;
                        }

                        #endregion
                    }
                }
                #region méthode d'engagement "Dans l'écran"
                //On définit qui a l'autorité sur le pointeur (quelle main est engagée)
                //Celui dont la main est dans l'écran est engagé

                /*if(KinectCoreWindow.KinectManualEngagedHands.Count == 0) //Personne n'est engagé
                 * {
                 *  if(isInScreen(e.CurrentPoint.Properties.UnclampedPosition)) //Vérifie que le point est sur l'écran
                 *  {
                 *      KinectCoreWindow.SetKinectOnePersonManualEngagement(new BodyHandPair(e.CurrentPoint.Properties.BodyTrackingId, e.CurrentPoint.Properties.HandType));
                 *      Debug.WriteLine("Engagé");
                 *  }
                 * }
                 * else //Une personne est engagée
                 * {
                 *  //Vérifie si on doit désengager--
                 *
                 *  if(!isInScreen(e.CurrentPoint.Properties.UnclampedPosition) &&  // si le point est en dehors de l'écran et que
                 *      e.CurrentPoint.Properties.IsEngaged)                        // celui-ci est engagé
                 *  {
                 *      KinectCoreWindow.SetKinectOnePersonManualEngagement(null);
                 *      Debug.WriteLine("Désengagé");
                 *  }
                 * }*/

                #endregion
            }
        }
예제 #26
0
        /// <summary>
        /// Méthode déclenchée ~30 fois par seconde par Kinect. On y trouve les infos mise à jour relatives à la position des mains/curseur kinect
        /// </summary>
        /// <param name="sender">L'objet appelant</param>
        /// <param name="e">Les paramètres d'une frame de body</param>
        private void MainWindow_PointerMoved(object sender, KinectPointerEventArgs e)
        {
            #region Méthode d'engagement "Dans l'écran"
            //On définit qui a l'autorité sur le pointeur (quelle main est engagée)
            //Celui dont la main est dans l'écran est engagé
            if (KinectCoreWindow.KinectManualEngagedHands.Count == 0)        //Personne n'est engagé
            {
                if (IsInScreen(e.CurrentPoint.Properties.UnclampedPosition)) //Vérifie que le point est sur l'écran
                {
                    KinectCoreWindow.SetKinectOnePersonManualEngagement(new BodyHandPair(e.CurrentPoint.Properties.BodyTrackingId, e.CurrentPoint.Properties.HandType));
                    (this.Resources["CursorShow"] as Storyboard).Begin(); //On affiche le pointeur
                }
                else
                {
                    this.lastPoint = null;
                }
            }
            else //Une personne est engagée
            {
                //Vérifie si on doit désengager--

                if (!IsInScreen(e.CurrentPoint.Properties.UnclampedPosition, 0.2f) &&   // si le point est en dehors de l'écran (avec une tolérance de 0.2, on peut sortir un peu de l'écran et dessiner) et que
                    e.CurrentPoint.Properties.IsEngaged)                                // celui-ci est engagé
                {
                    KinectCoreWindow.SetKinectOnePersonManualEngagement(null);
                    this.lastPoint = null;
                    (this.Resources["CursorHide"] as Storyboard).Begin(); //On cache le pointeur
                }
            }

            #endregion

            KinectPointerPoint kinectPoint = e.CurrentPoint;

            if (kinectPoint.Properties.IsEngaged) //On ne peut dessiner que si le point est engagé
            {
                //Vérification Dessin - Choix de couleur
                switch (isPanelOpen)
                {
                case true:     //On doit choisir la couleur
                    Canvas.SetLeft(colorChoicePanel, kinectPoint.Position.X * colorChoicePanel.ActualWidth - colorChoicePanel.ActualWidth);
                    this.UsedBrush = this.colorBrushes[this.colorBrushes.Count - 1 - (int)Math.Floor(kinectPoint.Position.X * this.colorBrushes.Count)];
                    this.lastPoint = null;
                    break;

                case false:     //On doit dessiner

                    //Diamètre du cercle changeant avec la pression
                    double diameter = 30;
                    diameter = diameter * Math.Pow(kinectPoint.Properties.HandReachExtent + 0.5, 3);

                    //On modifie la position du curseur
                    double posX = Math.Max(e.CurrentPoint.Properties.UnclampedPosition.X, 0);
                    posX  = Math.Min(posX, 1);    // Position relative 0->1 compris
                    posX *= this.drawCanvas.ActualWidth;
                    posX -= diameter / 2;

                    double posY = Math.Max(e.CurrentPoint.Properties.UnclampedPosition.Y, 0);
                    posY  = Math.Min(posY, 1);    // Position relative 0->1 compris
                    posY *= this.drawCanvas.ActualHeight;
                    posY -= diameter / 2;


                    //On modifie le curseur
                    this.cursorInfo.PosX = posX;
                    this.cursorInfo.PosY = posY;

                    this.cursorInfo.Diameter = diameter;


                    #region Dessin


                    //Les deux possition à dessiner

                    if (kinectPoint.Properties.HandReachExtent > 0.5) // Plus que 50 cm de l'épaule
                    {
                        if (lastPoint != null)                        //On ne dessine une ligne que si on connait le dernier point
                        {
                            //Création d'une nouvelle ligne
                            Line line = new Line()
                            {
                                //Premier point à partir du dernier point
                                X1 = this.lastPoint.Value.X + diameter / 2,
                                Y1 = this.lastPoint.Value.Y + diameter / 2,
                                //Deuxième point à partir du point courant
                                X2 = posX + diameter / 2,
                                Y2 = posY + diameter / 2,

                                //Design de la ligne
                                StrokeThickness    = diameter,         //Largeur de la ligne
                                Stroke             = this.UsedBrush,   //La couleur de la ligne
                                StrokeStartLineCap = PenLineCap.Round, //Ligne dont les deux côtés sont rond
                                StrokeEndLineCap   = PenLineCap.Round
                            };

                            //Ajout de la ligne
                            drawCanvas.Children.Add(line);
                        }

                        //Update the last position
                        this.lastPoint = new Point(posX, posY);
                    }
                    else
                    {
                        //Si on est moins que 0.5cm, on met le dernier point à null pour ne plus dessiner
                        this.lastPoint = null;
                    }


                    #endregion     //----Dessin

                    break;
                }
            }
        }
        /// <summary>
        /// Handles kinect pointer events
        /// </summary>
        /// <param name="sender">the KinectCoreWindow</param>
        /// <param name="args">Kinect pointer args</param>
        private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
        {
            KinectPointerPoint kinectPointerPoint = args.CurrentPoint;
            if (lastTime == TimeSpan.Zero || lastTime != kinectPointerPoint.Properties.BodyTimeCounter)
            {
                lastTime = kinectPointerPoint.Properties.BodyTimeCounter;
                mainScreen.Children.Clear();
            }

            RenderPointer(kinectPointerPoint.Properties.IsEngaged,
                kinectPointerPoint.Position,
                kinectPointerPoint.Properties.UnclampedPosition,
                kinectPointerPoint.Properties.HandReachExtent,
                kinectPointerPoint.Properties.BodyTimeCounter,
                kinectPointerPoint.Properties.BodyTrackingId,
                kinectPointerPoint.Properties.HandType);
        }
예제 #28
0
 private void kinectCoreWindow_PointerMoved(object sender, KinectPointerEventArgs args)
 {
     KinectPointerPoint kinectPointerPoint = args.CurrentPoint;
     if (lastTime == TimeSpan.Zero || lastTime != kinectPointerPoint.Properties.BodyTimeCounter)
     {
         lastTime = kinectPointerPoint.Properties.BodyTimeCounter;
         pointerCanvas.Children.Clear();
     }
 }
예제 #29
0
 /// <summary>
 /// Page timer code to flip back to home if no one is using the board
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnKinectPointerEntered(object sender, KinectPointerEventArgs e)
 {
     isKinectActive = true;
     pageTimer.Stop();
 }