示例#1
0
        private void ParseStations(WrapPanel panel, string url, bool refresh = false, bool start = false)
        {
            if (MainTab.SelectedIndex == 0 && Favorite_Radio_Wrap.Children.Count > 0)
            {
                return;
            }
            else if (MainTab.SelectedIndex == 0 && Favorite_Radio_Wrap.Children.Count == 0)
            {
                PrintRadio(Favorite_Radio_Wrap, FavoriteRadio);
            }
            else if (panel.Children.Count == 0)
            {
                Task <Radio.RadioFull[]> task = new Task <Radio.RadioFull[]>(() => GetStations.Get(url));
                task.Start();
                task.Wait();

                if (All_Radio_Wrap.Children.Count == 0 && MainTab.SelectedIndex == 1)
                {
                    AllRadio = task.Result;
                    PrintRadio(panel, AllRadio);
                }
                else
                {
                    PrintRadio(panel, task.Result);
                }
            }
        }
示例#2
0
        private void PlayRadio(Image panel)
        {
            Radio.RadioFull station = (GetData.GetParentStack(panel) as StackPanel).DataContext as Radio.RadioFull;

            station = GetStations.GetStream((panel.DataContext as Radio.RadioFull).Url, station);

            if (station != null)
            {
                StationJanre.Content     = $"[{ station.Janre}]";
                StationNameLabel.Content = station.Name;

                StationNameLabel.Uid          = station.WhoPlay;
                StationCoverImage.ImageSource = new BitmapImage(new Uri(station.Picture));
                StationWhoPlayLabel.Content   = GetTrack.Get(station.WhoPlay);
                StationWhoPlayLabel.Uid       = station.WhoPlay;

                FirstQualityButton.IsEnabled  = true;
                FirstQualityButton.Background = (Brush)this.TryFindResource("GeneralColor");
                FirstQualityButton.Content    = station.QualityStream[0];
                FirstQualityButton.Uid        = station.Stream[0];

                PlayGrid.DataContext = station;

                SecondQualityButton.IsEnabled = true;
                if (station.QualityStream[1] != null)
                {
                    SecondQualityButton.Content = station.QualityStream[1];
                    SecondQualityButton.Uid     = station.Stream[1];
                }
                else
                {
                    SecondQualityButton.Content   = "-";
                    SecondQualityButton.IsEnabled = false;
                }

                FirstQualityButton.Background  = (Brush)this.TryFindResource("GeneralColor");
                SecondQualityButton.Background = new SolidColorBrush(Colors.WhiteSmoke);

                bool found = Favorite.Coincidence(FavoriteRadio, station.Name);

                if (found)
                {
                    FavoriteRadioButton.Source = new BitmapImage(new Uri("pack://application:,,/Resources/Icons/pl_start_fav.png"));
                    FavoriteRadioButton.Uid    = "1";
                }
                else
                {
                    FavoriteRadioButton.Source = new BitmapImage(new Uri("pack://application:,,/Resources/Icons/pl_star.png"));
                    FavoriteRadioButton.Uid    = "0";
                }

                PlayMusic(station.Stream[0]);
            }
        }