Ejemplo n.º 1
0
        /// <summary>
        /// Handles everything related to drag drop
        /// </summary>
        /// <param name="tracks">The file paths that were dropped</param>
        /// <param name="player">An instance of the Player</param>
        /// <param name="library">An instance of the Library</param>
        /// <param name="enqueue">Whether to enqueue the tracks that were dropped</param>
        /// <param name="import">Whether to import the tracks that were dropped</param>
        /// <param name="clearqueue">Whether to clear the queue before handling everything else</param>
        public static async void DoDragDrop(string[] tracks, Player player, GUILibrary library, bool enqueue = true, bool import = true, bool clearqueue = true)
        {
            if (clearqueue) player.Queue.Clear();
            if (tracks.Any(x => Directory.Exists(x)))
            {
                foreach (var track in tracks)
                {
                    if (Directory.Exists(track))
                    {
                        string[] paths = Directory.EnumerateFiles(tracks[0], "*", SearchOption.AllDirectories)
                        .Where(name => name.EndsWith(".mp3")
                        || name.EndsWith(".wav") || name.EndsWith(".m4a") || name.EndsWith(".ogg")
                        || name.EndsWith(".flac") || name.EndsWith(".aiff")
                        || name.EndsWith(".wma")
                        || name.EndsWith(".aac")).ToArray();
                        if (enqueue) player.Queue.Add(paths);
                        if (import) await Task.Run(() => library.Import(paths));
                    }
                    else
                    {
                        if (enqueue) player.Queue.Add(track);
                        if (import) await Task.Run(() => library.Import(track));
                    }
                }

            }
            else
            {
                if (enqueue) player.Queue.Add(tracks);
                if (import) await Task.Run(() => library.Import(tracks));
            }
        }
Ejemplo n.º 2
0
 public void SaveChanges(List <string> filePaths)
 {
     foreach (string path in filePaths)
     {
         var track = new Track(path)
         {
             Artist      = ArtistBox.Text,
             Title       = TitleBox.Text,
             Album       = AlbumBox.Text,
             Genre       = GenreBox.Text,
             Year        = Convert.ToInt32(YearBox.Text),
             AlbumArtist = AlbumArtistBox.Text,
             Composer    = ComposerBox.Text,
             TrackNumber = Convert.ToInt32(TrackNumBox.Text),
             DiscNumber  = Convert.ToInt32(DiscNumBox.Text),
             Lyrics      = new LyricsInfo()
         };
         track.Lyrics.UnsynchronizedLyrics = UntimedLyricsBox.Text;
         track.EmbeddedPictures.Clear();
         foreach (var cover in CoverArts)
         {
             track.EmbeddedPictures.Add(cover);
         }
         track.Save();
         library?.Remove(path); // update library entry, if available
         library?.Import(path);
     }
 }
Ejemplo n.º 3
0
        public async Task PerformAutoImport()
        {
            if (App.Config.AutoImportPaths.Count <= 0)
            {
                return;                                        // not really needed but prevents going through unneeded
            }
            // effort (and showing the notification)
            var notification = new Notification {
                ContentText = Properties.Resources.NOTIFICATION_SCANNING
            };

            NotificationHandler.Add(notification);
            var filesToImport = new List <string>();
            var library       = Library.Read();
            await Task.Run(() =>
            {
                foreach (var folder in App.Config.AutoImportPaths)
                {
                    var files = Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories)
                                .Where(name => name.EndsWith(".mp3") ||
                                       name.EndsWith(".wav") || name.EndsWith(".m4a") || name.EndsWith(".ogg") ||
                                       name.EndsWith(".flac") || name.EndsWith(".aiff") ||
                                       name.EndsWith(".wma") ||
                                       name.EndsWith(".aac")).ToArray();
                    foreach (var file in files)
                    {
                        if (!library.Select(x => x.Path).Contains(file))
                        {
                            filesToImport.Add(file);
                        }
                    }
                }
                Library.Import(filesToImport);
            });

            NotificationHandler.Remove(notification);
        }