public void CreateTable()
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Path");
            dataTable.Columns.Add("File");
            dataTable.Columns.Add("Title");
            dataTable.Columns.Add("#");
            dataTable.Columns.Add("Album");
            dataTable.Columns.Add("Artist");
            dataTable.Columns.Add("Year");
            dataTable.Columns.Add("Length");

            foreach (string songPath in songPaths)
            {
                if (String.IsNullOrWhiteSpace(songPath))
                {
                    continue;
                }

                FileInfo fileInfo = new FileInfo(songPath);
                SongTag  songTag  = new SongTag(songPath);

                dataTable.Rows.Add(
                    fileInfo.FullName,
                    fileInfo.Name,
                    songTag.Title,
                    songTag.Track,
                    songTag.Album,
                    songTag.Artist,
                    songTag.Year,
                    songTag.Length);
            }


            DataGridView.DataSource = dataTable;
            DataGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            DataGridView.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
            DataGridView.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;

            DataGridView.Sort(DataGridView.Columns[1], ListSortDirection.Ascending);
            DataGridView.Columns[0].Visible = false;
        }
예제 #2
0
        public ConfigTagsForm(MusicPlayerForm musicPlayer, FileInfo fileInfo)
        {
            InitializeComponent();

            ThemeManager.AddThemableForm(this);
            ApplyTheme();

            this.MusicPlayer = musicPlayer;
            this.FileInfo    = fileInfo;

            NameLabel.Text = fileInfo.Name;

            SongTag            = new SongTag(fileInfo.FullName);
            TitleTextBox.Text  = SongTag.Title;
            TrackTextBox.Text  = SongTag.Track;
            AlbumTextBox.Text  = SongTag.Album;
            ArtistTextBox.Text = SongTag.Artist;
            YearTextBox.Text   = SongTag.Year;
            AlbumBox.Image     = SongTag.Art ?? Properties.Resources.album_art;
        }
예제 #3
0
        public void AddPlaylistSongs(string playlistName, List <string> songPaths)
        {
            string totalPath     = playlistPath + playlistName + ".wzmp";
            string selectedSongs = File.ReadAllText(totalPath);

            string[] addedSongs = songPaths.Where(path => !selectedSongs.Contains(path)).Select(path => path + "\n").ToArray();

            bool append = !String.IsNullOrWhiteSpace(ReadConfig(totalPath).Replace("\n", ""));

            using (StreamWriter streamWriter = new StreamWriter(totalPath, append))
            {
                streamWriter.WriteLine(String.Join("", addedSongs));
            }

            DataTable dataTable = (DataTable)playlistViewMap[playlistName].DataSource;

            foreach (string songPath in addedSongs)
            {
                FileInfo fileInfo = new FileInfo(songPath.Replace("\n", ""));
                SongTag  songTag  = new SongTag(songPath.Replace("\n", ""));

                dataTable.Rows.Add(
                    fileInfo.FullName,
                    fileInfo.Name,
                    songTag.Title,
                    songTag.Track,
                    songTag.Album,
                    songTag.Artist,
                    songTag.Year,
                    songTag.Length);
            }

            playlistViewMap[playlistName].Sort(playlistViewMap[playlistName].Columns[1], ListSortDirection.Ascending);
            playlistViewMap[playlistName].Columns[0].Visible = false;
            SizePlaylistTabs();
        }