public List <ViewTrack> AddTrackList(List <Track> tracks) { List <ViewTrack> viewTracks = new List <ViewTrack>(); foreach (var track in tracks) { if (!IsTrackExist(track.name)) { BitmapImage image = getTrackImage(track.path + track.name + track.format); track.image = image; TrackLibrary.Add(track.name, track); TrackList.Insert(0, track.name); viewTracks.Add(new ViewTrack(track.name, image)); } } return(viewTracks); }
// Добавление одного трека [переработано] public ViewTrack AddTrack(string filePath) { string fullTrackName = Path.GetFileName(filePath); string trackName = fullTrackName.Substring(0, fullTrackName.LastIndexOf('.')); if (!IsTrackExist(trackName)) { string trackFormat = fullTrackName.Substring(fullTrackName.LastIndexOf('.')); BitmapImage image = getTrackImage(filePath); Track newTrack = new Track(trackName, Path.GetDirectoryName(filePath) + "\\", trackFormat, image); TrackLibrary.Add(trackName, newTrack); TrackList.Insert(0, trackName); DbManager.Instance().SaveTrack(newTrack); return(new ViewTrack(trackName, image)); } return(null); }
// Добавление списка треков [переработано] public List <ViewTrack> AddTrackList(string[] files) { files = files.Reverse().ToArray <string>(); List <ViewTrack> viewTracks = new List <ViewTrack>(); List <Track> newTracks = new List <Track>(); string fullTrackName = ""; string trackName = ""; string trackFormat = ""; foreach (string file in files) { fullTrackName = Path.GetFileName(file); trackName = fullTrackName.Substring(0, fullTrackName.LastIndexOf('.')); if (!IsTrackExist(trackName)) { trackFormat = fullTrackName.Substring(fullTrackName.LastIndexOf('.')); BitmapImage image = getTrackImage(file); Track newTrack = new Track(trackName, Path.GetDirectoryName(file) + "\\", trackFormat, image); TrackLibrary.Add(trackName, newTrack); TrackList.Insert(0, trackName); viewTracks.Add(new ViewTrack(trackName, image)); newTracks.Insert(0, newTrack); } } DbManager.Instance().SaveTracks(newTracks); return(viewTracks); }