private void InitialConverterParameter(SettingsModel settings) { TemperatureDecoratorConverter.ChangeParameter(settings.Preferences.TemperatureParameter); DateTimeConverter.ChangeParameter(settings.Preferences.GetForecastFormat()); var p = settings.Preferences.GetHourlyFormat(); HourMinuteConverter.ChangeParameter(p); UpdateTimeConverter.ChangeParameter(p); RefreshCompleteConverter.ChangeParameter(p); WindSpeedConverter.ChangeParameter(settings.Preferences.WindParameter, settings.Preferences.SpeedParameter); PressureConverter.ChangeParameter(settings.Preferences.PressureParameter); VisibilityConverter.ChangeParameter(settings.Preferences.LengthParameter); ImmersiveHourConverter.ChangeParameter(settings.Preferences.GetImmersiveHourFormat()); ImmersiveMinConverter.ChangeParameter(settings.Preferences.GetImmersiveMinFormat()); }
private async Task itemInit(CityViewModel item, HeWeatherModel weather) { item.NowCondition = weather.NowWeather.Now.Condition; item.Temperature = weather.NowWeather.Temprature; string p = TemperatureDecoratorConverter.GetCurrentDeco(); item.Decorator = p; var utcOffset = weather.Location.UpdateTime - weather.Location.UtcTime; var current = DateTimeHelper.ReviseLoc(utcOffset); var todayIndex = Array.FindIndex(weather.DailyForecast, x => { return(x.Date.Date == current.Date); }); var hourIndex = Array.FindIndex(weather.HourlyForecast, x => { return((x.DateTime - current).TotalSeconds > 0); }); if (todayIndex < 0) { todayIndex = 0; } if (hourIndex < 0) { hourIndex = 0; } item.High = weather.DailyForecast[todayIndex].HighTemp; item.Low = weather.DailyForecast[todayIndex].LowTemp; var isNight = Generator.CalcIsNight(weather.Location.UpdateTime, weather.DailyForecast[todayIndex].SunRise, weather.DailyForecast[todayIndex].SunSet, new Models.Location(item.latitude, item.longitude)); item.Glance = Glance.GenerateGlanceDescription(weather, isNight, settings.Preferences.TemperatureParameter, DateTime.Now); var uri = await settings.Immersive.GetCurrentBackgroundAsync(weather.NowWeather.Now.Condition, isNight); if (uri != null) { try { item.Background = new BitmapImage(uri); } catch (Exception) { } } item.data = null; }