/// <summary> ///添加自己的Radio数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void inpuitControl_OnButtonOKClickChanged(object sender, InputControlEventArgs e) { //var info = (sender as InputUserRadioInfo); try { Debug.WriteLine(e.radio.RadioName + e.radio.RadioURL + e.radio.Type); Radiohelper helper = new Radiohelper(); ObservableCollection<RadioContent> radioList = helper.ReadXmltoObject<RadioContent>(AppConfig.UserAddListFile); //if (radioList!=null) //{ ////TODO:显示自添加的list //} if (radioList == null) { radioList = new ObservableCollection<RadioContent>(); } radioList.Add(e.radio); helper.WriteObjecttoXml<RadioContent>(radioList, AppConfig.UserAddListFile); } catch (Exception ex) { UmengSDK.UmengAnalytics.TrackException(ex); } }
private void MenuItem_Click(object sender, RoutedEventArgs e) { if (favList.Count > 0) { ToastPrompt _prompt = new ToastPrompt(); try { RadioFavList fav = (sender as Microsoft.Phone.Controls.MenuItem).CommandParameter as RadioFavList; favList.Remove(fav); longlistFav.ItemsSource.Remove(fav); Radiohelper helper = new Radiohelper(); helper.WriteObjecttoXml<RadioFavList>(favList, AppConfig.FavListFile); _prompt.Message = AppConfig.MsgFavDelSuccess;//删除成功 } catch (Exception ex) { _prompt.Message = AppConfig.MsgFavDelFailed;//删除失败 } _prompt.Title = AppConfig.ToastTitle; _prompt.TextWrapping = TextWrapping.NoWrap; _prompt.Show(); } }
private void btnFav_Click(object sender, RoutedEventArgs e) { Radiohelper helper = new Radiohelper(); // ObservableCollection<RadioFavList> favList = helper.ReadXmltoObject("fav.xml"); ObservableCollection<RadioFavList> favList = helper.ReadXmltoObject<RadioFavList>(AppConfig.FavListFile); if (favList==null) { favList = new ObservableCollection<RadioFavList>(); } //如果当前播放已经加入收藏夹,不再添加 foreach (var item in favList) { if (item.RadioURL == audioTrack.Source.ToString()) { //audioTrack = item; //btnFav.IsEnabled = false; _prompt = new ToastPrompt(); _prompt.Title = AppConfig.ToastTitle; _prompt.Message = AppConfig.MsgFavHas; _prompt.TextWrapping = TextWrapping.NoWrap; _prompt.Show(); return; } } if (audioTrack!=null) { favList.Add(new RadioFavList() { RadioName = audioTrack.Title, RadioURL = audioTrack.Source.ToString(), Type = audioTrack.Artist, IsFav=true }); helper.WriteObjecttoXml<RadioFavList>(favList, AppConfig.FavListFile); _prompt = new ToastPrompt(); _prompt.Title = AppConfig.ToastTitle; _prompt.Message =AppConfig.MsgFavAddSuccess; _prompt.TextWrapping = TextWrapping.NoWrap; _prompt.Show(); } }