Esempio n. 1
0
        /// <summary>
        /// Called to initialize the control when we are not in design mode.
        /// </summary>
        private void InitializeKinectThumb()
        {
            KinectRegion.AddHandPointerGotCaptureHandler(this, this.OnHandPointerCaptured);
            KinectRegion.AddQueryInteractionStatusHandler(this, this.OnQueryInteractionStatus);
            KinectRegion.AddHandPointerMoveHandler(this, this.OnHandPointerMove);
            KinectRegion.AddHandPointerGripReleaseHandler(this, this.OnHandPointerGripRelease);
            KinectRegion.AddHandPointerLostCaptureHandler(this, this.OnHandPointerLostCapture);

            KinectRegion.SetIsGripTarget(this, true);
        }
Esempio n. 2
0
        void KinectSensor_KinectChanged(object sender, KinectChangedEventArgs e)
        {
            bool error = true;

            if (e.OldSensor == null)
            {
                try
                {
                    e.OldSensor.DepthStream.Disable();
                    e.OldSensor.SkeletonStream.Disable();
                }
                catch (Exception)
                {
                    error = true;
                }
            }

            if (e.NewSensor == null)
            {
                return;
            }

            try
            {
                Kinect = e.NewSensor;
                e.NewSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
                e.NewSensor.SkeletonStream.Enable();
                e.NewSensor.SkeletonFrameReady += KinectSensor_SkeletonFrameReady;


                try
                {
                    e.NewSensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
                    e.NewSensor.DepthStream.Range           = DepthRange.Near;
                    e.NewSensor.SkeletonStream.EnableTrackingInNearRange = true;
                }
                catch (InvalidOperationException)
                {
                    e.NewSensor.DepthStream.Range = DepthRange.Default;
                    e.NewSensor.SkeletonStream.EnableTrackingInNearRange = false;
                }
            }
            catch (InvalidOperationException)
            {
                error = true;
            }

            ZonaCursor.KinectSensor = e.NewSensor;
            KinectRegion.AddHandPointerGripHandler(this.ZonaCursor, this.OnHandGripHandler);
            KinectRegion.AddHandPointerGripReleaseHandler(this.ZonaCursor, this.OngRripReleaseHandler);
            KinectRegion.AddHandPointerMoveHandler(this.ZonaCursor, this.OnMoveHandler);
            KinectRegion.AddHandPointerPressHandler(this.ZonaCursor, this.OnPressHandler);
            KinectRegion.AddHandPointerPressReleaseHandler(this.ZonaCursor, this.OnPressRelaaseHandler);
        }
Esempio n. 3
0
        private void InitializeKinectButtonBase()
        {
            KinectRegion.AddHandPointerEnterHandler(this, this.OnHandPointerEnter);
            KinectRegion.AddHandPointerMoveHandler(this, this.OnHandPointerMove);

            KinectRegion.AddHandPointerGotCaptureHandler(this, this.OnHandPointerCaptured);
            KinectRegion.AddHandPointerLostCaptureHandler(this, this.OnHandPointerLostCapture);


            KinectRegion.AddHandPointerGripHandler(this, this.OnHandPointerGrip);
            KinectRegion.AddHandPointerGripReleaseHandler(this, this.OnHandPointerGripRelease);
            KinectRegion.AddQueryInteractionStatusHandler(this, this.OnQueryInteractionStatus);
        }
Esempio n. 4
0
        public DragDropElement()
        {
            lastGripState = GripState.Released;

            kinectRegionBinder = new KinectRegionBinder(this);
            kinectRegionBinder.OnKinectRegionChanged += OnKinectRegionChanged;

            KinectRegion.AddHandPointerEnterHandler(this, OnHandPointerEnter);
            KinectRegion.AddHandPointerMoveHandler(this, OnHandPointerMove);
            KinectRegion.AddHandPointerGotCaptureHandler(this, OnHandPointerCaptured);
            KinectRegion.AddHandPointerLostCaptureHandler(this, OnHandPointerLostCapture);
            KinectRegion.AddHandPointerGripHandler(this, OnHandPointerGrip);
            KinectRegion.AddHandPointerGripReleaseHandler(this, OnHandPointerGripRelease);
            KinectRegion.AddQueryInteractionStatusHandler(this, OnQueryInteractionStatus);
        }
Esempio n. 5
0
        private void OnHandPointerGrip(object sender, HandPointerEventArgs handPointerEventArgs)
        {
            var button = sender as KinectCircleButton;

            if (handPointerEventArgs.HandPointer.IsInGripInteraction == true)
            {
                int buttonContent;
                GripOverButton = true;
                KinectRegion.AddQueryInteractionStatusHandler(kinectRegion, OnQuery);
                KinectRegion.AddHandPointerGripReleaseHandler(kinectRegion, OnHandPointerGripRelase);

                var Tree = button.Parent as Canvas;
                Tree.Children.Remove(button);
                buttonContent = (int)button.Content;
                GripApple     = myApple[buttonContent];
                Tree.Children.Remove(myApple[buttonContent].Figure);
                Treenum = GripApple.TreeNumber;
                handPointerEventArgs.Handled = true;
            }
        }
        /// <summary>
        /// Constructor. Creates a new DEEPKinectObject and binds it to an existing
        /// Shape object that is on the GUI.
        /// </summary>
        /// <param name="onScreenShape">The Shape that is on the GUI. We need this to bind the
        /// DEEPKinectObject to the shape on the screen.</param>
        /// <param name="isGrippable">Indicates whether the user can grip this object using a Kinect hand pointer.</param>
        /// <param name="isPressable">Indicates whether the user can press this object using a Kinect hand pointer.</param>
        public DEEPKinectObjectBaseClass(System.Windows.Shapes.Ellipse onScreenShape,
                                         UIElement backGroundRectangle,
                                         bool isGrippable,
                                         bool isPressable)
        {
            //Get a reference to the on-screen shape, so we can manipulate it later.
            this.onScreenShape = onScreenShape;

            /* Also get a starting location for the physical simulation. */
            this.onScreenShapePosition.X = onScreenShape.Margin.Left;
            this.onScreenShapePosition.Y = onScreenShape.Margin.Top;

            //Make sure the onscreen shape is grippable and touchable if the caller desires it.
            KinectRegion.SetIsGripTarget(onScreenShape, isGrippable);
            KinectRegion.SetIsPressTarget(onScreenShape, isPressable);

            //Add handlers so that we can do things when the shape is touched or gripped on screen.
            if (isGrippable)
            {
                KinectRegion.AddHandPointerGripHandler(onScreenShape, OnGripHandler);
                KinectRegion.AddHandPointerGripReleaseHandler(onScreenShape, OnGripReleaseHandler);
                KinectRegion.AddHandPointerGripReleaseHandler(backGroundRectangle, OnGripReleaseHandler);
            }
            if (isPressable)
            {
                KinectRegion.AddHandPointerPressHandler(onScreenShape, OnPressHandler);
                KinectRegion.AddHandPointerPressReleaseHandler(onScreenShape, OnPressReleaseHandler);
            }

            KinectRegion.AddHandPointerMoveHandler(backGroundRectangle, OnHandPointerMoveHandler);
            KinectRegion.AddHandPointerMoveHandler(onScreenShape, OnHandPointerMoveHandler);

            //Here, we initialize the animationTimer, which we will later use for effects.
            internalTimer          = new System.Timers.Timer(internalRefreshRate * 1000d);
            internalTimer.Elapsed += InternalTimer_Elapsed;
            internalTimer.Start();
        }
Esempio n. 7
0
        public void RegisterCallbackToSensor(KinectSensor sensor)
        {
            if (isRegisterAllFrameReady)
            {
                sensor.AllFramesReady += sensor_AllFramesReady;
            }
            else
            {
                sensor.SkeletonFrameReady += sensor_SkeletonFrameReady;
                sensor.DepthFrameReady    += sensor_DepthFrameReady;
                sensor.ColorFrameReady    += sensor_ColorFrameReady;
            }

            KinectRegion.AddHandPointerGotCaptureHandler(element, this.OnHandPointerCaptured);
            KinectRegion.AddHandPointerLostCaptureHandler(element, this.OnHandPointerLostCapture);
            KinectRegion.AddHandPointerEnterHandler(element, this.OnHandPointerEnter);
            KinectRegion.AddHandPointerMoveHandler(element, this.OnHandPointerMove);
            KinectRegion.AddHandPointerPressHandler(element, this.OnHandPointerPress);
            KinectRegion.AddHandPointerGripHandler(element, this.OnHandPointerGrip);
            KinectRegion.AddHandPointerGripReleaseHandler(element, this._onHandPointerGripRelease);
            KinectRegion.AddQueryInteractionStatusHandler(element, this.OnQueryInteractionStatus);
            KinectRegion.SetIsGripTarget(element, true);
            KinectState.Instance.KinectRegion.HandPointersUpdated += KinectRegion_HandPointersUpdated;
        }