How to Get All Color List from Xamarin Forms?

Or I need to add one by one to List?

Tagged:

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Have you tried getting the elements of the enumeration? That's just C# and not Xamarin specific. Should be just like how you would get all the enum values in a WPF or WinForms app.

  • LearnEverythingLearnEverything USMember ✭✭

    Thanks for the reply.

    I just created a class that get all list of colors or random light and dark colors.

    `public static List GetSystemColorList()
    {
    var colors = new List();
    colors.Add(new ColorItem() { Color = Color.Accent, Name = "Accent" });
    colors.Add(new ColorItem() { Color = Color.AliceBlue, Name = "AliceBlue" });
    colors.Add(new ColorItem() { Color = Color.MintCream, Name = "MintCream" });
    colors.Add(new ColorItem() { Color = Color.MistyRose, Name = "MistyRose" });
    colors.Add(new ColorItem() { Color = Color.Moccasin, Name = "Moccasin" });
    colors.Add(new ColorItem() { Color = Color.NavajoWhite, Name = "NavajoWhite" });
    colors.Add(new ColorItem() { Color = Color.Navy, Name = "Navy" });
    colors.Add(new ColorItem() { Color = Color.OldLace, Name = "OldLace" });
    colors.Add(new ColorItem() { Color = Color.MidnightBlue, Name = "MidnightBlue" });
    colors.Add(new ColorItem() { Color = Color.Olive, Name = "Olive" });
    colors.Add(new ColorItem() { Color = Color.Orange, Name = "Orange" });
    colors.Add(new ColorItem() { Color = Color.OrangeRed, Name = "OrangeRed" });
    colors.Add(new ColorItem() { Color = Color.Orchid, Name = "Orchid" });
    colors.Add(new ColorItem() { Color = Color.PaleGoldenrod, Name = "PaleGoldenrod" });
    colors.Add(new ColorItem() { Color = Color.PaleGreen, Name = "PaleGreen" });
    colors.Add(new ColorItem() { Color = Color.PaleTurquoise, Name = "PaleTurquoise" });
    colors.Add(new ColorItem() { Color = Color.OliveDrab, Name = "OliveDrab" });
    colors.Add(new ColorItem() { Color = Color.PaleVioletRed, Name = "PaleVioletRed" });
    colors.Add(new ColorItem() { Color = Color.MediumVioletRed, Name = "MediumVioletRed" });
    colors.Add(new ColorItem() { Color = Color.MediumSpringGreen, Name = "MediumSpringGreen" });
    colors.Add(new ColorItem() { Color = Color.LightSkyBlue, Name = "LightSkyBlue" });
    colors.Add(new ColorItem() { Color = Color.LightSlateGray, Name = "LightSlateGray" });
    colors.Add(new ColorItem() { Color = Color.LightSteelBlue, Name = "LightSteelBlue" });
    colors.Add(new ColorItem() { Color = Color.LightYellow, Name = "LightYellow" });
    colors.Add(new ColorItem() { Color = Color.Lime, Name = "Lime" });
    colors.Add(new ColorItem() { Color = Color.LimeGreen, Name = "LimeGreen" });
    colors.Add(new ColorItem() { Color = Color.MediumTurquoise, Name = "MediumTurquoise" });
    colors.Add(new ColorItem() { Color = Color.Linen, Name = "Linen" });
    colors.Add(new ColorItem() { Color = Color.Maroon, Name = "Maroon" });
    colors.Add(new ColorItem() { Color = Color.MediumAquamarine, Name = "MediumAquamarine" });
    colors.Add(new ColorItem() { Color = Color.MediumBlue, Name = "MediumBlue" });
    colors.Add(new ColorItem() { Color = Color.MediumOrchid, Name = "MediumOrchid" });
    colors.Add(new ColorItem() { Color = Color.MediumSeaGreen, Name = "MediumSeaGreen" });
    colors.Add(new ColorItem() { Color = Color.MediumSlateBlue, Name = "MediumSlateBlue" });
    colors.Add(new ColorItem() { Color = Color.Magenta, Name = "Magenta" });
    colors.Add(new ColorItem() { Color = Color.LightSeaGreen, Name = "LightSeaGreen" });
    colors.Add(new ColorItem() { Color = Color.PapayaWhip, Name = "PapayaWhip" });
    colors.Add(new ColorItem() { Color = Color.Peru, Name = "Peru" });
    colors.Add(new ColorItem() { Color = Color.SpringGreen, Name = "SpringGreen" });
    colors.Add(new ColorItem() { Color = Color.SteelBlue, Name = "SteelBlue" });
    colors.Add(new ColorItem() { Color = Color.Tan, Name = "Tan" });
    colors.Add(new ColorItem() { Color = Color.Teal, Name = "Teal" });
    colors.Add(new ColorItem() { Color = Color.Thistle, Name = "Thistle" });
    colors.Add(new ColorItem() { Color = Color.Tomato, Name = "Tomato" });
    colors.Add(new ColorItem() { Color = Color.Snow, Name = "Snow" });
    colors.Add(new ColorItem() { Color = Color.Transparent, Name = "Transparent" });
    colors.Add(new ColorItem() { Color = Color.Violet, Name = "Violet" });
    colors.Add(new ColorItem() { Color = Color.Wheat, Name = "Wheat" });
    colors.Add(new ColorItem() { Color = Color.White, Name = "White" });
    colors.Add(new ColorItem() { Color = Color.WhiteSmoke, Name = "WhiteSmoke" });
    colors.Add(new ColorItem() { Color = Color.Yellow, Name = "Yellow" });
    colors.Add(new ColorItem() { Color = Color.YellowGreen, Name = "YellowGreen" });
    colors.Add(new ColorItem() { Color = Color.Turquoise, Name = "Turquoise" });
    colors.Add(new ColorItem() { Color = Color.PeachPuff, Name = "PeachPuff" });
    colors.Add(new ColorItem() { Color = Color.SlateGray, Name = "SlateGray" });
    colors.Add(new ColorItem() { Color = Color.SkyBlue, Name = "SkyBlue" });
    colors.Add(new ColorItem() { Color = Color.Pink, Name = "Pink" });
    colors.Add(new ColorItem() { Color = Color.Plum, Name = "Plum" });
    colors.Add(new ColorItem() { Color = Color.PowderBlue, Name = "PowderBlue" });
    colors.Add(new ColorItem() { Color = Color.Purple, Name = "Purple" });
    colors.Add(new ColorItem() { Color = Color.Red, Name = "Red" });
    colors.Add(new ColorItem() { Color = Color.RosyBrown, Name = "RosyBrown" });
    colors.Add(new ColorItem() { Color = Color.SlateBlue, Name = "SlateBlue" });
    colors.Add(new ColorItem() { Color = Color.RoyalBlue, Name = "RoyalBlue" });
    colors.Add(new ColorItem() { Color = Color.Salmon, Name = "Salmon" });
    colors.Add(new ColorItem() { Color = Color.SandyBrown, Name = "SandyBrown" });
    colors.Add(new ColorItem() { Color = Color.SeaGreen, Name = "SeaGreen" });
    colors.Add(new ColorItem() { Color = Color.SeaShell, Name = "SeaShell" });
    colors.Add(new ColorItem() { Color = Color.Sienna, Name = "Sienna" });
    colors.Add(new ColorItem() { Color = Color.Silver, Name = "Silver" });
    colors.Add(new ColorItem() { Color = Color.SaddleBrown, Name = "SaddleBrown" });
    colors.Add(new ColorItem() { Color = Color.LightSalmon, Name = "LightSalmon" });
    colors.Add(new ColorItem() { Color = Color.MediumPurple, Name = "MediumPurple" });
    colors.Add(new ColorItem() { Color = Color.LightGreen, Name = "LightGreen" });
    colors.Add(new ColorItem() { Color = Color.Crimson, Name = "Crimson" });
    colors.Add(new ColorItem() { Color = Color.Cyan, Name = "Cyan" });
    colors.Add(new ColorItem() { Color = Color.LightPink, Name = "LightPink" });
    colors.Add(new ColorItem() { Color = Color.DarkCyan, Name = "DarkCyan" });
    colors.Add(new ColorItem() { Color = Color.DarkGoldenrod, Name = "DarkGoldenrod" });
    colors.Add(new ColorItem() { Color = Color.DarkGray, Name = "DarkGray" });
    colors.Add(new ColorItem() { Color = Color.Cornsilk, Name = "Cornsilk" });
    colors.Add(new ColorItem() { Color = Color.DarkGreen, Name = "DarkGreen" });
    colors.Add(new ColorItem() { Color = Color.DarkMagenta, Name = "DarkMagenta" });
    colors.Add(new ColorItem() { Color = Color.DarkOliveGreen, Name = "DarkOliveGreen" });
    colors.Add(new ColorItem() { Color = Color.DarkOrange, Name = "DarkOrange" });
    colors.Add(new ColorItem() { Color = Color.DarkOrchid, Name = "DarkOrchid" });
    colors.Add(new ColorItem() { Color = Color.DarkRed, Name = "DarkRed" });
    colors.Add(new ColorItem() { Color = Color.DarkSalmon, Name = "DarkSalmon" });
    colors.Add(new ColorItem() { Color = Color.DarkKhaki, Name = "DarkKhaki" });
    colors.Add(new ColorItem() { Color = Color.DarkSeaGreen, Name = "DarkSeaGreen" });
    colors.Add(new ColorItem() { Color = Color.CornflowerBlue, Name = "CornflowerBlue" });
    colors.Add(new ColorItem() { Color = Color.Chocolate, Name = "Chocolate" });
    colors.Add(new ColorItem() { Color = Color.AntiqueWhite, Name = "AntiqueWhite" });
    colors.Add(new ColorItem() { Color = Color.Aqua, Name = "Aqua" });
    colors.Add(new ColorItem() { Color = Color.Aquamarine, Name = "Aquamarine" });
    colors.Add(new ColorItem() { Color = Color.Azure, Name = "Azure" });
    colors.Add(new ColorItem() { Color = Color.Beige, Name = "Beige" });
    colors.Add(new ColorItem() { Color = Color.Bisque, Name = "Bisque" });
    colors.Add(new ColorItem() { Color = Color.Coral, Name = "Coral" });
    colors.Add(new ColorItem() { Color = Color.Black, Name = "Black" });
    colors.Add(new ColorItem() { Color = Color.Blue, Name = "Blue" });
    colors.Add(new ColorItem() { Color = Color.BlueViolet, Name = "BlueViolet" });
    colors.Add(new ColorItem() { Color = Color.Brown, Name = "Brown" });
    colors.Add(new ColorItem() { Color = Color.BurlyWood, Name = "BurlyWood" });
    colors.Add(new ColorItem() { Color = Color.CadetBlue, Name = "CadetBlue" });
    colors.Add(new ColorItem() { Color = Color.Chartreuse, Name = "Chartreuse" });
    colors.Add(new ColorItem() { Color = Color.BlanchedAlmond, Name = "BlanchedAlmond" });
    colors.Add(new ColorItem() { Color = Color.DarkSlateBlue, Name = "DarkSlateBlue" });
    colors.Add(new ColorItem() { Color = Color.DarkBlue, Name = "DarkBlue" });
    colors.Add(new ColorItem() { Color = Color.DarkTurquoise, Name = "DarkTurquoise" });
    colors.Add(new ColorItem() { Color = Color.HotPink, Name = "HotPink" });
    colors.Add(new ColorItem() { Color = Color.IndianRed, Name = "IndianRed" });
    colors.Add(new ColorItem() { Color = Color.Indigo, Name = "Indigo" });
    colors.Add(new ColorItem() { Color = Color.Ivory, Name = "Ivory" });
    colors.Add(new ColorItem() { Color = Color.Khaki, Name = "Khaki" });
    colors.Add(new ColorItem() { Color = Color.Lavender, Name = "Lavender" });
    colors.Add(new ColorItem() { Color = Color.Honeydew, Name = "Honeydew" });
    colors.Add(new ColorItem() { Color = Color.LavenderBlush, Name = "LavenderBlush" });
    colors.Add(new ColorItem() { Color = Color.LemonChiffon, Name = "LemonChiffon" });
    colors.Add(new ColorItem() { Color = Color.LightBlue, Name = "LightBlue" });
    colors.Add(new ColorItem() { Color = Color.LightCoral, Name = "LightCoral" });
    colors.Add(new ColorItem() { Color = Color.DarkSlateGray, Name = "DarkSlateGray" });
    colors.Add(new ColorItem() { Color = Color.LightGoldenrodYellow, Name = "LightGoldenrodYellow" });
    colors.Add(new ColorItem() { Color = Color.LightGray, Name = "LightGray" });
    colors.Add(new ColorItem() { Color = Color.Gray, Name = "Gray" });
    colors.Add(new ColorItem() { Color = Color.Green, Name = "Green" });
    colors.Add(new ColorItem() { Color = Color.DarkViolet, Name = "DarkViolet" });
    colors.Add(new ColorItem() { Color = Color.DeepPink, Name = "DeepPink" });
    colors.Add(new ColorItem() { Color = Color.DeepSkyBlue, Name = "DeepSkyBlue" });
    colors.Add(new ColorItem() { Color = Color.DodgerBlue, Name = "DodgerBlue" });
    colors.Add(new ColorItem() { Color = Color.Firebrick, Name = "Firebrick" });
    colors.Add(new ColorItem() { Color = Color.FloralWhite, Name = "FloralWhite" });
    colors.Add(new ColorItem() { Color = Color.DimGray, Name = "DimGray" });
    colors.Add(new ColorItem() { Color = Color.Fuchsia, Name = "Fuchsia" });
    colors.Add(new ColorItem() { Color = Color.Gainsboro, Name = "Gainsboro" });
    colors.Add(new ColorItem() { Color = Color.Goldenrod, Name = "Goldenrod" });
    colors.Add(new ColorItem() { Color = Color.GhostWhite, Name = "GhostWhite" });
    colors.Add(new ColorItem() { Color = Color.Gold, Name = "Gold" });
    colors.Add(new ColorItem() { Color = Color.ForestGreen, Name = "ForestGreen" });

            return colors;
        }
    
    }
    public class ColorItem
    {
        public Color Color { get; set; } = Color.Red;
        public string Name { get; set; }
        public string Representation { get { return this.Color.ToString(); } }
    }`
    
  • LearnEverythingLearnEverything USMember ✭✭

    //Random Dark Colors
    `public static Color GetRandomDarkColor()
    {
    var solid = Color.IndianRed;
    Random random = new Random();
    var num = random.Next(1, 48);
    switch (num)
    {
    case 1:
    solid = Color.Navy;
    break;
    case 2:
    solid = Color.MidnightBlue;
    break;
    case 3:
    solid = Color.Olive;
    break;
    case 4:
    solid = Color.OrangeRed;
    break;
    case 5:
    solid = Color.OliveDrab;
    break;
    case 6:
    solid = Color.PaleVioletRed;
    break;
    case 7:
    solid = Color.MediumVioletRed;
    break;
    case 8:
    solid = Color.Maroon;
    break;
    case 9:
    solid = Color.MediumBlue;
    break;
    case 10:
    solid = Color.YellowGreen;
    break;
    case 11:
    solid = Color.Purple;
    break;
    case 12:
    solid = Color.Red;
    break;
    case 13:
    solid = Color.SlateBlue;
    break;
    case 14:
    solid = Color.RoyalBlue;
    break;
    case 15:
    solid = Color.Salmon;
    break;
    case 16:
    solid = Color.SeaGreen;
    break;
    case 17:
    solid = Color.Sienna;
    break;
    case 18:
    solid = Color.SaddleBrown;
    break;
    case 19:
    solid = Color.Crimson;
    break;
    case 20:
    solid = Color.DarkCyan;
    break;
    case 21:
    solid = Color.DarkGoldenrod;
    break;
    case 22:
    solid = Color.DarkGreen;
    break;
    case 23:
    solid = Color.DarkMagenta;
    break;
    case 24:
    solid = Color.DarkOliveGreen;
    break;
    case 25:
    solid = Color.DarkOrange;
    break;
    case 26:
    solid = Color.DarkOrchid;
    break;
    case 27:
    solid = Color.DarkRed;
    break;
    case 28:
    solid = Color.CornflowerBlue;
    break;
    case 29:
    solid = Color.Chocolate;
    break;
    case 30:
    solid = Color.Blue;
    break;
    case 31:
    solid = Color.BlueViolet;
    break;
    case 32:
    solid = Color.Brown;
    break;
    case 33:
    solid = Color.DarkSlateBlue;
    break;
    case 34:
    solid = Color.DarkBlue;
    break;
    case 35:
    solid = Color.HotPink;
    break;
    case 36:
    solid = Color.IndianRed;
    break;
    case 37:
    solid = Color.Indigo;
    break;
    case 38:
    solid = Color.DarkSlateGray;
    break;
    case 39:
    solid = Color.Green;
    break;
    case 40:
    solid = Color.DarkViolet;
    break;
    case 41:
    solid = Color.DeepPink;
    break;
    case 42:
    solid = Color.DeepSkyBlue;
    break;
    case 43:
    solid = Color.DodgerBlue;
    break;
    case 44:
    solid = Color.Firebrick;
    break;
    case 45:
    solid = Color.Fuchsia;
    break;
    case 46:
    solid = Color.Goldenrod;
    break;
    case 47:
    solid = Color.Gold;
    break;
    case 48:
    solid = Color.ForestGreen;
    break;

                default:
                    solid = Color.IndianRed;
                    break;
    
    
            }
            return solid;
        }`
    
  • LearnEverythingLearnEverything USMember ✭✭

    //Get Random Light Colors
    public static Color GetRandomLightColor() { var solid = Color.MistyRose; Random random = new Random(); var num = random.Next(1, 37); switch (num) { case 1: solid = Color.Moccasin; break; case 2: solid = Color.NavajoWhite; break; case 3: solid = Color.PaleGoldenrod; break; case 4: solid = Color.PaleGreen; break; case 5: solid = Color.PaleTurquoise; break; case 6: solid = Color.MediumSpringGreen; break; case 7: solid = Color.LightSkyBlue; break; case 8: solid = Color.LightSteelBlue; break; case 9: solid = Color.LightYellow; break; case 10: solid = Color.MediumTurquoise; break; case 11: solid = Color.Linen; break; case 12: solid = Color.MediumAquamarine; break; case 13: solid = Color.PapayaWhip; break; case 14: solid = Color.Tan; break; case 15: solid = Color.Thistle; break; case 16: solid = Color.Wheat; break; case 17: solid = Color.Turquoise; break; case 18: solid = Color.PeachPuff; break; case 19: solid = Color.SkyBlue; break; case 20: solid = Color.Pink; break; case 21: solid = Color.Plum; break; case 22: solid = Color.PowderBlue; break; case 23: solid = Color.RosyBrown; break; case 24: solid = Color.LightSalmon; break; case 25: solid = Color.LightGreen; break; case 26: solid = Color.LightPink; break; case 27: solid = Color.Aqua; break; case 28: solid = Color.Aquamarine; break; case 29: solid = Color.Bisque; break; case 30: solid = Color.Coral; break; case 31: solid = Color.BurlyWood; break; case 32: solid = Color.CadetBlue; break; case 33: solid = Color.DarkTurquoise; break; case 34: solid = Color.Khaki; break; case 35: solid = Color.Lavender; break; case 36: solid = Color.LavenderBlush; break; case 37: solid = Color.LightBlue; break; default: solid = Color.Coral; break; } return solid; }

  • JohnHardmanJohnHardman GBUniversity mod

    @LearnEverything - You might want to consider using reflection. It will make your code shorter, as well as coping with future changes to Xamarin.Forms.Color (it's not that long ago that the list of named colors was extended).

  • JohnHardmanJohnHardman GBUniversity mod

    Exactly :-)

  • LearnEverythingLearnEverything USMember ✭✭

    For android

    using Android.Graphics;
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    
    namespace XamarinAndroid.Basic.Helpers
    {
        public static class ColorHelper
        {
    
            public static Color GetPerceivedBrightnessColor(Color c)
            {
                var foreColor = (PerceivedBrightness(c) > 130 ? Color.Black : Color.White);
                return foreColor;
            }
            private static int PerceivedBrightness(Color c)
            {
                return (int)Math.Sqrt(
                c.R * c.R * .241 +
                c.G * c.G * .691 +
                c.B * c.B * .068);
            }
    
            public static string ColorToHex(Color color)
            {
    
                return $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}";
    
            }
            static Random random = new Random();
            public static Color GetRandomDarkColor()
            {
                var solid = Color.IndianRed;
    
                var num = random.Next(1, 48);
                switch (num)
                {
                    case 1:
                        solid = Color.Navy;
                        break;
                    case 2:
                        solid = Color.MidnightBlue;
                        break;
                    case 3:
                        solid = Color.Olive;
                        break;
                    case 4:
                        solid = Color.OrangeRed;
                        break;
                    case 5:
                        solid = Color.OliveDrab;
                        break;
                    case 6:
                        solid = Color.PaleVioletRed;
                        break;
                    case 7:
                        solid = Color.MediumVioletRed;
                        break;
                    case 8:
                        solid = Color.Maroon;
                        break;
                    case 9:
                        solid = Color.MediumBlue;
                        break;
                    case 10:
                        solid = Color.YellowGreen;
                        break;
                    case 11:
                        solid = Color.Purple;
                        break;
                    case 12:
                        solid = Color.Red;
                        break;
                    case 13:
                        solid = Color.SlateBlue;
                        break;
                    case 14:
                        solid = Color.RoyalBlue;
                        break;
                    case 15:
                        solid = Color.Salmon;
                        break;
                    case 16:
                        solid = Color.SeaGreen;
                        break;
                    case 17:
                        solid = Color.Sienna;
                        break;
                    case 18:
                        solid = Color.SaddleBrown;
                        break;
                    case 19:
                        solid = Color.Crimson;
                        break;
                    case 20:
                        solid = Color.DarkCyan;
                        break;
                    case 21:
                        solid = Color.DarkGoldenrod;
                        break;
                    case 22:
                        solid = Color.DarkGreen;
                        break;
                    case 23:
                        solid = Color.DarkMagenta;
                        break;
                    case 24:
                        solid = Color.DarkOliveGreen;
                        break;
                    case 25:
                        solid = Color.DarkOrange;
                        break;
                    case 26:
                        solid = Color.DarkOrchid;
                        break;
                    case 27:
                        solid = Color.DarkRed;
                        break;
                    case 28:
                        solid = Color.CornflowerBlue;
                        break;
                    case 29:
                        solid = Color.Chocolate;
                        break;
                    case 30:
                        solid = Color.Blue;
                        break;
                    case 31:
                        solid = Color.BlueViolet;
                        break;
                    case 32:
                        solid = Color.Brown;
                        break;
                    case 33:
                        solid = Color.DarkSlateBlue;
                        break;
                    case 34:
                        solid = Color.DarkBlue;
                        break;
                    case 35:
                        solid = Color.HotPink;
                        break;
                    case 36:
                        solid = Color.IndianRed;
                        break;
                    case 37:
                        solid = Color.Indigo;
                        break;
                    case 38:
                        solid = Color.DarkSlateGray;
                        break;
                    case 39:
                        solid = Color.Green;
                        break;
                    case 40:
                        solid = Color.DarkViolet;
                        break;
                    case 41:
                        solid = Color.DeepPink;
                        break;
                    case 42:
                        solid = Color.DeepSkyBlue;
                        break;
                    case 43:
                        solid = Color.DodgerBlue;
                        break;
                    case 44:
                        solid = Color.Firebrick;
                        break;
                    case 45:
                        solid = Color.Fuchsia;
                        break;
                    case 46:
                        solid = Color.Goldenrod;
                        break;
                    case 47:
                        solid = Color.Gold;
                        break;
                    case 48:
                        solid = Color.ForestGreen;
                        break;
    
                    default:
                        solid = Color.IndianRed;
                        break;
    
    
                }
                return solid;
            }
            public static Color GetRandomLightColor()
            {
                var solid = Color.MistyRose;
                var num = random.Next(1, 37);
                switch (num)
                {
                    case 1:
                        solid = Color.Moccasin;
                        break;
                    case 2:
                        solid = Color.NavajoWhite;
                        break;
                    case 3:
                        solid = Color.PaleGoldenrod;
                        break;
                    case 4:
                        solid = Color.PaleGreen;
                        break;
                    case 5:
                        solid = Color.PaleTurquoise;
                        break;
                    case 6:
                        solid = Color.MediumSpringGreen;
                        break;
                    case 7:
                        solid = Color.LightSkyBlue;
                        break;
                    case 8:
                        solid = Color.LightSteelBlue;
                        break;
                    case 9:
                        solid = Color.LightYellow;
                        break;
                    case 10:
                        solid = Color.MediumTurquoise;
                        break;
                    case 11:
                        solid = Color.Linen;
                        break;
                    case 12:
                        solid = Color.MediumAquamarine;
                        break;
                    case 13:
                        solid = Color.PapayaWhip;
                        break;
                    case 14:
                        solid = Color.Tan;
                        break;
                    case 15:
                        solid = Color.Thistle;
                        break;
                    case 16:
                        solid = Color.Wheat;
                        break;
                    case 17:
                        solid = Color.Turquoise;
                        break;
                    case 18:
                        solid = Color.PeachPuff;
                        break;
                    case 19:
                        solid = Color.SkyBlue;
                        break;
                    case 20:
                        solid = Color.Pink;
                        break;
                    case 21:
                        solid = Color.Plum;
                        break;
                    case 22:
                        solid = Color.PowderBlue;
                        break;
                    case 23:
                        solid = Color.RosyBrown;
                        break;
                    case 24:
                        solid = Color.LightSalmon;
                        break;
                    case 25:
                        solid = Color.LightGreen;
                        break;
                    case 26:
                        solid = Color.LightPink;
                        break;
                    case 27:
                        solid = Color.Aqua;
                        break;
                    case 28:
                        solid = Color.Aquamarine;
                        break;
                    case 29:
                        solid = Color.Bisque;
                        break;
                    case 30:
                        solid = Color.Coral;
                        break;
                    case 31:
                        solid = Color.BurlyWood;
                        break;
                    case 32:
                        solid = Color.CadetBlue;
                        break;
                    case 33:
                        solid = Color.DarkTurquoise;
                        break;
                    case 34:
                        solid = Color.Khaki;
                        break;
                    case 35:
                        solid = Color.Lavender;
                        break;
                    case 36:
                        solid = Color.LavenderBlush;
                        break;
                    case 37:
                        solid = Color.LightBlue;
                        break;
                    default:
                        solid = Color.Coral;
                        break;
                }
                return solid;
            }
            public static Color GetRandomDefaultColor()
            {
                var solid = Color.IndianRed;
                var num = random.Next(1, 48);
                switch (num)
                {
                    case 1:
                        solid = Color.Navy;
                        break;
                    case 2:
                        solid = Color.MidnightBlue;
                        break;
                    case 3:
                        solid = Color.Olive;
                        break;
                    case 4:
                        solid = Color.OrangeRed;
                        break;
                    case 5:
                        solid = Color.OliveDrab;
                        break;
                    case 6:
                        solid = Color.PaleVioletRed;
                        break;
                    case 7:
                        solid = Color.MediumVioletRed;
                        break;
                    case 8:
                        solid = Color.Maroon;
                        break;
                    case 9:
                        solid = Color.MediumBlue;
                        break;
                    case 10:
                        solid = Color.YellowGreen;
                        break;
                    case 11:
                        solid = Color.Purple;
                        break;
                    case 12:
                        solid = Color.Red;
                        break;
                    case 13:
                        solid = Color.SlateBlue;
                        break;
                    case 14:
                        solid = Color.RoyalBlue;
                        break;
                    case 15:
                        solid = Color.Salmon;
                        break;
                    case 16:
                        solid = Color.SeaGreen;
                        break;
                    case 17:
                        solid = Color.Sienna;
                        break;
                    case 18:
                        solid = Color.SaddleBrown;
                        break;
                    case 19:
                        solid = Color.Crimson;
                        break;
                    case 20:
                        solid = Color.DarkCyan;
                        break;
                    case 21:
                        solid = Color.DarkGoldenrod;
                        break;
                    case 22:
                        solid = Color.DarkGreen;
                        break;
                    case 23:
                        solid = Color.DarkMagenta;
                        break;
                    case 24:
                        solid = Color.DarkOliveGreen;
                        break;
                    case 25:
                        solid = Color.DarkOrange;
                        break;
                    case 26:
                        solid = Color.DarkOrchid;
                        break;
                    case 27:
                        solid = Color.DarkRed;
                        break;
                    case 28:
                        solid = Color.CornflowerBlue;
                        break;
                    case 29:
                        solid = Color.Chocolate;
                        break;
                    case 30:
                        solid = Color.Blue;
                        break;
                    case 31:
                        solid = Color.BlueViolet;
                        break;
                    case 32:
                        solid = Color.Brown;
                        break;
                    case 33:
                        solid = Color.DarkSlateBlue;
                        break;
                    case 34:
                        solid = Color.DarkBlue;
                        break;
                    case 35:
                        solid = Color.HotPink;
                        break;
                    case 36:
                        solid = Color.IndianRed;
                        break;
                    case 37:
                        solid = Color.Indigo;
                        break;
                    case 38:
                        solid = Color.DarkSlateGray;
                        break;
                    case 39:
                        solid = Color.Green;
                        break;
                    case 40:
                        solid = Color.DarkViolet;
                        break;
                    case 41:
                        solid = Color.DeepPink;
                        break;
                    case 42:
                        solid = Color.DeepSkyBlue;
                        break;
                    case 43:
                        solid = Color.DodgerBlue;
                        break;
                    case 44:
                        solid = Color.Firebrick;
                        break;
                    case 45:
                        solid = Color.Fuchsia;
                        break;
                    case 46:
                        solid = Color.Goldenrod;
                        break;
                    case 47:
                        solid = Color.Gold;
                        break;
                    case 48:
                        solid = Color.ForestGreen;
                        break;
    
                    default:
                        solid = Color.IndianRed;
                        break;
    
    
                }
                return solid;
            }
    
        }
    }
    
    
Sign In or Register to comment.