<#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.IO" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="System.Text.RegularExpressions" #> <#@ output extension=".xaml" encoding="utf-8" #> <# StringBuilder FontString = new StringBuilder(); FontString.AppendLine(""); FontString.AppendLine(""); FontString.AppendLine(""); string cssPath = this.Host.ResolvePath("iconfont.css"); string svgPath = this.Host.ResolvePath("iconfont.js"); if (File.Exists(cssPath)) { string cssContent = File.ReadAllText(cssPath, Encoding.UTF8); MatchCollection matchs = Regex.Matches(cssContent, "\\.icon-(?.+?):before.+?\\{.+?content:.+?\"\\\\(?e.+?)\";.+?\\}", RegexOptions.Singleline); foreach (Match match in matchs) { string name = match.Groups["name"].Value; //name = Regex.Replace(name,"(a-(\\d{4,}(.*)?_fluent_|SegoeFluentIconsRegular-))|(_regular_icon|$)","",RegexOptions.Singleline); string value = match.Groups["value"].Value; FontString.AppendLine(string.Format("\t&#x{1};", name, value)); } } if (File.Exists(svgPath)) { FontString.AppendLine(""); FontString.AppendLine(""); string svgContent = File.ReadAllText(svgPath, Encoding.UTF8); MatchCollection matchs = Regex.Matches(svgContent, ".+?)\".+?>(?.+?)"); foreach (Match match in matchs) { string name = match.Groups["name"].Value; string symbol = match.Groups["value"].Value; StringBuilder value =new StringBuilder(); MatchCollection pathMatchs = Regex.Matches(symbol,".+?)\""); foreach(Match pathMatch in pathMatchs) { value.AppendLine("\t\t"+pathMatch.Groups["value"].Value); } FontString.AppendLine(string.Format("\t\n{1}\t", name, value)); } } FontString.AppendLine(""); FontString.AppendLine(""); FontString.AppendLine(""); string content = FontString.ToString(); string savePath =Path.Combine(this.Host.ResolvePath(""),@"..\Themes\FontGeometry.xaml"); //File.WriteAllText(savePath,content,Encoding.UTF8); #> <#=content#>