public void LoadFrom(ThemeLocalizeConfig config) { this.AccentColor = config.AccentColor == default(Color) ? this.AccentColor : config.AccentColor; this.SmallFontSize = config.SmallFontSize == default(double) ? this.SmallFontSize : config.SmallFontSize; this.LargeFontSize = config.LargeFontSize == default(double) ? this.LargeFontSize : config.LargeFontSize; this.FontSize = config.FontSize; this.ItemHeight = config.ItemHeight == default(double) ? this.ItemHeight : config.ItemHeight; this.ItemWidth = config.ItemWidth == default(double) ? this.ItemWidth : config.ItemWidth; this.ItemCornerRadius = config.ItemCornerRadius == default(double) ? this.ItemCornerRadius : config.ItemCornerRadius; this.RowHeight = config.RowHeight == default(double) ? this.RowHeight : config.RowHeight; //this.ForegroundColor = config.ForegroundColor == Colors.White ? this.ForegroundColor : config.ForegroundColor; //var ps = config.GetType().GetProperties(); //foreach (var p in ps) //{ // var find = this.GetType().GetProperty(p.Name); // if (find == null) continue; // if (!find.CanWrite) continue; // find.SetValue(this, p.GetValue(config)); //} this.Language = config.Language; this.ThemeType = config.ThemeType; this.AnimalSpeed = config.AnimalSpeed; this.AccentColorSelectType = config.AccentColorSelectType; this.IsUseAnimal = config.IsUseAnimal; this.Version = config.Version; }
public void LoadFrom(ThemeLocalizeConfig config) { this.AccentColor = config.AccentColor == default(Color) ? this.AccentColor : config.AccentColor; this.SmallFontSize = config.SmallFontSize == default(double) ? this.SmallFontSize : config.SmallFontSize; this.LargeFontSize = config.LargeFontSize == default(double) ? this.LargeFontSize : config.LargeFontSize; this.FontSize = config.FontSize; this.ItemHeight = config.ItemHeight == default(double) ? this.ItemHeight : config.ItemHeight; this.ItemWidth = config.ItemWidth == default(double) ? this.ItemWidth : config.ItemWidth; this.ItemCornerRadius = config.ItemCornerRadius == default(CornerRadius) ? this.ItemCornerRadius : config.ItemCornerRadius; this.RowHeight = config.RowHeight == default(double) ? this.RowHeight : config.RowHeight; this.Language = config.Language; this.ThemeType = config.ThemeType; this.AnimalSpeed = config.AnimalSpeed; this.AccentColorSelectType = config.AccentColorSelectType; this.IsUseAnimal = config.IsUseAnimal; }
public ThemeLocalizeConfig ConvertTo() { ThemeLocalizeConfig themeLocalize = new ThemeLocalizeConfig(); //themeLocalize.AccentColor = this.AccentColor; //themeLocalize.SmallFontSize = this.SmallFontSize; //themeLocalize.LargeFontSize = this.LargeFontSize; //themeLocalize.FontSize = this.FontSize; //themeLocalize.ItemHeight = this.ItemHeight; //themeLocalize.ItemWidth = this.ItemWidth; //themeLocalize.ItemCornerRadius = this.ItemCornerRadius; //themeLocalize.RowHeight = this.RowHeight; //themeLocalize.Language = this.Language; //themeLocalize.ThemeType = this.ThemeType; //themeLocalize.AnimalSpeed = this.AnimalSpeed; //themeLocalize.AccentColorSelectType = this.AccentColorSelectType; //themeLocalize.IsUseAnimal = this.IsUseAnimal; //themeLocalize.Version = this.Version; var ps = this.GetType().GetProperties(); foreach (var p in ps) { var find = typeof(ThemeLocalizeConfig).GetProperty(p.Name); if (find == null) { continue; } if (!find.CanWrite) { continue; } find.SetValue(themeLocalize, p.GetValue(this)); } return(themeLocalize); }
/// <summary> /// 用本地保存的配置初始化主题,如果本地没有保存业务则使用默认主题 /// </summary> /// <param name="builder"> 主程序构建对象 </param> /// <param name="useDefaultTheme"> 默认主题 </param> /// <returns></returns> public static IApplicationBuilder UseLocalTheme(this IApplicationBuilder builder, Action <ThemeService> useDefaultTheme) { IThemeLocalizeService localConfig = ServiceRegistry.Instance.GetInstance <IThemeLocalizeService>(); ThemeLocalizeConfig local = localConfig?.LoadTheme(); if (local == null) { useDefaultTheme?.Invoke(ThemeService.Current); return(builder); } // Do:设置默认主题 builder.UseTheme(l => { l.LoadFrom(local); }); return(builder); }
public ThemeLocalizeConfig ConvertTo() { ThemeLocalizeConfig themeLocalize = new ThemeLocalizeConfig(); themeLocalize.AccentColor = this.AccentColor; themeLocalize.SmallFontSize = this.SmallFontSize; themeLocalize.LargeFontSize = this.LargeFontSize; themeLocalize.FontSize = this.FontSize; themeLocalize.ItemHeight = this.ItemHeight; themeLocalize.ItemWidth = this.ItemWidth; themeLocalize.ItemCornerRadius = this.ItemCornerRadius; themeLocalize.RowHeight = this.RowHeight; themeLocalize.Language = this.Language; themeLocalize.ThemeType = this.ThemeType; themeLocalize.AnimalSpeed = this.AnimalSpeed; themeLocalize.AccentColorSelectType = this.AccentColorSelectType; themeLocalize.IsUseAnimal = this.IsUseAnimal; themeLocalize.Version = this.Version; return(themeLocalize); }