Example #1
0
 private void GeoLocation_OnLocate(PositionEventArg e)
 {
     ee = e;
     LocatedByCoords = e.Status;
     if (e.Status)
     {
         // Lokalizovano na zaklade polohy zarizeni
         OpenWeatherMap.DownloadForecastbyCoordinates(e.Pos.Coordinate.Point.Position.Latitude, e.Pos.Coordinate.Point.Position.Longitude);
         // config.AppConfig.DefaultCityID = Convert.ToInt32(Forecast.Location.Geobaseid);
     }
     else
     {
         // Neznam polohu
         OpenWeatherMap.DownloadForecastbyId(DefaultCityID);
         config.AppConfig.DefaultCityID = DefaultCityID;
     }
     config.AppConfig.TempMax = this.TempMax;
     config.AppConfig.TempMin = this.TempMin;
     SaveConfig();
 }
Example #2
0
        private async void  OpenWeatherMap_onDownloadComplete(bool status)
        {
            if (status)
            {
                this.LastSuccessForecastDownload = DateTime.Now;
            }
            XMLDownloaded = status;

            /*
             * !!!!  Běží na vedlejším vlákně !!!!
             */


            XMLForecastAvailable = await OpenWeatherMap.IsOfflineXMLAvailable("forecast.xml");

            IsSomethingToShow = false;

            if (XMLForecastAvailable)
            {
                // Get forecast object;
                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                StorageFile   XMLFile     = await localFolder.GetFileAsync("forecast.xml");

                this.Forecast = await OpenWeatherMap.GetForecast(XMLFile);

                if (this.Forecast.ForecasForNowAvailable)
                {
                    IsSomethingToShow  = true;
                    OldXMLForecastUsed = !status;
                }
            }


            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                      () =>
            {
                // Toto probehne na hlavnim vlakne
                ShowForecast(IsSomethingToShow);
            });
        }