/// <summary> /// Handle an Incoming Song Request Event /// </summary> /// <param name="songEvt">The event</param> private void SongRequeustListener(SongRequestEvent songEvt) { if (songEvt.Type == SongRequestEvent.REQUEST_TYPE.Next) { SelectedIndex++; } else if (songEvt.Type == SongRequestEvent.REQUEST_TYPE.Previous) { SelectedIndex--; } if (mCurrentIndex < 0) { SelectedIndex = FilteredCollection.Count - 1; } else if (mCurrentIndex >= FilteredCollection.Count) { SelectedIndex = 0; } //Get the Current Model. SongViewModel model = mSongs[SelectedIndex]; //Then fire an event to the listeners to indicate that the Currently selected song has changed. if (model != null) { SendSongChangeEvent(model); } }
/// <summary> /// Push A Song Changed event onto the Event Aggregator. /// </summary> /// <param name="view">The View model containing the song we want to listetn to.</param> private void SendSongChangeEvent(SongViewModel view) { //First get where this lies in our filtered collection. mSelectedSong = view; SelectedIndex = mSongs.IndexOf(view); EventAggregator.EventAggregator.Instance.RaiseEvent <SongChangeEvent>(new SongChangeEvent(view.Song)); }