Kinect Toolkit control animate button on Hover Button?

Mar 24, 2014 at 1:45 PM
I have created a HoverButton and trying to animate the HandPointer on hover of a button. To animate I am using PressExtent property and changing the value from 0 to 1. But this is not animating anything. How can I pragmatically animate button like pressed effect. As shown in the snapshot. Following is the code I have written: ButtonHover.cs

Image
        private HandPointer activeHandpointer;

        public KinectHoverButton()
        {
            if (!IsInDesignMode)
            {
                this.InitializeKinectHoverButton();
                this.repeatTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds((ButtonRepeatIntervalMilliseconds / ClickInterval)) };
                this.repeatTimer.Tick += this.RepeatTimerTick;
            }
        }

        /// <summary>
        /// Boolean value that returns true if a mouse or hand pointer is over this button
        /// </summary>
        public bool IsHandPointerOver
        {
            get
            {
                return (bool)this.GetValue(IsHandPointerOverProperty);
            }

            set
            {
                this.SetValue(IsHandPointerOverProperty, value);
            }
        }

        //protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
        //{
        //    base.OnMouseEnter(e);
        //    this.IsHandPointerOver = true;
        //    this.repeatTimer.Start();
        //}

        //protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
        //{
        //    base.OnMouseLeave(e);
        //    this.IsHandPointerOver = false;
        //    this.repeatTimer.Stop();
        //}

        private void InitializeKinectHoverButton()
        {
            KinectRegion.AddHandPointerEnterHandler(this, this.OnHandPointerEnter);
            KinectRegion.AddHandPointerLeaveHandler(this, this.OnHandPointerLeave);
        }

        private void RepeatTimerTick(object sender, EventArgs e)
        {
            if (this.IntervalCount < this.ClickInterval)
            {
                this.IntervalCount++;
                this.activeHandpointer.PressExtent = IntervalCount / ClickInterval;
            }
            else
            {
                 this.OnClick();
            }

        }

        private void OnHandPointerEnter(object sender, HandPointerEventArgs e)
        {
            if (!e.HandPointer.IsPrimaryHandOfUser || !e.HandPointer.IsPrimaryUser)
            {
                return;
            }

            this.activeHandpointer = e.HandPointer;

            this.IsHandPointerOver = true;
            this.IntervalCount = 0;
            this.repeatTimer.Start();
        }

        private void OnHandPointerLeave(object sender, HandPointerEventArgs e)
        {
            if (this.activeHandpointer != e.HandPointer)
            {
                return;
            }

            this.activeHandpointer = null;

            this.IntervalCount = 0;
            this.IsHandPointerOver = false;
            this.repeatTimer.Stop();
        }
    }
Mar 24, 2014 at 9:55 PM
for that, why not just use the Kinect Toolkit controls?
Mar 25, 2014 at 5:51 AM
In toolkit there is no Hover button hence i created a control inheriting toolkit KinectTileButton and added a timer on tick of which I have fired the click event. Now I want to show the progress on Hand Pointer when it is over hover button just like when you click a tile button. How can i achieve this. I tried to capture the Hand Pointer with OnHandPointerEnter event and increased the value of this.activeHandpointer.PressExtent from 0 to 1. But that is not showing any animation. How can i achieve this?