Пример #1
0
        private void HandleInputDeviceInput(object o, PianoKeyStrokeEventArgs e)
        {
            if (_testActive)
            {
                if (e.KeyStrokeType == KeyStrokeType.KeyPress)
                {
                    int keyDifference = Math.Abs(_testKeyId - e.midiKeyId);

                    if (keyDifference == 0)
                    {
                        Result = "Nailed it - you're a hero";
                    }
                    else if (keyDifference % 12 == 0)
                    {
                        Result = "Hmm, try another octave";
                    }
                    else if (keyDifference > 11)
                    {
                        Result = "Seriously??! Do your ears even work?";
                    }
                    else if (keyDifference > 3)
                    {
                        Result = "Not bad, for a deaf beach boy";
                    }
                    else
                    {
                        Result = "Only marginally disappointing";
                    }

                    var worker = new BackgroundWorker();
                    worker.DoWork += (ob, arg) => { Thread.Sleep(1000); };

                    _keyboard.HandleIncomingMessage(null, new PianoKeyStrokeEventArgs(_testKeyId, KeyStrokeType.KeyPress, 100));

                    //I need to be a bit more careful here
                    //If this method is called again too quickly, the lift key event won't fire
                    worker.RunWorkerCompleted += (ob, arg) =>
                    {
                        _keyboard.HandleIncomingMessage(null, new PianoKeyStrokeEventArgs(_testKeyId, KeyStrokeType.KeyRelease, 100));
                        if (!_testActive)
                        {
                            Result = "...go again..";
                        }
                    };

                    worker.RunWorkerAsync();

                    TestActive = false;
                }
            }
        }
Пример #2
0
        private void Controller_SongNoteEvent(object sender, SongEventArgs e)
        {
            _logger.Log(this, LogLevel.Debug, "Score control handling song note event. " + e);

            _virtualKeyboard.HandleIncomingMessage(this, e.NoteKeyStrokeEvenArguments);
            _output.Send(this, e.NoteKeyStrokeEvenArguments);

            if (e.NoteKeyStrokeEvenArguments.KeyStrokeType != Common.Events.KeyStrokeType.KeyPress)
            {
                return;
            }

            //Only handle this once per chord
            if (e.NoteTime <= _lastNoteTime)
            {
                return;
            }

            //update speed once per bar
            if (e.NoteTime > nextBarDetails.NoteTime)
            {
                _lastNoteTime  = nextBarDetails.NoteTime;
                nextBarDetails = _scoreParser.GetNextBarDetails(e.NoteTime);
                SetScrollSpeed(nextBarDetails.XCoord, _lastNoteTime, nextBarDetails.NoteTime);
            }

            _logger.Log(this, LogLevel.Debug, "Score control finished handling song note event. " + e);
        }
Пример #3
0
        private void HandlePlayerMessage(object o, ChannelMessageEventArgs e)
        {
            var pianoEventArgs = SanfordUtils.ConvertChannelMessageToKeyStrokeEventArgs(e.Message);

            if (_output != null)
            {
                _output.Send(this, pianoEventArgs);
            }
            if (_virtualKeyboard != null)
            {
                _virtualKeyboard.HandleIncomingMessage(o, pianoEventArgs);
            }
        }