Пример #1
0
        public static void AddStyles(List <GridCellsAppearance> viewSettings)
        {
            DataGridViewCellStyle headersAndfooters = Decorator.MakeStyle(Color.White, Color.FromArgb(blue: 64, red: 64, green: 64));
            DataGridViewCellStyle gray  = Decorator.MakeStyle(Color.Black, Color.LightGray);
            DataGridViewCellStyle white = Decorator.MakeStyle(Color.Black, Color.White);

            viewSettings.Add(new GridCellsAppearance
            {
                name        = "Standart",
                colorize    = delegate { return(white); },
                styleHeader = headersAndfooters,
                styleFooter = headersAndfooters
            });

            viewSettings.Add(new GridCellsAppearance
            {
                name     = "Zebra",
                colorize = delegate(int x, int y)
                {
                    if (y % 2 == 0)
                    {
                        return(gray);
                    }
                    return(white);
                },
                styleHeader = headersAndfooters,
                styleFooter = headersAndfooters
            });

            viewSettings.Add(new GridCellsAppearance
            {
                name     = "Chess",
                colorize = delegate(int x, int y)
                {
                    if (y % 2 == x % 2)
                    {
                        return(gray);
                    }
                    return(white);
                },
                styleHeader = headersAndfooters,
                styleFooter = headersAndfooters
            });


            // Color mode
            List <DataGridViewCellStyle> colors = new List <DataGridViewCellStyle>
            {
                Decorator.MakeStyle(Color.Black, Color.CornflowerBlue),
                Decorator.MakeStyle(Color.Black, Color.Cyan),
                Decorator.MakeStyle(Color.Black, Color.Chartreuse),
                Decorator.MakeStyle(Color.Black, Color.Orange),
                Decorator.MakeStyle(Color.Black, Color.HotPink),
            };
            int rowsPerColor = 4;

            viewSettings.Add(new GridCellsAppearance
            {
                name        = "RAINBOW",
                colorize    = (x, y) => colors[y / rowsPerColor % colors.Count],
                styleHeader = headersAndfooters,
                styleFooter = headersAndfooters,
                gridColor   = Color.Azure
            });


            DataGridViewCellStyle anotherFont  = Decorator.MakeStyle(Color.DarkRed, Color.White, new Font("Comic Sans MS", 12f, FontStyle.Bold));
            DataGridViewCellStyle anotherFont2 = Decorator.MakeStyle(Color.DarkMagenta, Color.White, new Font("Arial Black", 9f, FontStyle.Bold));

            viewSettings.Add(new GridCellsAppearance
            {
                name     = "Random Fonts",
                colorize = delegate
                {
                    if (Decorator.Chance(10))
                    {
                        return(anotherFont);                      // 10% chance
                    }
                    if (Decorator.Chance(10))
                    {
                        return(anotherFont2);                      // 10% chance
                    }
                    return(white);
                },
                styleHeader = headersAndfooters,
                styleFooter = headersAndfooters
            });
        }