Colors and Color
-
I am looking at the system.windows.media.colors class and the system.windows.media.color struct I assume there is some kind of collection in the colors class of the color struct, so when you type colors. it gives a drop down list of the color structs that are contained within the colors class. I need to replicate the same kind of functionality, but am unsure on how to go about building the colors class to give the drop down showing named instances of the structs. Any help most welcome Mark
-
I am looking at the system.windows.media.colors class and the system.windows.media.color struct I assume there is some kind of collection in the colors class of the color struct, so when you type colors. it gives a drop down list of the color structs that are contained within the colors class. I need to replicate the same kind of functionality, but am unsure on how to go about building the colors class to give the drop down showing named instances of the structs. Any help most welcome Mark
-
what about something like: foreach(Color c in Colors) { ComboBox1.Items.Add(c.ToString()); }
-
I am trying to understand the underlying code of the colors class, so i can replcate it for a differnt use. It has the functionality i need, but i am going to use it for something other than colors
-
I am looking at the system.windows.media.colors class and the system.windows.media.color struct I assume there is some kind of collection in the colors class of the color struct, so when you type colors. it gives a drop down list of the color structs that are contained within the colors class. I need to replicate the same kind of functionality, but am unsure on how to go about building the colors class to give the drop down showing named instances of the structs. Any help most welcome Mark
You could examine the source of the Color struct. A very simple implementation (loads missed out!) using the proper spelling...
public struct Colour
{
private byte m_R;
private byte m_G;
private byte m_B;public Colour(byte r, byte g, byte b) { m\_R = r; m\_G = g; m\_B = b; } public byte R { get { return m\_R; } } public byte G { get { return m\_G; } } public byte B { get { return m\_B; } } public static Colour White { get { return new Colour(255, 255, 255); } } public static Colour Black { get { return new Colour(0, 0, 0); } } }
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
ahh then you may want to use an 'enum' public enum Values{ One = 1 Two = 2 } then acces like Values.One or Values.Two
modified on Thursday, January 8, 2009 12:28 PM
-
You could examine the source of the Color struct. A very simple implementation (loads missed out!) using the proper spelling...
public struct Colour
{
private byte m_R;
private byte m_G;
private byte m_B;public Colour(byte r, byte g, byte b) { m\_R = r; m\_G = g; m\_B = b; } public byte R { get { return m\_R; } } public byte G { get { return m\_G; } } public byte B { get { return m\_B; } } public static Colour White { get { return new Colour(255, 255, 255); } } public static Colour Black { get { return new Colour(0, 0, 0); } } }
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
You could examine the source of the Color struct. A very simple implementation (loads missed out!) using the proper spelling...
public struct Colour
{
private byte m_R;
private byte m_G;
private byte m_B;public Colour(byte r, byte g, byte b) { m\_R = r; m\_G = g; m\_B = b; } public byte R { get { return m\_R; } } public byte G { get { return m\_G; } } public byte B { get { return m\_B; } } public static Colour White { get { return new Colour(255, 255, 255); } } public static Colour Black { get { return new Colour(0, 0, 0); } } }
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)