Tibialyzer.OutfiterManager.GenerateColorImage C# (CSharp) Метод

GenerateColorImage() публичный статический Метод

public static GenerateColorImage ( int pressedIndex ) : Bitmap
pressedIndex int
Результат System.Drawing.Bitmap
        public static Bitmap GenerateColorImage(int pressedIndex)
        {
            Bitmap bitmap = new Bitmap(OutfitColorBoxSize * OutfitColorsPerRow, OutfitColorBoxSize * 8);
            using (Graphics gr = Graphics.FromImage(bitmap)) {
                int index = 0;
                for (int i = 0; i < outfitColors.Count; i++) {
                    int x = OutfitColorBoxSize * (index % OutfitColorsPerRow);
                    int y = OutfitColorBoxSize * (index / OutfitColorsPerRow);
                    using (Brush brush = new SolidBrush(outfitColors[i]))
                        gr.FillRectangle(brush, new Rectangle(x, y, OutfitColorBoxSize - 1, OutfitColorBoxSize - 1));
                    gr.DrawImage(i == pressedIndex ? StyleManager.GetImage("color_bevel_pressed.png") : StyleManager.GetImage("color_bevel.png"), new Rectangle(x, y, OutfitColorBoxSize, OutfitColorBoxSize));
                    index++;
                }
            }
            return bitmap;
        }

Usage Example

Пример #1
0
        private void RefreshColorPicker(int colorIndex)
        {
            this.colorIndex              = colorIndex;
            headColorButton.Enabled      = true;
            primaryColorButton.Enabled   = true;
            secondaryColorButton.Enabled = true;
            detailColorButton.Enabled    = true;
            switch (colorIndex)
            {
            case 0: headColorButton.Enabled = false; break;

            case 1: primaryColorButton.Enabled = false; break;

            case 2: secondaryColorButton.Enabled = false; break;

            case 3: detailColorButton.Enabled = false; break;
            }
            Image oldImage = colorPicker.Image;

            colorPicker.Image = OutfiterManager.GenerateColorImage(outfit.colors[colorIndex]);
            if (oldImage != null)
            {
                oldImage.Dispose();
            }
        }