private float getScrollDistance(Frame frame, LastCircleGesture gesture)
    {
        float speed = gesture.circle.Radius / 2 * frame.Fingers.Count;

        if (speed < 10)
        {
            speed = 10;
        }

        float scroll_distance = (gesture.circle.Progress - lastCircleGesture.circle.Progress) * 10 * speed;

        // Make sure the distance isn't stupid - or too small
        if (scroll_distance > 100 || scroll_distance <= 1)
        {
            return(0);
        }

        // If it's clockwise we need the negative
        if (gesture.isClockwise)
        {
            scroll_distance = -scroll_distance;
        }

        return(scroll_distance);
    }
    private void handleScroll(Frame frame, CircleGesture circle)
    {
        int     speed       = scroll_speed;
        Boolean isClockwise = checkClockwise(circle);
        float   scroll_distance;

        LastCircleGesture newCircleGesture = new LastCircleGesture();

        newCircleGesture.circle      = circle;
        newCircleGesture.isClockwise = isClockwise;

        if (lastCircleGesture == null || isClockwise != lastCircleGesture.isClockwise || circle.Id != lastCircleGesture.circle.Id)
        {
            lastCircleGesture = newCircleGesture;
            return;
        }

        scroll_distance = getScrollDistance(frame, newCircleGesture);

        if (scroll_distance != 0)
        {
            if (circle.State != Leap.Gesture.GestureState.STATE_STOP)
            {
                mouse_event(MOUSEEVENTF_SCROLL, (uint)0, (uint)0, (uint)scroll_distance, (UIntPtr)0);
            }
        }

        lastCircleGesture = (circle.State == Leap.Gesture.GestureState.STATE_STOP) ? null : newCircleGesture;
    }
    private void handleScroll(Frame frame, CircleGesture circle)
    {
        int speed           = scroll_speed;
        Boolean isClockwise = checkClockwise(circle);
        float scroll_distance;

        LastCircleGesture newCircleGesture = new LastCircleGesture();

        newCircleGesture.circle      = circle;
        newCircleGesture.isClockwise = isClockwise;

        if (lastCircleGesture == null || isClockwise != lastCircleGesture.isClockwise || circle.Id != lastCircleGesture.circle.Id)
        {
            lastCircleGesture = newCircleGesture;
            return;
        }

        scroll_distance = getScrollDistance(frame, newCircleGesture);

        if (scroll_distance != 0)
        {
            if (circle.State != Leap.Gesture.GestureState.STATE_STOP)
            {
                mouse_event(MOUSEEVENTF_SCROLL, (uint)0, (uint)0, (uint)scroll_distance, (UIntPtr)0);
            }
        }

        lastCircleGesture = (circle.State == Leap.Gesture.GestureState.STATE_STOP) ? null : newCircleGesture;
    }
    private float getScrollDistance(Frame frame, LastCircleGesture gesture)
    {
        float speed = gesture.circle.Radius / 2 * frame.Fingers.Count;

        if (speed < 10) { speed = 10; }

        float scroll_distance = (gesture.circle.Progress - lastCircleGesture.circle.Progress) * 10 * speed;

        // Make sure the distance isn't stupid - or too small
        if (scroll_distance > 100 || scroll_distance <= 1)
        {
            return 0;
        }

        // If it's clockwise we need the negative
        if (gesture.isClockwise)
        {
            scroll_distance = -scroll_distance;
        }

        return scroll_distance;
    }