public NowWeather(observation current_observation) { if (current_observation == null) { return; } Now = new NowCondition(current_observation); CultureInfo provider = CultureInfo.InvariantCulture; float i; Temprature = Temperature.FromCelsius(current_observation.temp_c); if (float.TryParse(current_observation.feelslike_c, NumberStyles.Any, provider, out i)) { BodyTemprature = Temperature.FromCelsius(i); } if (float.TryParse(current_observation.precip_today_metric, NumberStyles.Any, provider, out i)) { Precipitation = i; } if (float.TryParse(current_observation.visibility_km, NumberStyles.Any, provider, out i)) { Visibility = Length.FromKM(i); } Wind = new Wind(Convert.ToUInt32(current_observation.wind_kph), Convert.ToUInt32(current_observation.wind_degrees)); if (float.TryParse(current_observation.pressure_mb, NumberStyles.Any, provider, out i)) { Pressure = Pressure.FromHPa(i); } }
public NowWeather(JsonContract.NowWeatherContract now) { if (now == null) { return; } CultureInfo provider = CultureInfo.InvariantCulture; Now = new NowCondition(now.cond); int fl; if (int.TryParse(now.fl, NumberStyles.Any, provider, out fl)) { BodyTemprature = Temperature.FromCelsius(fl); } float pcpn; if (float.TryParse(now.pcpn, NumberStyles.Any, provider, out pcpn)) { Precipitation = pcpn; } if (float.TryParse(now.vis, NumberStyles.Any, provider, out pcpn)) { Visibility = Length.FromKM(pcpn); } Wind = new Wind(now.wind); if (float.TryParse(now.pres, NumberStyles.Any, provider, out pcpn)) { Pressure = Pressure.FromHPa(pcpn); } if (int.TryParse(now.tmp, NumberStyles.Any, provider, out fl)) { Temprature = Temperature.FromCelsius(fl); } }
private void Item_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var i = sender as PressureViewModel; switch (i.Parameter) { case PressureParameter.Atm: MainValue = Pressure.FromAtm(i.Value); break; case PressureParameter.CmHg: MainValue = Pressure.FromCmHg(i.Value); break; case PressureParameter.Hpa: MainValue = Pressure.FromHPa(i.Value); break; case PressureParameter.Torr: MainValue = Pressure.FromTorr(i.Value); break; default: break; } foreach (var item in Items) { item.PropertyChanged -= Item_PropertyChanged; switch (item.Parameter) { case PressureParameter.Atm: item.Value = MainValue.Atm; break; case PressureParameter.CmHg: item.Value = MainValue.CmHg; break; case PressureParameter.Hpa: item.Value = MainValue.HPa; break; case PressureParameter.Torr: item.Value = MainValue.Torr; break; default: break; } item.PropertyChanged += Item_PropertyChanged; } }
public HourlyForecast(JsonContract.HourlyForecastContract hourly_forecast) { if (hourly_forecast == null) { return; } CultureInfo provider = CultureInfo.InvariantCulture; DateTime = DateTime.ParseExact(hourly_forecast.date, "yyyy-MM-dd HH:mm", provider); Humidity = uint.Parse(hourly_forecast.hum); Pop = uint.Parse(hourly_forecast.pop); Pressure = Pressure.FromHPa(float.Parse(hourly_forecast.pres, provider)); Temprature = Temperature.FromCelsius(int.Parse(hourly_forecast.tmp)); Wind = new Wind(hourly_forecast.wind); }
public DailyForecast(JsonContract.DailyForecastContract daily_forecast) { if (daily_forecast == null) { return; } CultureInfo provider = CultureInfo.InvariantCulture; Date = DateTime.ParseExact(daily_forecast.date, "yyyy-MM-dd", provider); SunRise = TimeSpan.Parse(daily_forecast.astro.sr); SunSet = TimeSpan.Parse(daily_forecast.astro.ss); Condition = new DailyCondition(daily_forecast.cond); Humidity = uint.Parse(daily_forecast.hum); Precipitation = float.Parse(daily_forecast.pcpn, provider); Pop = uint.Parse(daily_forecast.pop); Pressure = Pressure.FromHPa(float.Parse(daily_forecast.pres, provider)); HighTemp = Temperature.FromCelsius(int.Parse(daily_forecast.tmp.max)); LowTemp = Temperature.FromCelsius(int.Parse(daily_forecast.tmp.min)); Visibility = Length.FromKM(float.Parse(daily_forecast.vis, provider)); Wind = new Wind(daily_forecast.wind); }