public MainWindowViewModel(IMusicPlayer m, SongCollection collection) { if (DesignerProperties.GetIsInDesignMode( new System.Windows.DependencyObject())) { return; } _seconds = 0; _playingSong = new Song(); QueueInfo = ""; _player = m; ElapsedTime = "00:00 / 00:00"; _incrementPlayingProgress = new Timer(); _incrementPlayingProgress.Interval = 1000; _currentQueue = collection; _incrementPlayingProgress.Elapsed += (sender, e) => { _seconds += 1000; PlayingProgress += 1000; string displayProgress = TimeSpan.FromMilliseconds(_seconds).ToString("mm\\:ss"); ElapsedTime = displayProgress + " / " + PlayingSong.DisplayDuration; }; _findSongEnd = new Timer(); _findSongEnd.Interval = 1; _findSongEnd.Elapsed += (sender, e) => { Application.Current.Dispatcher.Invoke(() => { if (_player.IsDone()) { Debug.WriteLine("Done"); if (++_playingIndex < _currentQueue.SongList.Count) { SelectedSong = _currentQueue.SongList[_playingIndex]; PlaySongAction(); } else { StopSongAction(); } } }); }; AddToQueueCommand = new CommandHandler(() => AddToQueueAction(), () => true); ClearQueueCommand = new CommandHandler(() => ClearQueueAction(), () => true); PlaySong = new CommandHandler(() => PlaySongAction(), () => true); PauseSong = new CommandHandler(() => PauseSongAction(), () => true); StopSong = new CommandHandler(() => StopSongAction(), () => true); FastForwardCommand = new CommandHandler(() => FastForwardAction(), () => true); RewindCommand = new CommandHandler(() => RewindAction(), () => true); }