/// <summary>
        ///     Gets the index of the current track.
        /// </summary>
        /// <returns>The index of the current track.</returns>
        public int GetCurrentTrackIndex()
        {
            var currentTrack = TrackModels.FirstOrDefault(t => t.IsCurrent);

            if (currentTrack == null)
            {
                return(GetCurrentTrackIndexFromBassPlayer());
            }

            var currentBassTrackDescription = BassPlayer.CurrentTrack == null
                ? ""
                : BassPlayer.CurrentTrack.Description;

            if (currentBassTrackDescription == currentTrack.Description)
            {
                return(TrackModels.IndexOf(currentTrack));
            }

            var currentIndex = TrackModels.IndexOf(currentTrack);
            var match        = TrackModels
                               .FirstOrDefault(t => t.Description == currentBassTrackDescription &&
                                               TrackModels.IndexOf(t) >= currentIndex);

            if (match == null)
            {
                return(GetCurrentTrackIndexFromBassPlayer());
            }

            currentTrack.IsCurrent = false;
            match.IsCurrent        = true;

            return(TrackModels.IndexOf(match));
        }
        private void mnuTrackRank_Click(object sender, EventArgs e)
        {
            var toolStripDropDownItem = sender as ToolStripDropDownItem;

            if (toolStripDropDownItem == null)
            {
                return;
            }

            var trackRankDescription = toolStripDropDownItem.Text;
            var trackRank            = MixLibrary.GetRankFromDescription(trackRankDescription);

            var tracks = GetSelectedLibraryTracks();

            Library.SetRank(tracks, (int)trackRank);

            foreach (var track in tracks)
            {
                var trackModel = TrackModels.FirstOrDefault(t => t.Description == track.Description);
                if (trackModel == null)
                {
                    continue;
                }
                trackModel.TrackRankDescription = trackRankDescription;
            }

            //BindData();
            grdPlaylist.InvalidateDisplayedRows();
        }
        private int GetCurrentTrackIndexFromBassPlayer()
        {
            if (BassPlayer.CurrentTrack == null)
            {
                if (TrackModels.Count <= 0)
                {
                    return(-1);
                }
                TrackModels[0].IsCurrent = true;
                return(0);
            }
            var currentTrack = TrackModels.FirstOrDefault(t => t.Description == BassPlayer.CurrentTrack.Description);

            if (currentTrack == null)
            {
                return(-1);
            }
            currentTrack.IsCurrent = true;
            return(TrackModels.IndexOf(currentTrack));
        }