主にプログラミング関連のメモ帳 ♪(✿╹ヮ╹)ノ
書いてあるコードは自己責任でご自由にどうぞ。記事本文の無断転載は禁止です。
2016/01/31
Visual Studio のデザイナーが死んでいるので、 システム Brush リソースを出力させた。
その一覧と色を載せておきます。
とおもったら、はてなブログがパースしきれなかったようなので、 Gist においておきます。
Raw なりをコピペして、 HTML として保存してブラウザーで開けばいいと思う。
ちなみに、出力させたコード
適当に書いたものなのでかんべんしてね
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main(string[] args)
{
var dictionary = new Dictionary<string, List<SolidColorBrush>>();
var list = new List<string>();
var input = @"C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10586.0\Generic\generic.xaml";
var output = @"C:\generic.html";
var regex1 = new Regex("<ResourceDictionary x:Key=\"(?<ThemeType>.*)\">");
var regex2 = new Regex("<SolidColorBrush x:Key=\"(?<BrushName>.*)\" Color=\"(?<ColorHex>.*)\"(\\s)?/>");
var type = "";
using (var sr = new StreamReader(input))
{
while (true)
{
var line = sr.ReadLine();
if (line == null)
break;
if (regex1.IsMatch(line))
{
type = regex1.Match(line).Groups["ThemeType"].Value;
dictionary.Add(type, new List<SolidColorBrush>());
list.Add(type);
}
else if (regex2.IsMatch(line))
{
var match = regex2.Match(line);
if (match.Groups["BrushName"].Value.StartsWith("System"))
continue;
dictionary[type].Add(new SolidColorBrush(match.Groups["BrushName"].Value, match.Groups["ColorHex"].Value));
}
}
}
using (var sw = new StreamWriter(output))
{
sw.WriteLine("<table>");
sw.WriteLine("<thead>");
sw.WriteLine("<tr>");
sw.WriteLine("<th>Key</th>");
foreach (var kvp in dictionary)
sw.WriteLine($"<th>{kvp.Key}</th>");
sw.WriteLine("</thead>");
sw.WriteLine("<tbody>");
foreach (var value in dictionary[list[0]])
{
sw.WriteLine("<tr>");
sw.WriteLine($"<td>{value.Key}</td>");
if (value.Color.StartsWith("#"))
{
sw.WriteLine(
$"<td style=\"background-color: rgba({Convert.ToInt32(value?.R, 16)}, {Convert.ToInt32(value?.G, 16)}, {Convert.ToInt32(value?.B, 16)}, {Convert.ToInt32(value?.A, 16)/255.0})\">{value?.Color}</td>");
}
else if (value.Color.StartsWith("{"))
sw.WriteLine(
$"<td>{value?.Color}</td>");
else
sw.WriteLine(
$"<td bgcolor=\"{value?.Color}\">{value?.Color}</td>");
foreach (var t in list.Skip(1))
{
var color = dictionary[t].FirstOrDefault(w => w.Key == value.Key);
if (color.Color.StartsWith("#"))
{
sw.WriteLine(
$"<td style=\"background-color: rgba({Convert.ToInt32(color?.R, 16)}, {Convert.ToInt32(color?.G, 16)}, {Convert.ToInt32(color?.B, 16)}, {Convert.ToInt32(color?.A, 16)/255.0})\">{color?.Color}</td>");
}
else if (color.Color.StartsWith("{"))
sw.WriteLine(
$"<td>{color?.Color}</td>");
else
sw.WriteLine(
$"<td bgcolor=\"{color?.Color}\">{color?.Color}</td>");
}
sw.WriteLine("</tr>");
}
sw.WriteLine("</tbody>");
sw.WriteLine("</table>");
}
}
}
internal class SolidColorBrush
{
public string Key { get; }
public string Color { get; }
public string A { get; }
public string R { get; }
public string G { get; }
public string B { get; }
public SolidColorBrush(string key, string color)
{
Key = key;
if (color.StartsWith("#"))
{
A = color.Substring(1, 2);
R = color.Substring(3, 2);
G = color.Substring(5, 2);
B = color.Substring(7, 2);
}
Color = color;
}
}
}