private MusicViewModel createViewModel(IMusic music, bool toFront)
        {
            MusicViewModel s = null;

            switch (music.Type)
            {
            case EnumMusicType.album:
                s = new AlbumViewModel(music as Album);
                break;

            case EnumMusicType.artist:
                s = new ArtistViewModel(music as Artist);
                break;

            case EnumMusicType.collect:
                s = new CollectViewModel(music as Collection);
                break;

            default:
                s = SongViewModel.Get(music as Song);
                break;
            }

            return(s);
        }
        void btn_import_click(object sender, RoutedEventArgs e)
        {
            var dir = Global.AppSettings["DownloadFolder"];

            Task.Run(async() =>
            {
                var buffer       = new List <IMusic>();
                int bufferLength = 10;
                var mp3s         = Directory.EnumerateFiles(dir, "*.mp3").ToArray();
                foreach (var item in mp3s)
                {
                    try
                    {
                        var mp3  = TagLib.File.Create(item);
                        var tags = mp3.Tag;
                        if (tags.Comment == null)
                        {
                            continue;
                        }
                        var id       = "";
                        var artistid = "";
                        var albumid  = "";
                        var logo     = "";
                        var m        = reg_ids.Match(tags.Comment);
                        if (!m.Success)
                        {
                            m = reg.Match(tags.Comment);
                            if (!m.Success)
                            {
                                continue;
                            }
                            id           = m.Groups[1].Value;
                            var obj      = await NetAccess.Json(XiamiUrl.url_song, "id", id);
                            artistid     = MusicHelper.Get(obj["song"], "artist_id");
                            albumid      = MusicHelper.Get(obj["song"], "album_id");
                            logo         = StringHelper.EscapeUrl(MusicHelper.Get(obj["song"], "logo"));
                            tags.Comment = string.Join(" ", new[] { id, artistid, albumid });
                            mp3.Save();
                        }
                        else
                        {
                            id       = m.Groups[1].Value;
                            artistid = m.Groups[2].Value;
                            albumid  = m.Groups[3].Value;
                        }
                        var art = System.IO.Path.Combine(Global.BasePath, "cache", albumid + ".art");
                        if (!File.Exists(art))
                        {
                            if (string.IsNullOrEmpty(logo))
                            {
                                var obj = await NetAccess.Json(XiamiUrl.url_song, "id", id);
                                logo    = StringHelper.EscapeUrl(MusicHelper.Get(obj["song"], "logo"));
                            }
                            await new System.Net.WebClient().DownloadFileTaskAsync(logo, art);
                        }
                        var song = new Song
                        {
                            Id         = id,
                            ArtistId   = artistid,
                            AlbumId    = albumid,
                            Name       = tags.Title,
                            ArtistName = tags.FirstPerformer,
                            AlbumName  = tags.Album,
                            FilePath   = item,
                            Logo       = logo,
                        };
                        buffer.Add(song);
                    }
                    catch
                    {
                    }
                    if (buffer.Count == bufferLength)
                    {
                        var songs = new List <IMusic>();
                        foreach (var s in buffer.OfType <Song>())
                        {
                            SongViewModel.Get(s).HasMp3 = true;
                        }
                        songs.AddRange(buffer);
                        Items.AddItems(songs);
                        buffer.Clear();
                    }
                }
                if (buffer.Count > 0)
                {
                    foreach (var s in buffer.OfType <Song>())
                    {
                        SongViewModel.Get(s).HasMp3 = true;
                    }
                    Items.AddItems(buffer);
                }
            });
        }