public Convert ( object value, |
||
value | object | |
targetType | ||
parameter | object | |
language | string | |
return | object |
private static TileContent GenerateForecastTile(HeWeatherModel model, bool isNight, Uri uri, string glanceFull, string lockdetial, int todayIndex, CitySettingsModel currentCity, SettingsModel settings) { var ctosConverter = new ConditiontoTextConverter(); var ctoiConverter = new ConditiontoImageConverter(); var forecaset = new TileContent() { Visual = new TileVisual() { DisplayName = currentCity.City, Branding = TileBranding.NameAndLogo, LockDetailedStatus1 = currentCity.City + " " + model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter) + "\r\n" + lockdetial, TileLarge = new TileBinding() { Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileText(), new TileGroup() { Children = { new TileSubgroup() { Weight = 1, }, new TileSubgroup() { Weight = 1, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 1 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight?model.DailyForecast[todayIndex+1].Condition.NightCond:model.DailyForecast[todayIndex+1].Condition.DayCond,null,isNight,null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 1, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 2 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight?model.DailyForecast[todayIndex+2].Condition.NightCond:model.DailyForecast[todayIndex+2].Condition.DayCond,null,isNight,null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 1, }, } }, new TileText(), new TileGroup() { Children = { new TileSubgroup() { Weight = 1, }, new TileSubgroup() { Weight = 1, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 3 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight?model.DailyForecast[todayIndex+3].Condition.NightCond:model.DailyForecast[todayIndex+3].Condition.DayCond,null,isNight,null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 1, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 4 ? model.DailyForecast[todayIndex+4].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 4 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+4].Condition.NightCond : model.DailyForecast[todayIndex+4].Condition.DayCond, null, isNight, null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children= { new TileText() { Text = model.DailyForecast.Length > todayIndex + 4 ? model.DailyForecast[todayIndex+4].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 4 ? model.DailyForecast[todayIndex+4].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 1, }, } } } } }, TileMedium = new TileBinding() { Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileText() { }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].Date.ToString("ddd") : "", Align = TileTextAlign.Center }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } } }, TileWide = new TileBinding() { Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileGroup() { Children = { new TileSubgroup() { Weight = 1, Children = { new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 1 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+1].Condition.NightCond : model.DailyForecast[todayIndex+1].Condition.DayCond, null, isNight, null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children = { new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 1, Children = { new TileText() { Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 2 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+2].Condition.NightCond : model.DailyForecast[todayIndex+2].Condition.DayCond, null, isNight, null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children = { new TileText() { Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 1, Children = { new TileText() { Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].Date.ToString("ddd") : "", }, new TileImage() { Source = model.DailyForecast.Length > todayIndex + 3 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+3].Condition.NightCond : model.DailyForecast[todayIndex+3].Condition.DayCond, null, isNight, null)) : new TileImageSource(""), }, } }, new TileSubgroup() { Weight = 1, TextStacking = TileTextStacking.Bottom, Children = { new TileText() { Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "", Style = TileTextStyle.CaptionSubtle }, } }, } }, } } } } }; return forecaset; }
public static TileContent GenerateNormalTile(HeWeatherModel model, bool isNight, string glance, string glanceFull, Uri uri, int todayIndex, CitySettingsModel currentCity, SettingsModel settings) { var ctosConverter = new ConditiontoTextConverter(); var ctoiConverter = new ConditiontoImageConverter(); var loader = new ResourceLoader(); #region TileContent NowContent = new TileContent() { Visual = new TileVisual() { Branding = TileBranding.Auto, DisplayName = currentCity.City, TileMedium = new TileBinding() { Content = new TileBindingContentAdaptive() { PeekImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TilePeekImage() { Source = new TileImageSource(uri.ToString()), }), BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileText(), new TileText() { Text = (string)ctosConverter.Convert(model.NowWeather.Now.Condition,null,null,null), Align = TileTextAlign.Center }, new TileText() { Text = model.DailyForecast[todayIndex].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Align = TileTextAlign.Center }, new TileText() { Text = model.DailyForecast[todayIndex].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle } } } }, TileWide = new TileBinding() { DisplayName = glance, Branding = TileBranding.NameAndLogo, Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileGroup() { Children= { new TileSubgroup() { Weight = 1, Children = { new TileText() { Text = model.DailyForecast[todayIndex].Date.ToString("ddd"), Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, new TileImage() { Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)) }, new TileText() { Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, } }, new TileSubgroup() { Weight = 2, TextStacking = TileTextStacking.Center, Children = { new TileText() { Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Center }, new TileText() { Text = (string)ctosConverter.Convert(model.NowWeather.Now.Condition,null,null,null), Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast[todayIndex].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast[todayIndex].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Center } } }, new TileSubgroup() { Weight = 1, Children = { new TileText() { Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = loader.GetString("ScaleText"), Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, new TileText() { Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = loader.GetString("HumText"), Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 2, TextStacking = TileTextStacking.Center, Children = { new TileText() { Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Left }, new TileText() { Text = model.NowWeather.Wind.Speed.Actual(settings.Preferences.SpeedParameter) + model.NowWeather.Wind.Speed.DanWei(settings.Preferences.SpeedParameter), Align = TileTextAlign.Left, Style = TileTextStyle.Caption }, new TileText() { Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Left }, new TileText() { Text = model.DailyForecast[todayIndex].Humidity.ToString() + "%", Align = TileTextAlign.Left, Style = TileTextStyle.Caption }, } }, } } }, PeekImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TilePeekImage() { Source = new TileImageSource(uri.ToString()), }), } }, TileLarge = new TileBinding() { Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileGroup() { Children = { new TileSubgroup() { Weight = 30, Children = { new TileImage() { Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)) }, } }, new TileSubgroup() { TextStacking = TileTextStacking.Center, Children = { new TileText() { Text = model.DailyForecast[todayIndex].Date.ToString("ddd"), Style = TileTextStyle.Base }, new TileText() { Text = model.DailyForecast[todayIndex].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString() + '~' + model.DailyForecast[todayIndex].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Align = TileTextAlign.Auto, Style = TileTextStyle.Caption }, new TileText() { Text = glanceFull, Align = TileTextAlign.Auto, Style = TileTextStyle.CaptionSubtle, Wrap = true } } }, }, }, new TileText(), new TileGroup() { Children = { new TileSubgroup() { Weight = 30, Children = { new TileImage() { Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)) }, } }, new TileSubgroup() { TextStacking = TileTextStacking.Center, Children = { new TileText() { Text = model.DailyForecast[todayIndex+1].Date.ToString("ddd"), Style = TileTextStyle.Base }, new TileText() { Text = model.DailyForecast[todayIndex + 1].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString() + '~' + model.DailyForecast[todayIndex + 1].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Align = TileTextAlign.Auto, Style = TileTextStyle.Caption }, new TileText() { Text = loader.GetString("ScaleText")+": "+model.DailyForecast[todayIndex+1].Wind.Speed.Actual(settings.Preferences.SpeedParameter) + model.DailyForecast[todayIndex+1].Wind.Speed.DanWei(settings.Preferences.SpeedParameter), Align = TileTextAlign.Auto, Style = TileTextStyle.CaptionSubtle, }, new TileText() { Text = loader.GetString("HumText")+": "+model.DailyForecast[todayIndex+1].Humidity.ToString() + "%", Align = TileTextAlign.Auto, Style = TileTextStyle.CaptionSubtle, Wrap = true } } }, } } }, PeekImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TilePeekImage() { Source = new TileImageSource(uri.ToString()), }), } } } }; #endregion return NowContent; }
private static TileContent GenerateNowTile(HeWeatherModel model, bool isNight, Uri uri, string glanceFull, string lockdetial, int todayIndex, CitySettingsModel currentCity, SettingsModel settings) { var ctosConverter = new ConditiontoTextConverter(); var ctoiConverter = new ConditiontoImageConverter(); var loader = new ResourceLoader(); var now = new TileContent() { Visual = new TileVisual() { LockDetailedStatus1 = currentCity.City + " " + model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter) + "\r\n" + lockdetial, DisplayName = currentCity.City, Branding = TileBranding.NameAndLogo, TileMedium = new TileBinding() { Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileText(), new TileGroup() { Children = { new TileSubgroup() { Weight = 1, }, new TileSubgroup() { Weight = 1, Children = { new TileImage() { Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)), }, } }, new TileSubgroup() { Weight = 1, } } }, new TileText() { Text = model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter), Style = TileTextStyle.Body, Align = TileTextAlign.Center } } }, }, TileLarge = new TileBinding() { Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileText(), new TileGroup() { Children = { new TileSubgroup() { Weight = 3, }, new TileSubgroup() { Weight = 2, Children = { new TileImage() { Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)), }, } }, new TileSubgroup() { Weight = 3, } } }, new TileText() { Text = model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter), Style = TileTextStyle.Subheader, Align = TileTextAlign.Center }, new TileText() { Text = glanceFull, Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle, Wrap = true } } } }, TileSmall = new TileBinding() { Content = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new TileText() { Text = model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter), Align = TileTextAlign.Center, Style = TileTextStyle.Body } } } }, TileWide = new TileBinding() { DisplayName = currentCity.City, Branding = TileBranding.NameAndLogo, Content = new TileBindingContentAdaptive() { BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage() { Source = new TileImageSource(uri.ToString()), Overlay = 70 }), Children = { new TileGroup() { Children= { new TileSubgroup() { Weight = 1, Children = { new TileText() { Text = model.DailyForecast[todayIndex+1].Date.ToString("ddd"), Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, new TileImage() { Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.DailyForecast[todayIndex+1].Condition.DayCond,null,isNight,null)) }, new TileText() { Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, } }, new TileSubgroup() { Weight = 2, TextStacking = TileTextStacking.Center, Children = { new TileText() { Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Center }, new TileText() { Text = (string)ctosConverter.Convert(model.DailyForecast[todayIndex+1].Condition.DayCond,null,null,null), Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Align = TileTextAlign.Center, Style = TileTextStyle.Caption }, new TileText() { Text = model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(), Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Center } } }, new TileSubgroup() { Weight = 1, Children = { new TileText() { Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = loader.GetString("ScaleText"), Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, new TileText() { Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, new TileText() { Text = loader.GetString("HumText"), Align = TileTextAlign.Center, Style = TileTextStyle.CaptionSubtle }, } }, new TileSubgroup() { Weight = 2, TextStacking = TileTextStacking.Center, Children = { new TileText() { Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Left }, new TileText() { Text = model.DailyForecast[todayIndex+1].Wind.Speed.Actual(settings.Preferences.SpeedParameter) + model.NowWeather.Wind.Speed.DanWei(settings.Preferences.SpeedParameter), Align = TileTextAlign.Left, Style = TileTextStyle.Caption }, new TileText() { Style = TileTextStyle.CaptionSubtle, Align = TileTextAlign.Left }, new TileText() { Text = model.DailyForecast[todayIndex+1].Humidity.ToString() + "%", Align = TileTextAlign.Left, Style = TileTextStyle.Caption }, } }, } } }, } }, } }; return now; }