Esempio n. 1
0
        static void Main()
        {
            //this code comes after the setup below

            //create an instance of the ColorController:
            ColorController cc = new ColorController();

            //initialize some standard colors:
            cc["yellow"] = new Color(255, 255, 0);
            cc["orange"] = new Color(255, 128, 0);
            cc["purple"] = new Color(128, 0, 255);

            //initialize some personalized colors:
            //they are kind of random, this is just an example.
            cc["sunshine"] = new Color(255, 54, 0);
            cc["toast"]    = new Color(255, 153, 51);
            cc["rainyday"] = new Color(255, 0, 255);

            //let's clone.
            Color c1 = ColorController["yellow"].Clone() as Color;   //will match yellow's RGB
            Color c2 = ColorController["toast"].Clone() as Color;    //will match toast's RGB
            Color c3 = ColorController["rainyday"].Clone() as Color; //will match rainyday's RGB

            //yeah so... why is this useful?
            //the only thing I see is, setting
            //cc["yellow"] to the variable c1 makes typing more code easier.
            //but couldn't that just happen with a = ??
            //what's up with cloning?? :\
        }
        static void Main()
        {
            ColorController colorController = new ColorController();

            // Initialize with standard colors
            colorController["yellow"] = new Color(255, 255, 0);
            colorController["orange"] = new Color(255, 128, 0);
            colorController["purple"] = new Color(128, 0, 255);

            // User adds personlized colors
            colorController["sunny"] = new Color(255, 54, 0);
            colorController["tasty"] = new Color(255, 153, 51);
            colorController["rainy"] = new Color(255, 0, 255);

            // User clones selected colors
            Color c1 = colorController["yellow"].Clone() as Color;
            Color c2 = colorController["tasty"].Clone() as Color;
            Color c3 = colorController["rainy"].Clone() as Color;

            // Wait for user
            Console.ReadKey();
        }