public bool KinectHandManagerDidDetectHandStateChange(KinectHandManager aManager, KinectHandManager.HandStateChangeEvent aEvent)
        {
            //holds whether we handled the event
            bool result = false;
            if (this.IsEnabledCore && this.IsVisible)
            {
                if (aEvent.EventType == KinectHandManager.HandStateChangeType.OpenToClose)
                {
                    if (this._kinectSpaceBounds.Contains(aEvent.HandPosition))
                    {
                        _clickBeganInside = true;
                        //event handled
                        result = true;

                        Dispatcher.InvokeAsync((Action)delegate()
                        {
                            //click the button
                            ButtonAutomationPeer peer = new ButtonAutomationPeer(this);
                            IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                            invokeProv.Invoke();
                        });
                    }
                    else
                    {
                        _clickBeganInside = false;
                    }
                }
                else if (aEvent.EventType == KinectHandManager.HandStateChangeType.CloseToOpen)
                {
                    if (_clickBeganInside && this._kinectSpaceBounds.Contains(aEvent.HandPosition))
                    {
                        //event handled
                        result = true;

                        /*
                        Dispatcher.InvokeAsync((Action)delegate()
                        {
                            //click the button
                            ButtonAutomationPeer peer = new ButtonAutomationPeer(this);
                            IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                            invokeProv.Invoke();
                        });
                         * */
                    }
                }
            }

            return result;
        }
        public bool KinectHandManagerDidDetectHandStateChange(KinectHandManager aManager, KinectHandManager.HandStateChangeEvent aEvent)
        {
            //holds whether we handled the event
            bool result = false;
            if (this.IsEnabledCore && this.IsVisible)
            {
                if (aEvent.EventType == KinectHandManager.HandStateChangeType.OpenToClose)
                {
                    if (this._kinectSpaceBounds.Contains(aEvent.HandPosition))
                    {
                        _clickBeganInside = true;
                        _hasScrolled = false;
                        _clickBeganPoint = aEvent.HandPosition;
                        //event handled
                        result = true;
                    }
                    else
                    {
                        _clickBeganInside = false;
                    }
                }
                else if (aEvent.EventType == KinectHandManager.HandStateChangeType.CloseToOpen)
                {
                    if (_clickBeganInside && this._kinectSpaceBounds.Contains(aEvent.HandPosition))
                    {
                        //event handled
                        result = true;

                        if (!_hasScrolled && Point.Subtract(aEvent.HandPosition, _clickBeganPoint).Length < MAX_CLICK_DELTA)
                        {
                            int mouseX = (int)(System.Windows.SystemParameters.PrimaryScreenWidth * aEvent.HandPosition.X / _kinectManager.HandManager.HandCoordRangeX);
                            int mouseY = (int)(System.Windows.SystemParameters.PrimaryScreenHeight * aEvent.HandPosition.Y / _kinectManager.HandManager.HandCoordRangeY);
                            Dispatcher.InvokeAsync((Action)delegate()
                            {
                                this.Click(mouseX, mouseY);
                            });
                        }
                    }

                    _clickBeganInside = false;
                    _hasScrolled = false;
                }
            }

            return result;
        }
Example #3
0
        public bool KinectHandManagerDidGetHandLocation(KinectHandManager aManager, KinectHandManager.HandLocationEvent aEvent)
        {
            bool result = false;

            Dispatcher.InvokeAsync((Action)delegate ()
            {
                HoverOverLocation(aEvent.HandPosition);
            });

            return result;
        }
Example #4
0
 public bool KinectHandManagerDidDetectHandStateChange(KinectHandManager aManager, KinectHandManager.HandStateChangeEvent aEvent)
 {
     bool result = false;
     return result;
 }
        public bool KinectHandManagerDidGetHandLocation(KinectHandManager aManager, KinectHandManager.HandLocationEvent aEvent)
        {
            bool result = false;

            if (this.IsEnabledCore && this.IsVisible)
            {
                if (this._kinectSpaceBounds.Contains(aEvent.HandPosition))
                {
                    //always move mouse so is under hand
                    int mouseX = (int)(System.Windows.SystemParameters.PrimaryScreenWidth * aEvent.HandPosition.X / _kinectManager.HandManager.HandCoordRangeX);
                    int mouseY = (int)(System.Windows.SystemParameters.PrimaryScreenHeight * aEvent.HandPosition.Y / _kinectManager.HandManager.HandCoordRangeY);
                    Dispatcher.InvokeAsync((Action)delegate()
                    {
                        MouseMoved(mouseX, mouseY);
                    });
                }

                if (_clickBeganInside)
                {
                    result = true;

                    if (!_hasScrolled && Point.Subtract(aEvent.HandPosition, _clickBeganPoint).Length >= MAX_CLICK_DELTA)
                    {
                        _hasScrolled = true;
                        _lastScrollPoint = aEvent.HandPosition;

                        Debug.WriteLine("Began scrolling");
                    }

                    if (_hasScrolled)
                    {
                        double xDistance = aEvent.HandPosition.X - _lastScrollPoint.X;
                        double yDistance = aEvent.HandPosition.Y - _lastScrollPoint.Y;

                        int wheelX = (int)(xDistance * SCROLL_SCALAR);
                        int wheelY = (int)(yDistance * SCROLL_SCALAR);

                        int mouseX = (int)(System.Windows.SystemParameters.PrimaryScreenWidth * aEvent.HandPosition.X / _kinectManager.HandManager.HandCoordRangeX);
                        int mouseY = (int)(System.Windows.SystemParameters.PrimaryScreenHeight * aEvent.HandPosition.Y / _kinectManager.HandManager.HandCoordRangeY);

                        Dispatcher.InvokeAsync((Action)delegate()
                        {
                            MouseWheel(mouseX, mouseY, wheelX, wheelY);
                        });
                        _lastScrollPoint = aEvent.HandPosition;

                        //Debug.WriteLine("X: " + wheelX + " Y: " + wheelY);
                    }

                }
            }

            return result;
        }
        public bool KinectHandManagerDidGetHandLocation(KinectHandManager aManager, KinectHandManager.HandLocationEvent aEvent)
        {
            bool result = false;

            if (this.IsEnabledCore && this.IsVisible)
            {
                if (this._attachBounds.Contains(aEvent.HandPosition))
                {
                    result = true;

                    //TODO - have some sort of mouse over animation
                }
                else
                {

                }
            }

            return result;
        }