added popup color to scheme

This commit is contained in:
Patrick Kranz 2019-03-29 16:44:41 +01:00
parent 1145336538
commit cafe71c50b
2 changed files with 10 additions and 1 deletions

View file

@ -14,6 +14,9 @@ namespace ColorTool
public uint? foreground = null;
public uint? background = null;
public uint? popupForeground = null;
public uint? popupBackground = null;
public int CalculateIndex(uint value) =>
colorTable.Select((color, idx) => Tuple.Create(color, idx))
.OrderBy(Difference(value))

View file

@ -370,12 +370,18 @@ namespace ColorTool
{
csbiex.ColorTable[i] = colorScheme.colorTable[i];
}
if(colorScheme.background != null && colorScheme.foreground != null)
if (colorScheme.background != null && colorScheme.foreground != null)
{
int fgidx = colorScheme.CalculateIndex(colorScheme.foreground.Value);
int bgidx = colorScheme.CalculateIndex(colorScheme.background.Value);
csbiex.wAttributes = (ushort)(fgidx | (bgidx << 4));
}
if (colorScheme.popupBackground != null && colorScheme.popupForeground != null)
{
int fgidx = colorScheme.CalculateIndex(colorScheme.popupForeground.Value);
int bgidx = colorScheme.CalculateIndex(colorScheme.popupBackground.Value);
csbiex.wPopupAttributes = (ushort)(fgidx | (bgidx << 4));
}
SetConsoleScreenBufferInfoEx(hOut, ref csbiex);
}
if (success)