Ejemplo n.º 1
0
        /// <summary>
        /// Get how how many files will be exported.
        /// </summary>
        private void UpdateFileCount()
        {
            Cursor = Cursors.WaitCursor;

            // Instantiate main logic.
            OutputMusic outputMusic = new OutputMusic
            {
                FolderTrackLimit   = RegistryAccess.FolderTrackLimit,
                PlaylistTrackLimit = RegistryAccess.PlaylistTrackLimit
            };

            // Get all selected playlists.
            List <Playlist> playlists = Playlists.Select(playlistId => AppMusicLibrary.PlaylistDictionary[playlistId]).ToList();

            foreach (Playlist playlistItem in playlists)
            {
                // Add MP3 tracks.
                foreach (Track track in playlistItem.AllTracks.Where(track => track.FileName.ToLower().EndsWith(".mp3")))
                {
                    if (track.InLibrary)
                    {
                        outputMusic.AddTrack(track.Id, track.Artist, track.Name, track.TrackTime, AppMusicLibrary.MusicFolder + track.Location);
                    }
                    else
                    {
                        outputMusic.AddTrack(track.Id, track.Artist, track.Name, track.TrackTime, track.Location);
                    }
                }

                // Add playlist.
                outputMusic.AddPlaylist(playlistItem.PersistentId, playlistItem.Name, playlistItem.AllTracks);
            }

            // Retrieve the file count this would generate.
            int totalFileCount = outputMusic.TotalFileCount();

            // Display a warning if the total count is over the given limit.
            lblFileLimitWarning.Visible = (totalFileCount > RegistryAccess.OverallFileLimit);

            // Display the amount.
            txtOverallFileCount.Text = outputMusic.TotalFileCount().ToString();

            Cursor = Cursors.Default;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Do the main export.
        /// </summary>
        /// <param name="storageId"></param>
        private void ExportStorage(int storageId)
        {
            // Instantiate main logic to configure how the music will be output.
            _outputMusic = new OutputMusic
            {
                FolderTrackLimit    = Convert.ToInt32(nmcFolderTrackLimit.Value),
                PlaylistTrackLimit  = Convert.ToInt32(nmcPlaylistTrackLimit.Value),
                FileNameLengthLimit = Convert.ToInt32(nmcFileNameLengthLimit.Value),
                StripId3V1Tags      = chkStripID3V1Tags.Checked,
                StripId3V2Tags      = chkStripID3V2Tags.Checked,
                OutputFolder        = txtOutputFolder.Text
            };
            _outputMusic.OutputError   += _outputMusic_OutputError;
            _outputMusic.DeleteFiles   += _outputMusic_DeleteFiles;
            _outputMusic.StatusChanged += _outputMusic_StatusChanged;

            // Run the main operations asychronously.
            bgwOutput.RunWorkerAsync(storageId);
        }