using System;
using System.Windows.Media;
namespace ClassLibrary1
{
public class ARGBColor
{
public ARGBColor(string Hexadecimal)//#AARRGGBB
{
hexstring = Hexadecimal;
char[] asChar = Hexadecimal.ToCharArray();
string AA = Convert.ToString(asChar[1]) + Convert.ToString(asChar[2]);
string RR = Convert.ToString(asChar[3]) + Convert.ToString(asChar[4]);
string GG = Convert.ToString(asChar[5]) + Convert.ToString(asChar[6]);
string BB = Convert.ToString(asChar[7]) + Convert.ToString(asChar[8]);
a = Byte.Parse(AA, System.Globalization.NumberStyles.HexNumber);
r = Byte.Parse(RR, System.Globalization.NumberStyles.HexNumber);
g = Byte.Parse(GG, System.Globalization.NumberStyles.HexNumber);
b = Byte.Parse(BB, System.Globalization.NumberStyles.HexNumber);
}
public ARGBColor(byte alpha, byte red, byte green, byte blue)
{
a = alpha;
r = red;
g = green;
b = blue;
hexstring = "#" + Convert.ToString(A, 16).PadLeft(2, '0') + Convert.ToString(R, 16).PadLeft(2, '0') + Convert.ToString(G, 16).PadLeft(2, '0') + Convert.ToString(B, 16).PadLeft(2, '0');
}
private string hexstring;
public string Hexstring
{
get { return hexstring; }
set
{
hexstring = value;
char[] asChar = hexstring.ToCharArray();
string AA = Convert.ToString(asChar[1]) + Convert.ToString(asChar[2]);
string RR = Convert.ToString(asChar[3]) + Convert.ToString(asChar[4]);
string GG = Convert.ToString(asChar[5]) + Convert.ToString(asChar[6]);
string BB = Convert.ToString(asChar[7]) + Convert.ToString(asChar[8]);
a = Byte.Parse(AA, System.Globalization.NumberStyles.HexNumber);
r = Byte.Parse(RR, System.Globalization.NumberStyles.HexNumber);
g = Byte.Parse(GG, System.Globalization.NumberStyles.HexNumber);
b = Byte.Parse(BB, System.Globalization.NumberStyles.HexNumber);
}
}
private byte a;
public byte A
{
get { return a; }
set { a = value; Hexstring = "#" + Convert.ToString(a, 16).PadLeft(2, '0') + Convert.ToString(r, 16).PadLeft(2, '0') + Convert.ToString(g, 16).PadLeft(2, '0') + Convert.ToString(b, 16).PadLeft(2, '0'); }
}
private byte r;
public byte R
{
get { return r; }
set { r = value; Hexstring = "#" + Convert.ToString(a, 16).PadLeft(2, '0') + Convert.ToString(r, 16).PadLeft(2, '0') + Convert.ToString(g, 16).PadLeft(2, '0') + Convert.ToString(b, 16).PadLeft(2, '0'); }
}
private byte b;
public byte B
{
get { return b; }
set { b = value; Hexstring = "#" + Convert.ToString(a, 16).PadLeft(2, '0') + Convert.ToString(r, 16).PadLeft(2, '0') + Convert.ToString(g, 16).PadLeft(2, '0') + Convert.ToString(b, 16).PadLeft(2, '0'); }
}
private byte g;
public byte G
{
get { return g; }
set { g = value; Hexstring = "#" + Convert.ToString(a, 16).PadLeft(2, '0') + Convert.ToString(r, 16).PadLeft(2, '0') + Convert.ToString(g, 16).PadLeft(2, '0') + Convert.ToString(b, 16).PadLeft(2, '0'); }
}
}
}