Esempio n. 1
0
        private void GetForecast(XmlDocument doc)
        {
            string forecastListQuery = "weatherdata/forecast/*";

            var forecasts = doc.SelectNodes(forecastListQuery);

            foreach (XmlNode forecastNode in forecasts)
            {
                var forecast = new Forecast(forecastNode);

                Forecasts.Add(forecast);
            }
        }
Esempio n. 2
0
        public static List <ForecastView> GetForecastList(Example forecasts)
        {
            List <ForecastView> newForecastViews = new List <ForecastView>();

            for (int i = 0; i < 7; i++)
            {
                Forecast forecast = forecasts.Query.Results.Channel[i].Item.Forecast;
                Wind     wind     = forecasts.Query.Results.Channel[i].Wind;

                newForecastViews.Add(new ForecastView
                {
                    Date         = forecast.Date,
                    Temperature  = forecast.High + " °C",
                    WindSpeed    = GetFormatedWindSpeed(wind.Speed),
                    WeatherImage = GetImage(forecast.Text),
                });
            }

            return(newForecastViews);
        }
Esempio n. 3
0
        private Weather GetWeatherFromApi(string city)
        {
            var    weather = new Weather();
            var    client  = new WebClient();
            string url     = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22" + city + "%22)%20and%20u%20=%20%27c%27%20&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
            var    obj     = JsonConvert.DeserializeObject <dynamic>(client.DownloadString(url));

            weather.City = obj.query.results.channel.location.city;
            weather.TemperatureCurrent = obj.query.results.channel.item.condition.temp;
            weather.Code = obj.query.results.channel.item.forecast[0].code;
            weather.Date = DateTime.Parse(obj.query.created.ToString("dd-MM-yyyy  HH:mm:ss"));

            foreach (var item in obj.query.results.channel.item.forecast)
            {
                var temp = new Forecast();
                temp.TemperatureDay   = item.high;
                temp.TemperatureNight = item.low;
                temp.Code             = item.code;
                weather.Forecast.Add(temp);
            }

            return(weather);
        }
Esempio n. 4
0
 public HourModel(Forecast f)
 {
     data = f;
 }
Esempio n. 5
0
        public HourVM(Forecast hour)
        {
            model = new HourModel(hour);

            Hour = hour;
        }
Esempio n. 6
0
 public string ToQuery(Forecast f)
 {
     return($"({f.Id}, '{Value}', {FixDouble.ToString(All)}),");
 }
Esempio n. 7
0
 public string ToQuery(Forecast f)
 {
     return($"({f.Id}, {FixDouble.ToString(Number)}, '{Name}','{Var}'),");
 }
Esempio n. 8
0
 public string ToQuery(Forecast f)
 {
     return($"({f.Id}, '{Unit}', {FixDouble.ToString(Value)}, '{Type}'),");
 }
Esempio n. 9
0
 public string ToQuery(Forecast f)
 {
     return($"({f.Id}, '{UnitType}', {FixDouble.ToString(Value)}, " +
            $"{FixDouble.ToString(Min)}, {FixDouble.ToString(Max)}),");
 }
Esempio n. 10
0
 public string ToSpeedQuery(Forecast f)
 {
     return($"({f.Id}, {FixDouble.ToString(Speed)}, '{SpeedName}'),");
 }
Esempio n. 11
0
 public string ToDirQuery(Forecast f)
 {
     return($"({f.Id}, {FixDouble.ToString(Direction)}, '{Code}','{DirectionName}'),");
 }
Esempio n. 12
0
 public ForecastPage()
 {
     InitializeComponent();
     BindingContext = new Forecast();
 }
Esempio n. 13
0
        public DailyVM(Forecast daily)
        {
            model = new HourModel(daily);

            Daily = daily;
        }