Fixed a bug with the Hexadecimal color selector

This commit is contained in:
2022-05-30 15:26:03 +02:00
parent 77f940c201
commit 68310609b7

View File

@@ -128,13 +128,14 @@ namespace Paint_2
private void btnSetColor_Click(object sender, EventArgs e)
{
string value = tbxColorHex.Text;
int fromBase = 16;
value = value.Replace("#", String.Empty);
int R, G, B;
try
{
R = Convert.ToInt32(value[0] + value[1]);
G = Convert.ToInt32(value[2] + value[3]);
B = Convert.ToInt32(value[4] + value[5]);
R = Convert.ToInt32(String.Concat(value[0], value[1]), fromBase);
G = Convert.ToInt32(String.Concat(value[2], value[3]), fromBase);
B = Convert.ToInt32(String.Concat(value[4], value[4]), fromBase);
}
catch (Exception exception)
{