Guest User

Mda

a guest
Oct 13th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. class Field
  2. {
  3.     public enum CellType { Empty, ColorR, ColorG }
  4.  
  5.     private CellType[,] Cells;
  6.     private Size mCellSize;
  7.  
  8.     private int mWidth;
  9.     private int mHeight;
  10.  
  11.     Graphics g;
  12.  
  13.     public Field(Panel P, Size FieldSizeInCell)
  14.     {
  15.         // проверить все на нул и нули
  16.         // пока нет
  17.  
  18.         this.g = P.CreateGraphics();
  19.  
  20.         mWidth = FieldSizeInCell.Width;
  21.         mHeight = FieldSizeInCell.Height;
  22.  
  23.         mCellSize = new Size(P.Width / mWidth, P.Height / mHeight);
  24.  
  25.         CreateFieldArray(); // сам
  26.     }
  27.  
  28.     public void DrawField()
  29.     {
  30.         // тут нарисовать общий прямоугольник поля
  31.         // пока нет
  32.  
  33.         for (int row = 0; row < mWidth; row++) {
  34.             for (int col = 0; col < mHeight; col++) {
  35.                 this.DrawCell(row, col);
  36.             }
  37.         }
  38.     }
  39.  
  40.     private void DrawCell(int row, int col)
  41.     {
  42.         CellType SomeCell = Cells[row, col];
  43.         Color GradC = Color.Black;
  44.         Color MainC = Color.Black;
  45.  
  46.         switch (SomeCell)
  47.         {
  48.             case CellType.Empty: MainC = Color.White;
  49.             case CellType.ColorR: MainC = Color.Red;
  50.             case CellType.ColorG: MainC = Color.Green;
  51.         }
  52.  
  53.         // мда
  54.         int X = row * mCellSize.Width;
  55.         int Y = col * mCellSize.Height;
  56.         LinearGradientBrush Br = new LinearGradientBrush(new Point(X, Y), new Point(X + mCellSize.Width, Y + mCellSize.Height), GradC, MainC);
  57.  
  58.         g.FillRectangle(Br, X, Y, mCellSize.Width, mCellSize.Height);
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment