Пример #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string type = NavigationContext.QueryString["type"];
            Debug.WriteLine("============this from " + type);
            if (type == "fav")
            {
                naviType = NaviTypeEnum.Fav;
                txtListName.Text = "收藏列表";
                //TODO:加载收藏
                longlistFav.Visibility = Visibility.Visible;
                Radiohelper helper = new Radiohelper();
                favList = helper.ReadXmltoObject<RadioFavList>(AppConfig.FavListFile);
                if (favList != null)
                {
                    longlistFav.ItemsSource = favList;
                }
                ApplicationBar.IsVisible = false;
            }
            else if (type == "all")
            {
                naviType = NaviTypeEnum.All;
                txtListName.Text = "选择频道";
                longlistAll.Visibility = Visibility.Visible;
                var viewModel = new RadioListViewModel();
                longlistAll.ItemsSource = viewModel.GroupedRadios;

                //ApplicationBar.BackgroundColor=Color

                //AppBarPrompt _appBar = new AppBarPrompt();

                //_appBar.Show();

                //BulidApplicationBar();

               //pc = new PopupCotainer(this);

            }
            else if (type == "sug")
            {
                naviType = NaviTypeEnum.Sug;
                txtListName.Text = "推荐频道";
                //TODO:加载推荐
                longlistSug.Visibility = Visibility.Visible;
                longlistSug.ItemsSource = DataService.GetSuggestRadios();
                ApplicationBar.IsVisible = false;
            }
            base.OnNavigatedTo(e);
        }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
        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();
            }
           
        }