Пример #1
0
        private void LoadMusicEvent(object sender, LoadMusicEventArgs e)
        {
            switch (e.EventType)
            {
                case EventType.TaskComplete:
                    switch (e.Details)
                    {
                        case LoadMusicTask.Mp3:
                            _mp3Done = true;
                            break;

                        case LoadMusicTask.Wma:
                            _wmaDone = true;
                            break;

                        default:
                            throw new InvalidEnumArgumentException("Invalid music task: " + e.Details);
                    }
                    Busy = !(_mp3Done && _wmaDone);
                    if (!Busy) CurrentDirectory = string.Empty;
                    Console.Out.WriteLine("Busy = {0}", Busy);
                    break;

                case EventType.ReadingDirectory:
                    CurrentDirectory = e.Details;
                    break;

                case EventType.AddTrack:
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        lock (_lockObject)
                        {
                            MusicCollection.Add(e.Track);
                        }
                    });
                    break;
            }
        }
Пример #2
0
 protected virtual void OnLoadMusicEvent(LoadMusicEventArgs e)
 {
     var handler = LoadMusicEvent;
     if (handler != null) handler(this, e);
 }