Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Field
- {
- public enum CellType { Empty, ColorR, ColorG }
- private CellType[,] Cells;
- private Size mCellSize;
- private int mWidth;
- private int mHeight;
- Graphics g;
- public Field(Panel P, Size FieldSizeInCell)
- {
- // проверить все на нул и нули
- // пока нет
- this.g = P.CreateGraphics();
- mWidth = FieldSizeInCell.Width;
- mHeight = FieldSizeInCell.Height;
- mCellSize = new Size(P.Width / mWidth, P.Height / mHeight);
- CreateFieldArray(); // сам
- }
- public void DrawField()
- {
- // тут нарисовать общий прямоугольник поля
- // пока нет
- for (int row = 0; row < mWidth; row++) {
- for (int col = 0; col < mHeight; col++) {
- this.DrawCell(row, col);
- }
- }
- }
- private void DrawCell(int row, int col)
- {
- CellType SomeCell = Cells[row, col];
- Color GradC = Color.Black;
- Color MainC = Color.Black;
- switch (SomeCell)
- {
- case CellType.Empty: MainC = Color.White;
- case CellType.ColorR: MainC = Color.Red;
- case CellType.ColorG: MainC = Color.Green;
- }
- // мда
- int X = row * mCellSize.Width;
- int Y = col * mCellSize.Height;
- LinearGradientBrush Br = new LinearGradientBrush(new Point(X, Y), new Point(X + mCellSize.Width, Y + mCellSize.Height), GradC, MainC);
- g.FillRectangle(Br, X, Y, mCellSize.Width, mCellSize.Height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment