示例#1
0
        protected async override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                // Navigated from a tile, time to get the stations.

                if (NavigationContext.QueryString.ContainsKey("station"))
                {
                    string station = NavigationContext.QueryString["station"];

                    // no skipping yet - no stations
                    btnNext.IsEnabled = btnPrevious.IsEnabled = false;

                    SettingsManager.AttemptToLoadSettings();

                    MainPageViewModel.Instance.FavoriteStations = Serialize.Open <ObservableCollection <Station> >("fav.xml");

                    List <Station> stations = (await MobileServiceClientHelper.GetAllStations()).ToList();
                    if (stations != null)
                    {
                        Serialize.Save("stationcache.xml", stations);

                        // now it's OK to navigate through stations.
                        btnNext.IsEnabled = btnPrevious.IsEnabled = true;

                        // after all, I need this because the user might do
                        // "station hopping"
                        MainPageViewModel.Instance.Stations = new System.Collections.ObjectModel.ObservableCollection <Station>(stations);

                        Station currentStation = (from c in
                                                  MainPageViewModel.Instance.Stations
                                                  where c.JSONID == station
                                                  select c).Single();

                        CoreViewModel.Instance.CurrentStation = currentStation;

                        imgFave.Source = FavoriteImageSetter.GetImage(CoreViewModel.Instance.CurrentStation);

                        CheckCurrentPlayingState();

                        SetMediaItem(); // This is used for Zune Hub integration.
                    }
                }
                else
                {
                    CheckCurrentPlayingState();
                    SetMediaItem();
                }
            }
            catch
            {
            }

            StartStoryboard();

            base.OnNavigatedTo(e);
        }
示例#2
0
        public async static Task <bool> AttemptStationLoading(string defaultStation = "")
        {
            MainPageViewModel.Instance.FavoriteStations = Serialize.Open <ObservableCollection <Station> >("fav.xml");

            if (MainPageViewModel.Instance.Stations.Count == 0)
            {
                try
                {
                    List <Station> stations = (await MobileServiceClientHelper.GetAllStations()).ToList();
                    Debug.WriteLine(stations.GetType());

                    if (stations != null)
                    {
                        // Storing the station cache so that I can manipulate those
                        // with the back/forward buttons.
                        Serialize.Save <List <Station> >("stationcache.xml", stations);

                        HandleStationList(stations, ref defaultStation);
                        return(true);
                    }
                    else
                    {
                        NotifyOfStationDownloadError(ref defaultStation);
                        return(false);
                    }
                }
                catch
                {
                    NotifyOfStationDownloadError(ref defaultStation);

                    return(false);
                }
            }
            else
            {
                // No need to load stations.
                return(false);
            }
        }
示例#3
0
 //TODO: Step 6 - Android - Initialize our Service
 private void InitializeHelloWorldServiceClient()
 {
     MobileServiceClient = MobileServiceClientHelper.CreateMobileServiceClient();
     MobileServiceClient.GetMobileMatchCompleted      += GetMobileMatchCompleted;
     MobileServiceClient.GetRandomMobileNameCompleted += GetRandomMobileNameCompleted;
 }