public Forecast() { From = new DateTime(); To = new DateTime(); Wind = new Wind(); Temperature = new Temperature(); Pressure = new Pressure(); Symbol = new Symbol(); Precipitation = new Precipitation(); Clouds = new Clouds(); }
public Forecast(params object[] args) { Id = int.Parse(args[0].ToString()); From = DateTime.Parse(args[2].ToString()); To = DateTime.Parse(args[3].ToString()); Humidity = FixDouble.ToDouble(args[4].ToString()); Temperature = new Temperature { UnitType = args[6].ToString(), Value = FixDouble.ToDouble(args[7].ToString()), Min = FixDouble.ToDouble(args[8].ToString()), Max = FixDouble.ToDouble(args[9].ToString()), }; Precipitation = new Precipitation { Unit = args[11].ToString(), Value = FixDouble.ToDouble(args[12].ToString()), Type = args[13].ToString() }; Pressure = new Pressure { Unit = args[15].ToString(), Value = FixDouble.ToDouble(args[16].ToString()) }; Symbol = new Symbol { Number = FixDouble.ToDouble(args[18].ToString()), Name = args[19].ToString(), Var = args[20].ToString(), }; Wind = new Wind { Direction = FixDouble.ToDouble(args[22].ToString()), Code = args[23].ToString(), DirectionName = args[24].ToString(), Speed = FixDouble.ToDouble(args[26].ToString()), SpeedName = args[27].ToString(), }; Clouds = new Clouds { Value = args[29].ToString(), All = FixDouble.ToDouble(args[30].ToString()), }; }
public Forecast(XmlNode node) { string fromQuery = "@from"; string toQuery = "@to"; string humidityQuery = "humidity/@value"; From = DateTime.Parse($"{node.SelectSingleNode(fromQuery)?.InnerText:O}"); To = DateTime.Parse($"{node.SelectSingleNode(toQuery)?.InnerText:O}"); Wind = new Wind(node); Temperature = new Temperature(node); Pressure = new Pressure(node); Symbol = new Symbol(node); Humidity = FixDouble.ToDouble(node.SelectSingleNode(humidityQuery)?.InnerText); Clouds = new Clouds(node); Precipitation = new Precipitation(node); }
public WheatherPage() { this.InitializeComponent(); canvasControl.Draw += CanvasControl_Draw1; canvasControl.Invalidate(); Window.Current.VisibilityChanged += Current_VisibilityChanged; canvasWidth(); canvasHeight(); rand = new Random(); sun = new Sun(0, 0, 44, 12); moon = new Moon(150, 75, 44); precip = new Precipitation(cloudHeight * k, 500, 1600); tempType = localSettings.Values["tempType"] != null ? localSettings.Values["tempType"].ToString() : "c"; windType = localSettings.Values["windType"] != null ? localSettings.Values["windType"].ToString() : "kph"; presType = localSettings.Values["presType"] != null ? localSettings.Values["presType"].ToString() : "mb"; precipType = localSettings.Values["precipType"] != null ? localSettings.Values["precipType"].ToString() : "mm"; visType = localSettings.Values["visType"] != null ? localSettings.Values["visType"].ToString() : "km"; days = localSettings.Values["days"] != null?Convert.ToInt32(localSettings.Values["days"].ToString()) : 5; cityName = localSettings.Values["cityName"] != null ? localSettings.Values["cityName"].ToString() : "kiev"; weatherAPI = new WeatherAPI(cityName, days); try { respond = weatherAPI.getRespond(); allWeather = JsonConvert.DeserializeObject <AllWeather>(respond); JObject respondObject = JObject.Parse(respond); IList <JToken> respondForecastList = respondObject["forecast"]["forecastday"].Children().ToList(); forecastDays = new ObservableCollection <ForecastDay>(); foreach (JToken respondForecast in respondForecastList) { ForecastDay forecastDay = respondForecast.ToObject <ForecastDay>(); forecastDay.makeFormatedDate(); forecastDays.Add(forecastDay); } ; foreach (ForecastDay item in forecastDays) { SelectedForecastDay SelectedforecastDay = new SelectedForecastDay( item.dateFormated, getNeedProperty <Day>("maxtemp_", tempType, item.day) + "° ", getNeedProperty <Day>("mintemp_", tempType, item.day) + "° ", getNeedProperty <Day>("avgtemp_", tempType, item.day) + "° " + tempType.ToUpper(), getNeedProperty <Day>("maxwind_", windType, item.day) + " " + windType, getNeedProperty <Day>("totalprecip_", precipType, item.day) + " " + precipType, getNeedProperty <Day>("avgvis_", visType, item.day) + "° " + visType, item.day.avghumidity + "%", item.day.condition.text, "ms-appx:///Assets/weather/" + item.day.condition.icon.Substring(30), item.day.condition.code + "", item.astro.moonset, item.astro.moonrise, item.astro.sunrise, item.astro.sunset); _forecastDays.Add(SelectedforecastDay); } location.Text = allWeather.location.name + ", " + allWeather.location.country; currentTempreture.Text = getNeedProperty <CurrentWeather>("temp_", tempType, allWeather.current) + "° " + tempType; currentDate.Text = DateTime.Now.ToString("ddd d", new CultureInfo("en-US")); currentCondition.Text = allWeather.current.condition.text; currentWind.Text = "Wind" + getNeedProperty <CurrentWeather>("wind_", windType, allWeather.current) + " " + windType + " " + allWeather.current.wind_dir; currentPresure.Text = "Presure " + getNeedProperty <CurrentWeather>("pressure_", presType, allWeather.current) + " " + presType; currentHumidity.Text = "Humidity " + allWeather.current.humidity + "%" + " " + getNeedProperty <CurrentWeather>("precip_", precipType, allWeather.current) + " " + precipType; currentTempFeelslike.Text = "Feelslike " + getNeedProperty <CurrentWeather>("feelslike_", tempType, allWeather.current) + "° " + tempType; currentVis.Text = "Visibility " + getNeedProperty <CurrentWeather>("vis_", visType, allWeather.current) + " " + visType; conditionsString = weatherAPI.getConditions(); conditions2 = new ObservableCollection <Condition>(JsonConvert.DeserializeObject <List <Condition> >(conditionsString)); foreach (Condition cond in JsonConvert.DeserializeObject <List <Condition> >(conditionsString)) { conditionPicker.Items.Add(cond.night); } conditionPicker.SelectedItem = allWeather.current.condition.text; } catch (Exception ex) { Debug.WriteLine(ex); } getFrequency(); clouds = new List <Cloud>(); width = 1700; float x = width / frequency; for (float i = 0; i < frequency; i++) { var cl = new Cloud(x / 2 + i * x, cloudHeight * k + random(-1 * (cloudHeight * k) / 2, (cloudHeight * k) / 1.5f), (int)random(4, 12), cloudHeight, 0); clouds.Add(cl); } moveTimer.Interval = new TimeSpan(1); moveTimer.Tick += MoveTimer_Tick; moveTimer.Start(); }