Ejemplo n.º 1
0
        public Page1(LCD l)
        {
            lcd = l;
            InitializeComponent();

            update_timer          = new DispatcherTimer();
            update_timer.Interval = new TimeSpan(0, 0, 0, 0, 200);
            update_timer.Tick    += new EventHandler(updateTimer_Tick);

            weatherTimer          = new DispatcherTimer();
            weatherTimer.Interval = new TimeSpan(0, 10, 0);
            weatherTimer.Tick    += new EventHandler(weatherTimer_Tick);

            update_timer.Start();
            weatherTimer.Start();

            yw = new YahooWeather();
            wr = yw.getWeather("Trelleborg", "SE", false);

            if (wr != null)
            {
                imgWeather.Source = setWeatherImage(wr.Condition.Code);
                updateLables();
                setForecast();
            }
        }
Ejemplo n.º 2
0
 private void GetYahooWeatherDetails()
 {
     YahooWeather _weather = new YahooWeather(SelectedCity.Name);
     string url = _weather.BuildUrl();
     YahooWeatherDetails weatherDetails = _weather.GetYahooWeatherDetails(url);
     _weatherDetails = weatherDetails;
     LoadYahooWeatherDates(weatherDetails);
 }
Ejemplo n.º 3
0
        private void GetYahooWeatherDetailsOffline(string city)
        {
            YahooWeather _weather = new YahooWeather(SelectedCity.Name);

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "Offline Datas\\"), string.Format("{0}\\{1}.txt", SelectedWeatherSource, city));
            if (!File.Exists(path))
                throw new Exception(string.Format("Please download the data for {0} to work in offline mode.", city));

            YahooWeatherDetails weatherDetails = _weather.GetYahooWeatherDetailsOffline(File.ReadAllText(path));
            _weatherDetails = weatherDetails;
            LoadYahooWeatherDates(weatherDetails);
        }
Ejemplo n.º 4
0
 //return weather for a city
 public Weather(string city)
 {
     iLocation = WeatherLocation.WL_AUS;
     yw = new YahooWeather();
     for (int i = 0; i < yw.WeatherAustralia.Length; i++)
     {
         if (city == yw.WeatherAustralia[i].city.ToLower() || city == yw.WeatherAustralia[i].city.ToLower().Substring(0, 3))
         {
             iLocation = (WeatherLocation)yw.WeatherAustralia[i].index;
             city_name = yw.WeatherAustralia[i].city_chn;
             break;
         }
     }
 }
Ejemplo n.º 5
0
 private string GetUrl(ref WeatherDetails _weather)
 {
     string Url = null;
     switch (SelectedWeatherSource)
     {
         case "Open Weather":
             appId = ConfigurationManager.AppSettings["OpenWeather"];
             _weather = new OpenWeather(appId, SelectedCity.Name);
             Url = _weather.BuildUrl();
             break;
         case "Yahoo":
             _weather = new YahooWeather(SelectedCity.Name);
             Url = _weather.BuildUrl();
             break;
     }
     return Url;
 }
Ejemplo n.º 6
0
        private async Task WeatherReport(IDialogContext context, IAwaitable <LuisResult> result)
        {
            var luisresult = await result;
            EntityRecommendation _location;
            var          reply = context.MakeMessage();
            YahooWeather yw    = new YahooWeather();

            if (luisresult.TryFindEntity("Weather.Location", out _location))
            {
                await yw.GetWeatherFromYahoo(context, _location.Entity.ToString());

                context.Done(true);
            }
            else
            {
                await context.Forward(new NoneDialog(), this.WeatherAfterAsync, result, System.Threading.CancellationToken.None);
            }
        }
    public IEnumerator Weather()
    {
        YahooWeather cityWeather;

        do
        {
            cityWeather = new YahooWeather(url);
            yield return(cityWeather);

            tryNumber++;
            //Debug.Log(tryNumber);
        } while ((tryNumber < 5) && (cityWeather.query.count == 0));

        if (cityWeather.query.count != 0)
        {
            GameObject cityUI = GameObject.Find("City");
            cityUI.GetComponent <Text>().text = cityWeather.query.results.channel.location.city + ", " + cityWeather.query.results.channel.location.country;
            GameObject temperatureUI = GameObject.Find("Temperature");
            int        temperature   = ((cityWeather.query.results.channel.item.forecast[1].high - 32) * 5) / 9;
            temperatureUI.GetComponent <Text>().text = temperature.ToString() + "°C";
            GameObject status = GameObject.Find("Status");
            status.GetComponent <SceneStatus>().readyToOpen = true;
        }
    }
Ejemplo n.º 8
0
 /// <summary>
 /// return the weather for all australia
 /// </summary>
 public Weather()
 {
     yw = new YahooWeather();
     iLocation = WeatherLocation.WL_AUS;
 }