Exemple #1
0
        // Constructor
        public MainPage()
        {
            MessageBoxResult result = MessageBoxResult.None;

            try
            {
                InitializeComponent();
                fmRadioInstance = FMRadio.Instance;
                this.Loaded    += MainPage_Loaded;
                this.Unloaded  += MainPage_Unloaded;
                DataContext     = this;
                App.progressIndicatorSetter(true, false, AppResources.ApplicationTitle, this);
            }
            catch (RadioDisabledException b)
            {
                FlurryWP8SDK.Api.LogError("RadioDisabledException", b);
                result = MessageBox.Show(AppResources.NoFmSupport, AppResources.SomethingHappened, MessageBoxButton.OK);
            }
            catch (Exception a)
            {
                FlurryWP8SDK.Api.LogError("Exception after RadioDisabledException", a);
                result = MessageBox.Show(AppResources.NoFmSupport, AppResources.SomethingHappened, MessageBoxButton.OK);
            }
            finally
            {
                if (result == MessageBoxResult.OK)
                {
                    Application.Current.Terminate();
                }
            }
        }
        void radioListGropus_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Radios radios = radioListGropus.SelectedItem as Radios;

            try
            {
                var app = App.Current as App;
                app.selectRasios = radioListGropus.SelectedItem as Radios;
                if (app.selectRasios != null)
                {
                    //this.NavigationService.Navigate(new Uri("/RadioMainPage.xaml", UriKind.Relative));
                    pivot.SelectedIndex = 1;

                    this.radioPivtoItem.Header = app.selectRasios.RadioName;
                    StartRadio();
                    radio = FMRadio.Instance;
                    //radio.PowerMode = RadioPowerMode.On;
                    radio.CurrentRegion = RadioRegion.Europe;
                    radio.Frequency     = app.selectRasios.RadioFrequency;
                }
            }
            catch (Exception ex)
            {
                UmengSDK.UmengAnalytics.TrackException(ex);
            }
        }
 static FMRadioController()
 {
     try
     {
         radio     = FMRadio.Instance;
         frequency = radio.Frequency;
     }
     catch (RadioDisabledException)
     {
         radio = null;
     }
 }
Exemple #4
0
        void FMPage_Loaded(object sender, RoutedEventArgs e)
        {
            //FMRadioModel model = new FMRadioModel();
            //model.SelectRadio();
            //foreach (var item in model.Items)
            //{
            //    Debug.WriteLine(item.Frequency);
            //}

            try
            {
                fmRadio = FMRadio.Instance;
                fmRadio.PowerMode = RadioPowerMode.On;
                fmRadio.CurrentRegion = RadioRegion.Europe;
            }
            catch (Exception)
            {
                MessageBox.Show("确保您的手机可以正常使用收音机功能!", "提示", MessageBoxButton.OK);
                return;
            }

            //TODO:Add AD
            Thickness adPosition = new Thickness();//定义广告banner的位置。
            adPosition.Left = 0;
            adPosition.Top = 0;
            adPosition.Right = 0;
            adPosition.Bottom = 0;
            AdControl adControl = new AdControl(this);
            adControl.Height = 100;
            adControl.InitAd(adPosition, "ODA2fDkzN3wyOTA5fDE=");//初始化广告banner

            adControl.AdReveiceEvent += adControl_AdReveiceEvent;
            adControl.AdFailedEvent += adControl_AdFailedEvent;
            adControl.LeaveApplicationEvent += adControl_LeaveApplicationEvent;
            adControl.PresentScreenEvent += adControl_PresentScreenEvent;
            adControl.DismissScreenEvent += adControl_DismissScreenEvent;

            gridAD.Children.Add(adControl);
            adControl.LoadAd();
        }