예제 #1
0
        public double GetMouseToKeyboardTransitionCost(KeyDownEvent keyDownEvent)
        {
            PhysicalKey key = FindKey(keyDownEvent.Data);

            if (key != null)
            {
                KeyboardSection parentSection = key.ParentSection;
                if (parentSection.Handedness == Handedness.Right)
                {
                    lastMouseHandedAction = ActionType.Keyboard;
                    if (MousePad == null)
                    {
                        throw new Exception("MousePad not specified.");
                    }
                    if (mousePadCenter.X == double.MinValue)
                    {
                        CalculateMousePadCenterPoint();
                    }

                    double travelDistance      = MillerComplexity.GetDistance(parentSection.Center, mousePadCenter);
                    double targetApproachWidth = MillerComplexity.GetTargetApproachWidth(key.Size.Width, key.Size.Height);
                    return(MillerComplexity.GetTargetPressScore(travelDistance, targetApproachWidth));
                }
            }
            return(0);
        }
예제 #2
0
        public double GetReachingForMouseTransitionCost()
        {
            if (MousePad == null)
            {
                throw new Exception("MousePad not specified.");
            }
            if (mousePadCenter.X == double.MinValue)
            {
                CalculateMousePadCenterPoint();
            }
            if (MousePad.Mouse == null)
            {
                throw new Exception("Mouse not specified.");
            }

            KeyboardSection nearestSection = GetLastTouchedSectionClosestToMouse();

            if (nearestSection == null)
            {
                throw new Exception("A keyboard section near the mouse was not found.");
            }

            double travelDistance      = MillerComplexity.GetDistance(nearestSection.Center, mousePadCenter);
            double targetApproachWidth = MousePad.Mouse.Width; // Mouse is nearly always approached from the left or right;

            lastMouseHandedAction = ActionType.Mouse;
            return(MillerComplexity.GetTargetPressScore(travelDistance, targetApproachWidth));
        }