public static ThemeAccentInfo FromAccent(TelegramThemeType type, Color accent, Color outgoing = default) { var color = accent; if (color == default) { color = BootStrapper.Current.UISettings.GetColorValue(UIColorType.Accent); } var colorizer = ThemeColorizer.FromTheme(type, _accent[type][AccentShade.Default], color); var outgoingColorizer = outgoing != default ? ThemeColorizer.FromTheme(type, _accent[type][AccentShade.Default], outgoing) : null; var values = new Dictionary <string, Color>(); var shades = new Dictionary <AccentShade, Color>(); foreach (var item in _map[type]) { if (outgoingColorizer != null && item.Key.EndsWith("Outgoing")) { values[item.Key] = outgoingColorizer.Colorize(item.Value); } else { values[item.Key] = colorizer.Colorize(item.Value); } } foreach (var item in _accent[type]) { shades[item.Key] = colorizer.Colorize(item.Value); } return(new ThemeAccentInfo(type, accent, values, shades)); }
public static Color Colorize(TelegramThemeType type, Color accent, string key) { var colorizer = ThemeColorizer.FromTheme(type, _accent[type][AccentShade.Default], accent); if (_map[type].TryGetValue(key, out Color color)) { return(colorizer.Colorize(color)); } var lookup = type == TelegramThemeType.Day ? ThemeIncoming.Light : ThemeIncoming.Dark; return(colorizer.Colorize(lookup[key].Color)); }
public static ThemeAccentInfo FromAccent(TelegramThemeType type, Color accent) { var color = accent; if (color == default) { color = BootStrapper.Current.UISettings.GetColorValue(UIColorType.Accent); } var colorizer = ThemeColorizer.FromTheme(type, _accent[type], color); var values = new Dictionary <string, Color>(); foreach (var item in _map[type]) { values[item.Key] = colorizer.Colorize(item.Value); } return(new ThemeAccentInfo(type, accent, values)); }
public static ThemeCustomInfo FromFile(string path, IList <string> lines) { var values = new Dictionary <string, Color>(); var shades = new Dictionary <AccentShade, Color>(); var requested = SettingsService.Current.Appearance.RequestedTheme; var accent = _accent[requested == TelegramTheme.Dark ? TelegramThemeType.Night : TelegramThemeType.Day][AccentShade.Default]; var name = string.Empty; foreach (var line in lines) { if (line.StartsWith("name: ")) { name = line.Substring("name: ".Length); } else if (line.StartsWith("parent: ")) { requested = (TelegramTheme)int.Parse(line.Substring("parent: ".Length)); accent = _accent[requested == TelegramTheme.Dark ? TelegramThemeType.Night : TelegramThemeType.Day][AccentShade.Default]; } else if (line.Equals("!") || line.Equals("#") || string.IsNullOrWhiteSpace(line)) { continue; } else { var split = line.Split(':'); if (split.Length < 2) { continue; } var key = split[0].Trim(); var value = split[1].Trim(); if (value.StartsWith("#") && int.TryParse(value.Substring(1), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int hexValue)) { byte a = (byte)((hexValue & 0xff000000) >> 24); byte r = (byte)((hexValue & 0x00ff0000) >> 16); byte g = (byte)((hexValue & 0x0000ff00) >> 8); byte b = (byte)(hexValue & 0x000000ff); if (key == "accent") { accent = Color.FromArgb(a, r, g, b); } else { values[key] = Color.FromArgb(a, r, g, b); } } else if (key == "accent" && value == "default") { accent = default; } } } var color = accent; if (color == default) { color = BootStrapper.Current.UISettings.GetColorValue(UIColorType.Accent); } var type = requested == TelegramTheme.Dark ? TelegramThemeType.Night : TelegramThemeType.Day; var colorizer = ThemeColorizer.FromTheme(type, _accent[type][AccentShade.Default], color); foreach (var item in _accent[type]) { shades[item.Key] = colorizer.Colorize(item.Value); } return(new ThemeCustomInfo(path, accent, values, shades) { Name = name, Path = path, Parent = requested, }); }