standardize casing on PascalCase

Feedback from review. I've decided to go with PascalCase as that's more standard in C# and recommended by MS (see the "Field" row in the table on https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions)
This commit is contained in:
Will Fuqua 2019-04-26 12:34:55 +07:00
parent 12fff3126b
commit f8f4f263a5
No known key found for this signature in database
GPG key ID: 67B6F489167C16A3
12 changed files with 194 additions and 196 deletions

View file

@ -63,12 +63,12 @@ namespace ColorTool
.First().Item2;
private static Func<Tuple<uint, int>, double> Difference(uint c1) =>
// heuristic 1: nearest neighbor in RGB space
// tup => Distance(RGB(c1), RGB(tup.Item1));
// heuristic 2: nearest neighbor in RGB space
// tup => Distance(HSV(c1), HSV(tup.Item1));
// heuristic 3: weighted RGB L2 distance
tup => WeightedRGBSimilarity(c1, tup.Item1);
// heuristic 1: nearest neighbor in RGB space
// tup => Distance(RGB(c1), RGB(tup.Item1));
// heuristic 2: nearest neighbor in RGB space
// tup => Distance(HSV(c1), HSV(tup.Item1));
// heuristic 3: weighted RGB L2 distance
tup => WeightedRGBSimilarity(c1, tup.Item1);
private static double WeightedRGBSimilarity(uint c1, uint c2)
{

View file

@ -11,50 +11,62 @@ namespace ColorTool
/// <summary>
/// Displays the color table that demonstrates the current colorscheme.
/// </summary>
class ColorTable
static class ColorTable
{
const int DARK_BLACK = 0;
const int DARK_BLUE = 1;
const int DARK_GREEN = 2;
const int DARK_CYAN = 3;
const int DARK_RED = 4;
const int DARK_MAGENTA = 5;
const int DARK_YELLOW = 6;
const int DARK_WHITE = 7;
const int BRIGHT_BLACK = 8;
const int BRIGHT_BLUE = 9;
const int BRIGHT_GREEN = 10;
const int BRIGHT_CYAN = 11;
const int BRIGHT_RED = 12;
const int BRIGHT_MAGENTA = 13;
const int BRIGHT_YELLOW = 14;
const int BRIGHT_WHITE = 15;
private const int DarkBlack = 0;
private const int DarkBlue = 1;
private const int DarkGreen = 2;
private const int DarkCyan = 3;
private const int DarkRed = 4;
private const int DarkMagenta = 5;
private const int DarkYellow = 6;
private const int DarkWhite = 7;
private const int BrightBlack = 8;
private const int BrightBlue = 9;
private const int BrightGreen = 10;
private const int BrightCyan = 11;
private const int BrightRed = 12;
private const int BrightMagenta = 13;
private const int BrightYellow = 14;
private const int BrightWhite = 15;
// This is the order of colors when output by the table.
private static readonly IReadOnlyList<int> outputFgs = new[]
private static readonly IReadOnlyList<int> Foregrounds = new[]
{
BRIGHT_WHITE,
DARK_BLACK,
BRIGHT_BLACK,
DARK_RED,
BRIGHT_RED,
DARK_GREEN,
BRIGHT_GREEN,
DARK_YELLOW,
BRIGHT_YELLOW,
DARK_BLUE,
BRIGHT_BLUE,
DARK_MAGENTA,
BRIGHT_MAGENTA,
DARK_CYAN,
BRIGHT_CYAN,
DARK_WHITE,
BRIGHT_WHITE
BrightWhite,
DarkBlack,
BrightBlack,
DarkRed,
BrightRed,
DarkGreen,
BrightGreen,
DarkYellow,
BrightYellow,
DarkBlue,
BrightBlue,
DarkMagenta,
BrightMagenta,
DarkCyan,
BrightCyan,
DarkWhite,
BrightWhite
};
private static readonly IReadOnlyList<int> Backgrounds = new[]
{
DarkBlack,
DarkRed,
DarkGreen,
DarkYellow,
DarkBlue,
DarkMagenta,
DarkCyan,
DarkWhite
};
private const string TestText = " gYw ";
private static readonly IReadOnlyList<string> FGs = new[]
private static readonly IReadOnlyList<string> AnsiForegroundSequences = new[]
{
"m",
"1m",
@ -76,7 +88,7 @@ namespace ColorTool
"1;37m"
};
private static readonly IReadOnlyList<string> BGs = new[]
private static readonly IReadOnlyList<string> AnsiBackgroundSequences = new[]
{
"m",
"40m",
@ -89,18 +101,6 @@ namespace ColorTool
"47m"
};
private static readonly IReadOnlyList<int> saneBgs = new[]
{
DARK_BLACK,
DARK_RED,
DARK_GREEN,
DARK_YELLOW,
DARK_BLUE,
DARK_MAGENTA,
DARK_CYAN,
DARK_WHITE
};
public static void PrintTable()
{
ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor));
@ -109,36 +109,35 @@ namespace ColorTool
ConsoleColor currentForeground = Console.ForegroundColor;
Console.Write("\t");
for (int bg = 0; bg < BGs.Count; bg++)
for (int bg = 0; bg < AnsiBackgroundSequences.Count; bg++)
{
if (bg > 0) Console.Write(" ");
Console.Write(" ");
Console.Write(bg == 0 ? " " : BGs[bg]);
Console.Write(bg == 0 ? " " : AnsiBackgroundSequences[bg]);
Console.Write(" ");
}
Console.WriteLine();
for (int fg = 0; fg < FGs.Count; fg++)
for (int fg = 0; fg < AnsiForegroundSequences.Count; fg++)
{
Console.ForegroundColor = currentForeground;
Console.BackgroundColor = currentBackground;
if (fg >= 0) Console.Write(FGs[fg] + "\t");
if (fg >= 0) Console.Write(AnsiForegroundSequences[fg] + "\t");
if (fg == 0) Console.ForegroundColor = currentForeground;
else Console.ForegroundColor = colors[outputFgs[fg - 1]];
else Console.ForegroundColor = colors[Foregrounds[fg - 1]];
for (int bg = 0; bg < BGs.Count; bg++)
for (int bg = 0; bg < AnsiBackgroundSequences.Count; bg++)
{
if (bg > 0) Console.Write(" ");
if (bg == 0)
Console.BackgroundColor = currentBackground;
else Console.BackgroundColor = colors[saneBgs[bg - 1]];
else Console.BackgroundColor = colors[Backgrounds[bg - 1]];
Console.Write(TestText);
Console.BackgroundColor = currentBackground;
}
Console.Write("\n");
}
Console.Write("\n");
@ -150,22 +149,22 @@ namespace ColorTool
public static void PrintTableWithVt()
{
Console.Write("\t");
for (int bg = 0; bg < BGs.Count; bg++)
for (int bg = 0; bg < AnsiBackgroundSequences.Count; bg++)
{
if (bg > 0) Console.Write(" ");
Console.Write(" ");
Console.Write(bg == 0 ? " " : BGs[bg]);
Console.Write(bg == 0 ? " " : AnsiBackgroundSequences[bg]);
Console.Write(" ");
}
Console.WriteLine();
for (int fg = 0; fg < FGs.Count; fg++)
for (int fg = 0; fg < AnsiForegroundSequences.Count; fg++)
{
Console.Write("\x1b[m");
if (fg >= 0)
{
Console.Write(FGs[fg] + "\t");
Console.Write(AnsiForegroundSequences[fg] + "\t");
}
if (fg == 0)
@ -174,10 +173,10 @@ namespace ColorTool
}
else
{
Console.Write("\x1b[" + FGs[fg]);
Console.Write("\x1b[" + AnsiForegroundSequences[fg]);
}
for (int bg = 0; bg < BGs.Count; bg++)
for (int bg = 0; bg < AnsiBackgroundSequences.Count; bg++)
{
if (bg > 0)
{
@ -189,14 +188,13 @@ namespace ColorTool
}
else
{
Console.Write("\x1b[" + BGs[bg]);
Console.Write("\x1b[" + AnsiBackgroundSequences[bg]);
}
Console.Write(TestText);
Console.Write("\x1b[49m");
}
Console.Write("\n");
}
Console.Write("\n");

View file

@ -4,5 +4,6 @@
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>

View file

@ -8,9 +8,11 @@ using System.Runtime.InteropServices;
namespace ColorTool
{
class ConsoleAPI
static class ConsoleAPI
{
////////////////////////////////////////////////////////////////////////
private const int StdOutputHandle = -11;
public const int ColorTableSize = 16;
[StructLayout(LayoutKind.Sequential)]
public struct COORD
{
@ -58,10 +60,7 @@ namespace ColorTool
}
}
public static int STD_OUTPUT_HANDLE = -11;
public static IntPtr GetStdOutputHandle() => GetStdHandle(STD_OUTPUT_HANDLE);
public static IntPtr GetStdOutputHandle() => GetStdHandle(StdOutputHandle);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
@ -86,13 +85,10 @@ namespace ColorTool
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode);
////////////////////////////////////////////////////////////////////////
public static uint RGB(int r, int g, int b)
{
return (uint)r + (((uint)g) << 8) + (((uint)b) << 16);
}
public const int COLOR_TABLE_SIZE = 16;
}
}

View file

@ -5,6 +5,9 @@
namespace ColorTool
{
/// <summary>
/// Keeps track of the color table indices for the background/foreground in a colorscheme.
/// </summary>
public readonly struct ConsoleAttributes
{
public ConsoleAttributes(uint? background, uint? foreground, uint? popupBackground, uint? popupForeground)

View file

@ -16,24 +16,24 @@ namespace ColorTool.ConsoleTargets
class VirtualTerminalConsoleTarget : IConsoleTarget
{
// Use a Console index in to get a VT index out.
public static readonly IReadOnlyList<int> VT_INDICIES = new[]
public static readonly IReadOnlyList<int> VirtualTerminalIndices = new[]
{
0, // DARK_BLACK
4, // DARK_BLUE
2, // DARK_GREEN
6, // DARK_CYAN
1, // DARK_RED
5, // DARK_MAGENTA
3, // DARK_YELLOW
7, // DARK_WHITE
8+0, // BRIGHT_BLACK
8+4, // BRIGHT_BLUE
8+2, // BRIGHT_GREEN
8+6, // BRIGHT_CYAN
8+1, // BRIGHT_RED
8+5, // BRIGHT_MAGENTA
8+3, // BRIGHT_YELLOW
8+7, // BRIGHT_WHITE
0, // Dark Black
4, // Dark Blue
2, // Dark Green
6, // Dark Cyan
1, // Dark Red
5, // Dark Magenta
3, // Dark Yellow
7, // Dark White
8+0, // Bright Black
8+4, // Bright Blue
8+2, // Bright Green
8+6, // Bright Cyan
8+1, // Bright Red
8+5, // Bright Magenta
8+3, // Bright Yellow
8+7, // Bright White
};
public void ApplyColorScheme(ColorScheme colorScheme, bool quietMode)
@ -50,7 +50,7 @@ namespace ColorTool.ConsoleTargets
for (int i = 0; i < colorScheme.ColorTable.Length; i++)
{
int vtIndex = VT_INDICIES[i];
int vtIndex = VirtualTerminalIndices[i];
Color color = colorScheme[i];
string s = $"\x1b]4;{vtIndex};rgb:{color.R:X}/{color.G:X}/{color.B:X}\x7";
Console.Write(s);

View file

@ -11,33 +11,15 @@ using System.Linq;
namespace ColorTool
{
class Program
static class Program
{
static bool quietMode = false;
static bool reportErrors = false;
static bool setDefaults = false;
static bool setProperties = true;
static bool setUnixStyle = false;
private static bool quietMode = false;
private static bool reportErrors = false;
private static bool setDefaults = false;
private static bool setProperties = true;
private static bool setUnixStyle = false;
static void Usage()
{
Console.WriteLine(Resources.Usage,
string.Join($"{Environment.NewLine} ", SchemeManager.GetParsers().Select(p => p.Name)));
}
static void OutputUsage()
{
Console.WriteLine(Resources.OutputUsage);
}
static void Version()
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var info = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
Console.WriteLine($"colortool v{info.FileVersion}");
}
static void Main(string[] args)
public static void Main(string[] args)
{
if (args.Length < 1)
{
@ -124,11 +106,29 @@ namespace ColorTool
}
}
private static void Usage()
{
Console.WriteLine(Resources.Usage,
string.Join($"{Environment.NewLine} ", SchemeManager.GetParsers().Select(p => p.Name)));
}
private static void OutputUsage()
{
Console.WriteLine(Resources.OutputUsage);
}
private static void Version()
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var info = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
Console.WriteLine($"colortool v{info.FileVersion}");
}
/// <summary>
/// Returns an enumerable of consoles that we want to apply the colorscheme to.
/// The contents of this enumerable depends on the user's provided command line flags.
/// </summary>
public static IEnumerable<IConsoleTarget> GetConsoleTargets()
private static IEnumerable<IConsoleTarget> GetConsoleTargets()
{
if (setDefaults)
{

View file

@ -48,7 +48,6 @@ namespace ColorTool
Console.WriteLine(schemeDirectory);
}
public static void PrintSchemes()
{
var schemeDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "schemes");

View file

@ -21,7 +21,7 @@ namespace ColorTool.SchemeParsers
private const string FileExtension = ".ini";
// These are in Windows Color table order - BRG, not RGB.
internal static readonly IReadOnlyList<string> COLOR_NAMES = new[]
internal static readonly IReadOnlyList<string> ColorNames = new[]
{
"DARK_BLACK",
"DARK_BLUE",
@ -53,16 +53,16 @@ namespace ColorTool.SchemeParsers
string filename = FindIniScheme(schemeName);
if (filename == null) return null;
string[] tableStrings = new string[COLOR_TABLE_SIZE];
string[] tableStrings = new string[ColorTableSize];
uint[] colorTable = null;
uint? foregroundColor = null;
uint? backgroundColor = null;
uint? popupForegroundColor = null;
uint? popupBackgroundColor = null;
for (int i = 0; i < COLOR_TABLE_SIZE; i++)
for (int i = 0; i < ColorTableSize; i++)
{
string name = COLOR_NAMES[i];
string name = ColorNames[i];
StringBuilder buffer = new StringBuilder(512);
GetPrivateProfileString("table", name, null, buffer, 512, filename);
@ -82,16 +82,16 @@ namespace ColorTool.SchemeParsers
{
try
{
colorTable = new uint[COLOR_TABLE_SIZE];
for (int i = 0; i < COLOR_TABLE_SIZE; i++)
colorTable = new uint[ColorTableSize];
for (int i = 0; i < ColorTableSize; i++)
{
colorTable[i] = ParseColor(tableStrings[i]);
}
if (ReadAttributes("popup", out var foreground, out var background))
{
var foregroundIndex = (COLOR_NAMES as IList<string>).IndexOf(foreground);
var backgroundIndex = (COLOR_NAMES as IList<string>).IndexOf(background);
var foregroundIndex = (ColorNames as IList<string>).IndexOf(foreground);
var backgroundIndex = (ColorNames as IList<string>).IndexOf(background);
if (foregroundIndex != -1 && backgroundIndex != -1)
{
popupForegroundColor = colorTable[foregroundIndex];
@ -101,8 +101,8 @@ namespace ColorTool.SchemeParsers
if (ReadAttributes("screen", out foreground, out background))
{
var foregroundIndex = (COLOR_NAMES as IList<string>).IndexOf(foreground);
var backgroundIndex = (COLOR_NAMES as IList<string>).IndexOf(background);
var foregroundIndex = (ColorNames as IList<string>).IndexOf(foreground);
var backgroundIndex = (ColorNames as IList<string>).IndexOf(background);
if (foregroundIndex != -1 && backgroundIndex != -1)
{
foregroundColor = colorTable[foregroundIndex];
@ -139,14 +139,14 @@ namespace ColorTool.SchemeParsers
StringBuilder buffer = new StringBuilder(512);
GetPrivateProfileString(section, "FOREGROUND", null, buffer, 512, filename);
foreground = buffer.ToString();
if (!COLOR_NAMES.Contains(foreground))
if (!ColorNames.Contains(foreground))
return false;
buffer = new StringBuilder(512);
GetPrivateProfileString(section, "BACKGROUND", null, buffer, 512, filename);
background = buffer.ToString();
if (!COLOR_NAMES.Contains(background))
if (!ColorNames.Contains(background))
return false;
return true;

View file

@ -16,24 +16,24 @@ namespace ColorTool.SchemeParsers
class JsonParser : ISchemeParser
{
private const string FileExtension = ".json";
private static IReadOnlyList<string> CONCFG_COLOR_NAMES = new[]
private static readonly IReadOnlyList<string> ConcfgColorNames = new[]
{
"black", // DARK_BLACK
"dark_blue", // DARK_BLUE
"dark_green", // DARK_GREEN
"dark_cyan", // DARK_CYAN
"dark_red", // DARK_RED
"dark_magenta", // DARK_MAGENTA
"dark_yellow", // DARK_YELLOW
"gray", // DARK_WHITE
"dark_gray", // BRIGHT_BLACK
"blue", // BRIGHT_BLUE
"green", // BRIGHT_GREEN
"cyan", // BRIGHT_CYAN
"red", // BRIGHT_RED
"magenta", // BRIGHT_MAGENTA
"yellow", // BRIGHT_YELLOW
"white" // BRIGHT_WHITE
"black", // Dark Black
"dark_blue", // Dark Blue
"dark_green", // Dark Green
"dark_cyan", // Dark Cyan
"dark_red", // Dark Red
"dark_magenta", // Dark Magenta
"dark_yellow", // Dark Yellow
"gray", // Dark White
"dark_gray", // Bright Black
"blue", // Bright Blue
"green", // Bright Green
"cyan", // Bright Cyan
"red", // Bright Red
"magenta", // Bright Magenta
"yellow", // Bright Yellow
"white" // Bright White
};
public string Name { get; } = "concfg Parser";
@ -50,10 +50,10 @@ namespace ColorTool.SchemeParsers
{
XmlNode root = xmlDoc.DocumentElement;
XmlNodeList children = root.ChildNodes;
uint[] colorTable = new uint[COLOR_TABLE_SIZE]; ;
for (int i = 0; i < COLOR_TABLE_SIZE; i++)
uint[] colorTable = new uint[ColorTableSize]; ;
for (int i = 0; i < ColorTableSize; i++)
{
string name = CONCFG_COLOR_NAMES[i];
string name = ConcfgColorNames[i];
var node = children.OfType<XmlNode>().Where(n => n.Name == name).Single();
colorTable[i] = ParseColor(node.InnerText);
}
@ -68,8 +68,8 @@ namespace ColorTool.SchemeParsers
var parts = popupNode.InnerText.Split(',');
if (parts.Length == 2)
{
var foregroundIndex = (CONCFG_COLOR_NAMES as IList<string>).IndexOf(parts[0]);
var backgroundIndex = (CONCFG_COLOR_NAMES as IList<string>).IndexOf(parts[1]);
var foregroundIndex = (ConcfgColorNames as IList<string>).IndexOf(parts[0]);
var backgroundIndex = (ConcfgColorNames as IList<string>).IndexOf(parts[1]);
if (foregroundIndex != -1 && backgroundIndex != -1)
{
popupForeground = colorTable[foregroundIndex];
@ -87,8 +87,8 @@ namespace ColorTool.SchemeParsers
var parts = screenNode.InnerText.Split(',');
if (parts.Length == 2)
{
var foregroundIndex = (CONCFG_COLOR_NAMES as IList<string>).IndexOf(parts[0]);
var backgroundIndex = (CONCFG_COLOR_NAMES as IList<string>).IndexOf(parts[1]);
var foregroundIndex = (ConcfgColorNames as IList<string>).IndexOf(parts[0]);
var backgroundIndex = (ConcfgColorNames as IList<string>).IndexOf(parts[1]);
if (foregroundIndex != -1 && backgroundIndex != -1)
{
screenForeground = colorTable[foregroundIndex];

View file

@ -16,30 +16,31 @@ namespace ColorTool.SchemeParsers
class XmlSchemeParser : ISchemeParser
{
// In Windows Color Table order
private static readonly string[] PLIST_COLOR_NAMES =
private static readonly string[] PListColorNames =
{
"Ansi 0 Color", // DARK_BLACK
"Ansi 4 Color", // DARK_BLUE
"Ansi 2 Color", // DARK_GREEN
"Ansi 6 Color", // DARK_CYAN
"Ansi 1 Color", // DARK_RED
"Ansi 5 Color", // DARK_MAGENTA
"Ansi 3 Color", // DARK_YELLOW
"Ansi 7 Color", // DARK_WHITE
"Ansi 8 Color", // BRIGHT_BLACK
"Ansi 12 Color", // BRIGHT_BLUE
"Ansi 10 Color", // BRIGHT_GREEN
"Ansi 14 Color", // BRIGHT_CYAN
"Ansi 9 Color", // BRIGHT_RED
"Ansi 13 Color", // BRIGHT_MAGENTA
"Ansi 11 Color", // BRIGHT_YELLOW
"Ansi 15 Color" // BRIGHT_WHITE
"Ansi 0 Color", // Dark Black
"Ansi 4 Color", // Dark Blue
"Ansi 2 Color", // Dark Green
"Ansi 6 Color", // Dark Cyan
"Ansi 1 Color", // Dark Red
"Ansi 5 Color", // Dark Magenta
"Ansi 3 Color", // Dark Yellow
"Ansi 7 Color", // Dark White
"Ansi 8 Color", // Bright Black
"Ansi 12 Color", // Bright Blue
"Ansi 10 Color", // Bright Green
"Ansi 14 Color", // Bright Cyan
"Ansi 9 Color", // Bright Red
"Ansi 13 Color", // Bright Magenta
"Ansi 11 Color", // Bright Yellow
"Ansi 15 Color" // Bright White
};
private const string FG_KEY = "Foreground Color";
private const string BG_KEY = "Background Color";
private const string RED_KEY = "Red Component";
private const string GREEN_KEY = "Green Component";
private const string BLUE_KEY = "Blue Component";
private const string ForegroundKey = "Foreground Color";
private const string BackgroundKey = "Background Color";
private const string RedKey = "Red Component";
private const string GreenKey = "Green Component";
private const string BlueKey = "Blue Component";
private const string FileExtension = ".itermcolors";
public string Name { get; } = "iTerm Parser";
@ -54,7 +55,7 @@ namespace ColorTool.SchemeParsers
XmlNode root = xmlDoc.GetElementsByTagName("dict")[0];
XmlNodeList children = root.ChildNodes;
uint[] colorTable = new uint[COLOR_TABLE_SIZE];
uint[] colorTable = new uint[ColorTableSize];
uint? fgColor = null, bgColor = null;
int colorsFound = 0;
bool success = false;
@ -65,12 +66,12 @@ namespace ColorTool.SchemeParsers
XmlNode components = tableEntry.NextSibling;
success = ParseRgbFromXml(components, ref rgb);
if (!success) { break; }
else if (tableEntry.InnerText == FG_KEY) { fgColor = rgb; }
else if (tableEntry.InnerText == BG_KEY) { bgColor = rgb; }
else if (-1 != (index = Array.IndexOf(PLIST_COLOR_NAMES, tableEntry.InnerText)))
else if (tableEntry.InnerText == ForegroundKey) { fgColor = rgb; }
else if (tableEntry.InnerText == BackgroundKey) { bgColor = rgb; }
else if (-1 != (index = Array.IndexOf(PListColorNames, tableEntry.InnerText)))
{ colorTable[index] = rgb; colorsFound++; }
}
if (colorsFound < COLOR_TABLE_SIZE)
if (colorsFound < ColorTableSize)
{
if (reportErrors)
{
@ -97,15 +98,15 @@ namespace ColorTool.SchemeParsers
{
if (c.Name == "key")
{
if (c.InnerText == RED_KEY)
if (c.InnerText == RedKey)
{
r = (int)(255 * Convert.ToDouble(c.NextSibling.InnerText, CultureInfo.InvariantCulture));
}
else if (c.InnerText == GREEN_KEY)
else if (c.InnerText == GreenKey)
{
g = (int)(255 * Convert.ToDouble(c.NextSibling.InnerText, CultureInfo.InvariantCulture));
}
else if (c.InnerText == BLUE_KEY)
else if (c.InnerText == BlueKey)
{
b = (int)(255 * Convert.ToDouble(c.NextSibling.InnerText, CultureInfo.InvariantCulture));
}

View file

@ -26,7 +26,7 @@ namespace ColorTool.SchemeWriters
file.WriteLine("[table]");
for (int i = 0; i < 16; i++)
{
string line = IniSchemeParser.COLOR_NAMES[i];
string line = IniSchemeParser.ColorNames[i];
line += " = ";
uint color = csbiex.ColorTable[i];
uint r = color & (0x000000ff);
@ -40,15 +40,15 @@ namespace ColorTool.SchemeWriters
file.WriteLine("[screen]");
var forgroundIndex = csbiex.wAttributes & 0xF;
var backgroundIndex = csbiex.wAttributes >> 4;
file.WriteLine($"FOREGROUND = {IniSchemeParser.COLOR_NAMES[forgroundIndex]}");
file.WriteLine($"BACKGROUND = {IniSchemeParser.COLOR_NAMES[backgroundIndex]}");
file.WriteLine($"FOREGROUND = {IniSchemeParser.ColorNames[forgroundIndex]}");
file.WriteLine($"BACKGROUND = {IniSchemeParser.ColorNames[backgroundIndex]}");
file.WriteLine();
file.WriteLine("[popup]");
forgroundIndex = csbiex.wPopupAttributes & 0xF;
backgroundIndex = csbiex.wPopupAttributes >> 4;
file.WriteLine($"FOREGROUND = {IniSchemeParser.COLOR_NAMES[forgroundIndex]}");
file.WriteLine($"BACKGROUND = {IniSchemeParser.COLOR_NAMES[backgroundIndex]}");
file.WriteLine($"FOREGROUND = {IniSchemeParser.ColorNames[forgroundIndex]}");
file.WriteLine($"BACKGROUND = {IniSchemeParser.ColorNames[backgroundIndex]}");
}
}
catch (Exception ex)