Exemplo n.º 1
0
        private void onHasGazeChanged(object sender, RoutedEventArgs e)
        {
            object      source = e.Source;
            AbstractKey aKey   = source as AbstractKey;

            if (timer != null && timer.isRunning)
            {
                // If first initialization or timer is already running
                // Stop it and refresh key, because we moving to a new one
                // Stopping timer and reseting highlight
                timer.Stop();
                aKey.resetHighlight();
            }
            else
            {
                // If timer is not running
                // Just run it
                timer            = new Timer((int)Application.Current.Resources["Threshold"], 100, true);
                timer.OnElapsed += delegate() {
                    captureKey(source);
                    aKey.resetHighlight();
                };
                timer.OnTick += delegate(double ratio) {
                    aKey.progressHighlight(ratio);
                };
                timer.Start();
            }
            // And anyway toggle key
            toggleKey(source);
        }
Exemplo n.º 2
0
        // Only use with eye tracking!!!
        private void toggleKey(object source)
        {
            // Basically we switch state for general keys
            // And for shift and caps only if they are not already toggled
            switch (keyTypes[source.GetType()])
            {
            case 3:
            case 4:
                // Shifts
                if (!isShiftPressed)
                {
                    leftShift.toggle();
                }
                break;

            case 7:
                // Caps
                if (!isCapsLockPressed)
                {
                    capsLock.toggle();
                }
                break;

            default:
                // All others
                AbstractKey key = source as AbstractKey;
                key.toggle();
                break;
            }
        }
Exemplo n.º 3
0
        private void onMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (timer != null)
            {
                timer.Stop();
            }
            AbstractKey aKey = e.Source as AbstractKey;

            aKey.resetHighlight();
        }
Exemplo n.º 4
0
        private void onMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            timer = new Timer((int)Application.Current.Resources["Threshold"], 10, true);
            object      source = e.Source;
            AbstractKey aKey   = source as AbstractKey;

            timer.OnElapsed += delegate() {
                captureKey(source);
                aKey.resetHighlight();
            };
            timer.OnTick += delegate(double ratio) {
                aKey.progressHighlight(ratio);
            };
            timer.Start();
        }