public static void ShowTagWin(Window win, ListFiles lf) { if (lf == null) return; var tw = new TagWin(lf) { Owner = win }; tw.Show(); }
public TagWin(ListFiles lf) { InitializeComponent(); mf = lf.MusicFile; DataContext = mf; }
public static async Task<int> ReloadPlayList(PlayList pl) { return await Task.Run(() => { int count = 0; var newLines = ImportListFile(pl.Source, ListType.M3U8); if (newLines == null) return 0; var dict = pl.ListFiles.ToDictionary(lf => lf.MusicFile.FullName); var oldLines = dict.Keys.AsEnumerable(); var del = oldLines.Except(newLines).Select(ol => dict[ol]); var add = newLines.Except(oldLines).Select(nl => MDModel.Model.MusicFile.SingleOrDefault(m => m.FullName == nl)); foreach (var di in del) pl.ListFiles.Remove(di); count += MDModel.Model.SaveChanges(); foreach (var ai in add) { if (ai == null) continue; var lf = new ListFiles() { FileId = ai.FileId, IsChecked = true, ListId = pl.ListId, }; pl.ListFiles.Add(lf); } count += MDModel.Model.SaveChanges(); return count; }); }