mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-06-02 21:45:13 -05:00
TryParseHex should be able to work with 0x prefix
This commit is contained in:
parent
3f01c09a65
commit
a6cb6900ec
|
|
@ -486,7 +486,11 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
|||
return $"#{red:X2}{green:X2}{blue:X2}";
|
||||
}
|
||||
|
||||
public static bool TryParseHex(this string hex, out int result) => int.TryParse(hex, System.Globalization.NumberStyles.HexNumber, CultureInfo.CurrentCulture, out result);
|
||||
public static bool TryParseHex(this string hex, out int result) {
|
||||
hex = hex.Trim();
|
||||
if (hex.StartsWith("0x")) hex = hex.Substring(2);
|
||||
return int.TryParse(hex, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out result);
|
||||
}
|
||||
|
||||
public static (byte, byte, byte) ToRgb(this (double hue, double sat, double bright) hsb) => Theme.FromHSB(hsb.hue, hsb.sat, hsb.bright);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user