示例#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);
        }
示例#2
0
        /// <summary>
        /// Called to update where we listen for grip.
        /// </summary>
        internal void ListenForGrip()
        {
            if (this.gripEventTarget != null)
            {
                KinectRegion.RemoveHandPointerGripHandler(this.gripEventTarget, this.OnHandPointerGrip);
                KinectRegion.SetIsGripTarget(this, false);

                BindingOperations.ClearBinding(this, IsPrimaryHandPointerOverProperty);

                this.gripEventTarget.IsEnabledChanged -= this.OnStateChangeEvent;
                this.gripEventTarget.MouseEnter       -= this.OnMouseChange;
                this.gripEventTarget.MouseLeave       -= this.OnMouseChange;

                this.gripEventTarget = null;
            }

            this.sliderParent = FindAncestor <KinectSlider>(this);

            if (this.sliderParent == null)
            {
                this.gripEventTarget = this;
            }
            else if (this.sliderParent.GripEventTarget != null)
            {
                this.gripEventTarget = this.sliderParent.GripEventTarget;
            }
            else
            {
                this.gripEventTarget = this.sliderParent;
            }

            var binding = new Binding {
                Source = this.gripEventTarget, Path = new PropertyPath(KinectRegion.IsPrimaryHandPointerOverProperty)
            };

            BindingOperations.SetBinding(this, IsPrimaryHandPointerOverProperty, binding);

            this.gripEventTarget.IsEnabledChanged += this.OnStateChangeEvent;
            this.gripEventTarget.MouseEnter       += this.OnMouseChange;
            this.gripEventTarget.MouseLeave       += this.OnMouseChange;

            KinectRegion.AddHandPointerGripHandler(this.gripEventTarget, this.OnHandPointerGrip);
            KinectRegion.SetIsGripTarget(this.gripEventTarget, 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();
        }
示例#4
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;
        }