Beispiel #1
0
        void UpdateUI(object sender, EventArgs e)
        {
            if (!System.Threading.Monitor.TryEnter(timerLock))
            {
                return;
            }
            try
            {
                if (stopUI)
                {
                    Stop(null, null);
                    stopUI = false;
                    return;
                }
                ClearPianoNotes();
                var info = trackInfo.Info;
                SongPlayer.GetSongState(info);
                for (int i = SongPlayer.NumTracks - 1; i >= 0; i--)
                {
                    if (!PianoTracks[i])
                    {
                        continue;
                    }

                    var notes = info.Notes[i];
                    pianoNotes.AddRange(notes);
                    foreach (var n in notes)
                    {
                        if (n >= piano.LowNoteID && n <= piano.HighNoteID)
                        {
                            piano[n - piano.LowNoteID].NoteOnColor = Config.Colors[info.Voices[i]];
                            piano.PressPianoKey(n);
                        }
                    }
                }
                if (!drag)
                {
                    UpdateSongPosition((int)info.Position);
                }
                trackInfo.Invalidate();
            }
            finally
            {
                System.Threading.Monitor.Exit(timerLock);
            }
        }