Exemplo n.º 1
0
        private void InitMusic()
        {
            CurrentMusicList.CollectionChanged += CurrentMusicList_OnCountChange;

            var CurrentMusicListStr = File.ReadAllText("Data\\CurrentMusicList.json");

            CurrentMusicList = JsonConvert.DeserializeObject <MusicObservableCollection <Music> >(CurrentMusicListStr);

            var HistoryMusicListStr = File.ReadAllText("Data\\HistoryMusicList.json");

            HistoryMusicList = JsonConvert.DeserializeObject <MusicHistoriesCollection <MusicHistory> >(HistoryMusicListStr);

            var PlayListCollectionStr = File.ReadAllText("Data\\PlayListCollection.json");

            PlayListCollection          = JsonConvert.DeserializeObject <ObservableCollection <PlayListCollectionModel> >(PlayListCollectionStr);
            PlayListListBox.DataContext = PlayListCollection;

            //if (CurrentMusicList.Count > 0)
            //{
            //    PlayMusicButton_Click(new object(), new RoutedEventArgs());
            //    PlayMusicButton_Click(new object(), new RoutedEventArgs());
            //}
            CurrentMusicListCountLable.DataContext = CurrentMusicList;
            bsp.PropertyChanged += Bsp_PropertyChanged;
        }
Exemplo n.º 2
0
        private void Init()
        {
            var LocalMusicFolderListContent = "";
            var LocalMusicListContent       = "";

            try
            {
                LocalMusicListContent       = File.ReadAllText("Data\\LocalMusicList.json");
                LocalMusicFolderListContent = File.ReadAllText("Data\\LocalMusicFolderList.json");
            }
            catch (System.Exception)
            {
            }

            FolderList = JsonConvert.DeserializeObject <ObservableCollection <string> >(LocalMusicFolderListContent);
            if (FolderList.Count == 0)
            {
                FolderList.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) + "\\");
            }
            LocalMusicList = JsonConvert.DeserializeObject <MusicObservableCollection <Music> >(LocalMusicListContent);
            if (LocalMusicList.Count == 0)
            {
                RefreshLocalList();
            }

            LocalMusicDataGrid.DataContext    = LocalMusicList;
            LocalMusicCountLable.Content      = LocalMusicList.Count + "首音乐";
            LocalMusicList.CollectionChanged += LocalMusicList_OnCountChange;;
            FolderList.CollectionChanged     += FolderList_CollectionChanged;
        }
        private void Init()
        {
            var DownLoadedListStr = File.ReadAllText("Data\\DownLoadedList.json");

            DownLoadedList = Newtonsoft.Json.JsonConvert.DeserializeObject <MusicObservableCollection <Music> >(DownLoadedListStr);

            var DownLoadingListStr = File.ReadAllText("Data\\DownLoadingList.json");

            DownLoadingList = Newtonsoft.Json.JsonConvert.DeserializeObject <NetMusicObservableCollection <NetMusic> >(DownLoadingListStr);
            DownLoadedMusicDataGrid.DataContext  = DownLoadedList;
            DownLoadingMusicDataGrid.DataContext = DownLoadingList;
            DownLoadDirectoryLable.Content       = DownLoadDirectory;
            timer.Interval = TimeSpan.FromMilliseconds(1000);
            timer.Tick    += TimerOnTick;
            timer.Start();
        }