Exemplo n.º 1
0
        // This event is needed for cases when user taps on a note and slides to another note
        private void WKey_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            // We get the current point and check if mouse/pointer is actually clicked
            // This prevents the keys from being registered as pressed when the mouse is simply hovering over the keys
            // The rest of the function is the same as BKey_PointerPressed
            var ptPt = e.GetCurrentPoint(WKey);

            if (ptPt.Properties.IsLeftButtonPressed)
            {
                KeyTapped?.Invoke(KeyPitch, null);
                e.Handled = true;
                PressKey();
            }
        }
Exemplo n.º 2
0
        private void handleKey(Keys key, int scancode, bool press)
        {
            var index = (int)key;
            var time  = (float)AppTime.Elapsed.TotalSeconds;

            // Update modifier state
            switch (key)
            {
            case Keys.LeftShift: _modMask.LeftShift = press; break;

            case Keys.LeftControl: _modMask.LeftControl = press; break;

            case Keys.LeftAlt: _modMask.LeftAlt = press; break;

            case Keys.RightShift: _modMask.RightShift = press; break;

            case Keys.RightControl: _modMask.RightControl = press; break;

            case Keys.RightAlt: _modMask.RightAlt = press; break;
            }

            // Update key state
            if (press)
            {
                _currKeys[index]  = true;
                _lastPress[index] = time;
                _pressed.Add(key);

                KeyPressed?.Invoke(this,
                                   new KeyEventData(KeyEventType.Pressed, key, ModifierMask, time - _lastRelease[index]));
            }
            else               // release
            {
                _currKeys[index]    = false;
                _lastRelease[index] = time;
                _pressed.Remove(key);
                float diff = time - _lastPress[index];

                KeyReleased?.Invoke(this,
                                    new KeyEventData(KeyEventType.Released, key, ModifierMask, diff));
                if (TapEventsEnabled && (diff <= TapTime))
                {
                    KeyTapped?.Invoke(this,
                                      new KeyEventData(KeyEventType.Tapped, key, ModifierMask, time - _lastTap[index]));
                    _lastTap[index] = time;
                }
            }
        }
Exemplo n.º 3
0
 // If key is tapped/clicked through the app, call the KeyTapped event so that the NoteOn is sent to the MIDI output
 // The key colour is also set here instead of through the main ControlMessageHelper class
 private void WKey_PointerPressed(object sender, PointerRoutedEventArgs e)
 {
     KeyTapped?.Invoke(KeyPitch, null);
     e.Handled = true;
     PressKey();
 }