Exemplo n.º 1
0
 public static void ShowTagWin(Window win, ListFiles lf)
 {
     if (lf == null)
         return;
     var tw = new TagWin(lf) { Owner = win };
     tw.Show();
 }
Exemplo n.º 2
0
 public TagWin(ListFiles lf)
 {
     InitializeComponent();
     mf = lf.MusicFile;
     DataContext = mf;
 }
Exemplo n.º 3
0
        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;
            });
        }