Beispiel #1
0
        private void DgrPlaylist_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            DgrPlaylist.Columns["FilePath"].Visible = false;
            DgrPlaylist.AutoResizeColumns();

            ResizeWindow();
        }
Beispiel #2
0
        private void BtnDeleteFile_Click(object sender, EventArgs e)
        {
            List <Song> deleteList = new List <Song>();

            foreach (DataGridViewRow row in DgrPlaylist.SelectedRows)
            {
                deleteList.Add(row.DataBoundItem as Song);
            }

            foreach (var song in deleteList)
            {
                Playlist.RemoveSong(song);
            }

            DgrPlaylist.DataSource = null;
            DgrPlaylist.DataSource = Playlist.SongList;
            DgrPlaylist.ClearSelection();
        }
 private void ResetPlayList()
 {
     WindowsMediaPlayer.controls.stop();
     DgrPlaylist.ClearSelection();
     if (DgrPlaylist.Rows.Count > 0)
     {
         DgrPlaylist.Rows[0].Selected = true;
     }
     BtnPlay.Text = PlayText[0];
     if (Playlist.SongList.Count > 0)
     {
         CurrentSong = Playlist.SongList[0];
     }
     else
     {
         CurrentSong = null;
     }
     SetSongInfo();
     InitShuffleIndex();
     if (ChkShuffle.Checked)
     {
         MakeShuffleIndex();
     }
 }
        private void RefreshList()
        {
            SortMethod method = (SortMethod)ComboSortPlaylist.SelectedIndex;

            List <Song> songList   = DgrPlaylist.DataSource as List <Song>;
            List <Song> sortedList = new List <Song>();

            switch (method)
            {
            case SortMethod.Default:
                sortedList.AddRange(songList);
                break;

            case SortMethod.DefaultReverse:
                sortedList.AddRange(songList);
                sortedList.Reverse();
                break;

            case SortMethod.Album:
                sortedList.AddRange(from s in songList orderby s.Album ascending select s);
                break;

            case SortMethod.AlbumReverse:
                sortedList.AddRange(from s in songList orderby s.Album descending select s);
                break;

            case SortMethod.Artist:
                sortedList.AddRange(from s in songList orderby s.Artist ascending select s);
                break;

            case SortMethod.ArtistReverse:
                sortedList.AddRange(from s in songList orderby s.Artist descending select s);
                break;

            case SortMethod.Song:
                sortedList.AddRange(from s in songList orderby s.Title ascending select s);
                break;

            case SortMethod.SongReverse:
                sortedList.AddRange(from s in songList orderby s.Title descending select s);
                break;

            default:
                break;
            }

            DgrPlaylist.DataSource = null;
            DgrPlaylist.DataSource = sortedList;

            DgrPlaylist.ClearSelection();
            foreach (DataGridViewRow s in DgrPlaylist.Rows)
            {
                var song = s.DataBoundItem as Song;
                if (song == CurrentSong)
                {
                    s.Selected = true;
                }
            }

            InitShuffleIndex();
            if (ChkShuffle.Checked)
            {
                MakeShuffleIndex();
            }
        }
        private bool MoveSelection(int movement)
        {
            int nextIndex;

            if (ChkShuffle.Checked)
            {
                CurrentShuffleIndexPlaying += movement;
                if (CurrentShuffleIndexPlaying < 0)
                {
                    if (ChkRepeatMode.Checked && RadioRepeatAll.Checked)
                    {
                        CurrentShuffleIndexPlaying = ShuffleIndex.Length - 1;
                    }
                    else
                    {
                        return(false);
                    }
                }
                if (CurrentShuffleIndexPlaying > ShuffleIndex.Length - 1)
                {
                    if (ChkRepeatMode.Checked && RadioRepeatAll.Checked)
                    {
                        CurrentShuffleIndexPlaying = 0;
                    }
                    else
                    {
                        return(false);
                    }
                }
                nextIndex = ShuffleIndex[CurrentShuffleIndexPlaying];
            }
            else
            {
                if (DgrPlaylist.SelectedRows.Count > 0)
                {
                    nextIndex = DgrPlaylist.SelectedRows[0].Index + movement;
                }
                else
                {
                    nextIndex = 0;
                }
            }

            if (nextIndex < 0)
            {
                if (ChkRepeatMode.Checked && RadioRepeatAll.Checked)
                {
                    nextIndex = DgrPlaylist.Rows.Count - 1;
                }
                else
                {
                    return(false);
                }
            }
            if (nextIndex > DgrPlaylist.Rows.Count - 1)
            {
                if (ChkRepeatMode.Checked && RadioRepeatAll.Checked)
                {
                    nextIndex = 0;
                }
                else
                {
                    return(false);
                }
            }

            DgrPlaylist.ClearSelection();
            DgrPlaylist.Rows[nextIndex].Selected = true;
            return(true);
        }