public MainWindow() { Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; this.shuffleManager = new ShuffleManager(); this.player = new MusicPlayer(); this.player.StreamEnded += player_StreamEnded; InitializeComponent(); string playlistDir = Path.Combine(Path.GetDirectoryName(typeof(MainWindow).Assembly.Location), "data"); List<Playlist> playlists = new List<Playlist>(); foreach (var file in Directory.GetFiles(playlistDir, "*.bin")) { try { var playlist = Playlist.ReadFrom(file); playlists.Add(playlist); } catch (Exception e) { MessageBox.Show("Error reading playlist " + file + ": " + e.ToString()); } } var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); this.listPlaylists.ItemsSource = playlists; this.listPlaylists.SelectedIndex = 0; var rand = new Random(); var numbers = Enumerable.Range(0, 200).Select(i => rand.NextDouble()).ToArray(); this.LoadLevelBars(numbers); var timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(200); timer.Tick += timer_Tick; timer.Start(); }