Beispiel #1
0
        public lcUI()
        {
            InitializeComponent();
            lst.PreviewMouseDoubleClick  += lst_PreviewMouseDoubleClick;
            lst2.PreviewMouseDoubleClick += lst2_PreviewMouseDoubleClick;
            lst3.PreviewMouseDoubleClick += lst3_PreviewMouseDoubleClick;
            lst4.PreviewMouseDoubleClick += lst4_PreviewMouseDoubleClick;
            btnLibrary.Click             += showLibraryArtist;
            similars.MouseDoubleClick    += SimilarsOnMouseDoubleClick;
            if (Connectivity.CheckForInternetConnection())
            {
                int lcount = 0;
                grdLoading.FadeIn();
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var la = Web.LFM.TopTracks.Util.GetTopTracks().track.Take(20);
                    using (var db = new SQLiteConnection(DBPath))
                    {
                        foreach (var v in la)
                        {
                            var av =
                                db.Table <Track>().Where(c => c.Title == v.name && c.Artist == v.artist.name);
                            if (av.Count() > 0)
                            {
                                v.Available = "";
                                v.Path      = av.First().Path;
                            }
                        }
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        lst.ItemsSource = la;
                        lcount++;
                        if (lcount > 3)
                        {
                            grdLoading.FadeOut();
                        }
                    }));
                });
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var lb = Web.LFM.HypedTracks.Util.GetHypedTracks().track.Take(20);
                    using (var db = new SQLiteConnection(DBPath))
                    {
                        foreach (var v in lb)
                        {
                            var av =
                                db.Table <Track>().Where(c => c.Title == v.name && c.Artist == v.artist.name);
                            if (av.Count() > 0)
                            {
                                v.Available = "";
                                v.Path      = av.First().Path;
                            }
                        }
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        lst2.ItemsSource = lb;
                        lcount++;
                        if (lcount > 3)
                        {
                            grdLoading.FadeOut();
                        }
                    }));
                });
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var lc = Web.LFM.TopArtists.Artists.GetTopArtists().artist.Take(20);
                    using (var db = new SQLiteConnection(DBPath))
                    {
                        foreach (var v in lc)
                        {
                            var av =
                                db.Table <Artist>().Where(c => c.Name == v.name).Count();
                            if (av > 0)
                            {
                                v.Available = "";
                            }
                        }
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        lst3.ItemsSource = lc;
                        lcount++;
                        if (lcount > 3)
                        {
                            grdLoading.FadeOut();
                        }
                    }));
                });

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    var ld = Web.LFM.HypedArtists.Util.GetHypedArtists().artist.Take(20);
                    using (var db = new SQLiteConnection(DBPath))
                    {
                        foreach (var v in ld)
                        {
                            var av =
                                db.Table <Artist>().Where(c => c.Name == v.name).Count();
                            if (av > 0)
                            {
                                v.Available = "";
                            }
                        }
                    }
                    Dispatcher.Invoke(new Action(() =>
                    {
                        lst4.ItemsSource = ld;
                        lcount++;
                        if (lcount > 3)
                        {
                            grdLoading.FadeOut();
                        }
                    }));
                });
            }
        }