public List <DataItemCombo> GetIcons(IconSource icon = IconSource.MaterialDesign, IconSize iconSize = IconSize.PX18) { var lstIcons = new List <DataItemCombo>(); var filename = $"{icon.GetDescription<IconSource>()}.json"; filename = Path.Combine(_settings.Folder.Icons, filename); var records = JsonConvert.DeserializeObject <List <OxIcon> >(System.IO.File.ReadAllText(filename)); var _id = 0; foreach (var record in records) { _id++; var data = new DataItemCombo(); var prefix = string.Empty; if (icon == IconSource.MaterialDesign) { prefix = "mdi"; } var suffix = $"{prefix}-{iconSize.GetDescription<IconSize>()}"; var name = $"{prefix} {prefix}-{record.Name} {suffix}"; data.Key = _id; data.Text = name; data.Descricao = record.Name; lstIcons.Add(data); } lstIcons = lstIcons.OrderBy(f => f.Descricao).ToList(); return(lstIcons); }
public void CreateFileEnumFor(IconSource icon = IconSource.MaterialDesign, IconSize iconSize = IconSize.PX18) { const string quote = "\""; var filename = $"{icon.GetDescription<IconSource>()}.json"; filename = Path.Combine(_settings.Folder.Icons, filename); var records = JsonConvert.DeserializeObject <List <OxIcon> >(System.IO.File.ReadAllText(filename)); var _id = 0; var ws = File.CreateText("c:\\usr\\MaterialDesignIcon.cs"); ws.WriteLine("using System.ComponentModel;"); ws.WriteLine("namespace Works.Web.Common.Icons"); ws.WriteLine("\t\t{"); ws.WriteLine("\t\t\tpublic enum MaterialDesignIcon"); ws.WriteLine("\t\t\t{"); foreach (var record in records) { var prefix = "mdi"; var name = $"{prefix}-{record.Name}"; var desc = $"\t\t\t\t\t[Description({quote}{name}{quote})"; ws.WriteLine(desc); var arr = record.Name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); var nameCapitalized = string.Empty; foreach (var oneString in arr) { nameCapitalized += oneString.Substring(0, 1).ToUpper() + oneString.Substring(1); } ws.WriteLine($"\t\t\t\t\t{nameCapitalized},"); } ws.WriteLine("\t\t\t}"); ws.WriteLine("\t\t}"); ws.Flush(); ws.Close(); }