Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Colors and Color

Colors and Color

Scheduled Pinned Locked Moved C#
helptutorial
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mark_w_
    wrote on last edited by
    #1

    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

    M D 2 Replies Last reply
    0
    • M mark_w_

      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

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      what about something like: foreach(Color c in Colors) { ComboBox1.Items.Add(c.ToString()); }

      M 1 Reply Last reply
      0
      • M musefan

        what about something like: foreach(Color c in Colors) { ComboBox1.Items.Add(c.ToString()); }

        M Offline
        M Offline
        mark_w_
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • M mark_w_

          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

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • M mark_w_

            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

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            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)

            M M 2 Replies Last reply
            0
            • M musefan

              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

              M Offline
              M Offline
              mark_w_
              wrote on last edited by
              #6

              thats the kind of functionality i need, but it need to display structs, which is where i start getting stuck :(

              1 Reply Last reply
              0
              • D DaveyM69

                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)

                M Offline
                M Offline
                mark_w_
                wrote on last edited by
                #7

                EDIT - Scratch that, i have worked out how the above sorts everything out for me THANKS :) I agree about the spelling ;)

                1 Reply Last reply
                0
                • D DaveyM69

                  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)

                  M Offline
                  M Offline
                  musefan
                  wrote on last edited by
                  #8

                  yeah thats what i meant to write lol

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups