mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added color name variable for name parser
This commit is contained in:
parent
c5ecb6af06
commit
e75e437ee7
3 changed files with 9 additions and 2 deletions
|
@ -239,8 +239,7 @@ private void UpdateControls(MyColor color, ColorType type)
|
|||
txtDecimal.Text = ColorHelpers.ColorToDecimal(color).ToString();
|
||||
}
|
||||
|
||||
Color knownColor = ColorHelpers.FindClosestKnownColor(color);
|
||||
lblNameValue.Text = Helpers.GetProperName(knownColor.Name);
|
||||
lblNameValue.Text = ColorHelpers.GetColorName(color);
|
||||
|
||||
controlChangingColor = false;
|
||||
}
|
||||
|
|
|
@ -456,5 +456,11 @@ public static Color FindClosestKnownColor(Color color)
|
|||
List<Color> colors = GetKnownColors();
|
||||
return colors.Aggregate(Color.Black, (accu, curr) => ColorDifference(color, curr) < ColorDifference(color, accu) ? curr : accu);
|
||||
}
|
||||
|
||||
public static string GetColorName(Color color)
|
||||
{
|
||||
Color knownColor = FindClosestKnownColor(color);
|
||||
return Helpers.GetProperName(knownColor.Name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ public class CodeMenuEntryPixelInfo : CodeMenuEntry
|
|||
public static readonly CodeMenuEntryPixelInfo b1 = new CodeMenuEntryPixelInfo("b1", "Blue color (0-1). Specify decimal precision with {n}, defaults to 3.");
|
||||
public static readonly CodeMenuEntryPixelInfo hex = new CodeMenuEntryPixelInfo("hex", "Hex color value (Lowercase)");
|
||||
public static readonly CodeMenuEntryPixelInfo HEX = new CodeMenuEntryPixelInfo("HEX", "Hex color value (Uppercase)");
|
||||
public static readonly CodeMenuEntryPixelInfo name = new CodeMenuEntryPixelInfo("name", "Color name");
|
||||
public static readonly CodeMenuEntryPixelInfo x = new CodeMenuEntryPixelInfo("x", "X position");
|
||||
public static readonly CodeMenuEntryPixelInfo y = new CodeMenuEntryPixelInfo("y", "Y position");
|
||||
public static readonly CodeMenuEntryPixelInfo n = new CodeMenuEntryPixelInfo("n", "New line");
|
||||
|
@ -61,6 +62,7 @@ public static string Parse(string input, Color color, Point position)
|
|||
Replace(b255.ToPrefixString(), color.B.ToString(), StringComparison.InvariantCultureIgnoreCase).
|
||||
Replace(HEX.ToPrefixString(), ColorHelpers.ColorToHex(color), StringComparison.InvariantCulture).
|
||||
Replace(hex.ToPrefixString(), ColorHelpers.ColorToHex(color).ToLowerInvariant(), StringComparison.InvariantCultureIgnoreCase).
|
||||
Replace(name.ToPrefixString(), ColorHelpers.GetColorName(color), StringComparison.InvariantCultureIgnoreCase).
|
||||
Replace(x.ToPrefixString(), position.X.ToString(), StringComparison.InvariantCultureIgnoreCase).
|
||||
Replace(y.ToPrefixString(), position.Y.ToString(), StringComparison.InvariantCultureIgnoreCase).
|
||||
Replace(n.ToPrefixString(), Environment.NewLine, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
|
Loading…
Reference in a new issue