Guest User

Untitled

a guest
Oct 13th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.14 KB | None | 0 0
  1. namespace DrawingTest
  2. {
  3.     using System;
  4.     using System.Drawing;
  5.     using System.Windows.Forms;
  6.  
  7.  
  8.     public partial class Form1 : Form
  9.     {
  10.         private const int SIZE = 100;
  11.         private const int TILE_COUNT = 4;
  12.  
  13.         public Form1()
  14.         {
  15.             InitializeComponent();
  16.             ClientSize = new Size
  17.             {
  18.                 Height = SIZE * TILE_COUNT,
  19.                 Width = SIZE * TILE_COUNT
  20.             };
  21.  
  22.             //Paint += Form1_Paint;
  23.         }
  24.  
  25.         //private void Form1_Paint(object sender, PaintEventArgs e)
  26.         //{
  27.         //    Graphics g = e.Graphics;
  28.  
  29.         //    for (int i = 0; i < TILE_COUNT; ++i)
  30.         //    {
  31.         //        for (int j = 0; j < TILE_COUNT; ++j)
  32.         //        {
  33.         //            g.FillRectangle(new SolidBrush(Color.AliceBlue), new Rectangle
  34.         //            {
  35.         //                Height = SIZE,
  36.         //                Width = SIZE,
  37.         //                X = j * SIZE,
  38.         //                Y = i * SIZE
  39.         //            });
  40.         //            g.DrawRectangle(new Pen(Color.Black), new Rectangle
  41.         //            {
  42.         //                Height = SIZE,
  43.         //                Width = SIZE,
  44.         //                X = j * SIZE,
  45.         //                Y = i * SIZE
  46.         //            });
  47.         //        }
  48.         //    }
  49.         //}
  50.  
  51.         protected override void OnClick(EventArgs e)
  52.         {
  53.             Graphics g = CreateGraphics();
  54.            
  55.             for (int i = 0; i < TILE_COUNT; ++i)
  56.             {
  57.                 for (int j = 0; j < TILE_COUNT; ++j)
  58.                 {
  59.                     g.FillRectangle(new SolidBrush(Color.AliceBlue), new Rectangle
  60.                     {
  61.                         Height = SIZE,
  62.                         Width = SIZE,
  63.                         X = j * SIZE,
  64.                         Y = i * SIZE
  65.                     });
  66.                     g.DrawRectangle(new Pen(Color.Black), new Rectangle
  67.                     {
  68.                         Height = SIZE,
  69.                         Width = SIZE,
  70.                         X = j * SIZE,
  71.                         Y = i * SIZE
  72.                     });
  73.                 }
  74.             }
  75.         }
  76.  
  77.         protected override void OnPaint(PaintEventArgs e)
  78.         {
  79.             //Graphics g = e.Graphics;
  80.  
  81.             //for (int i = 0; i < TILE_COUNT; ++i)
  82.             //{
  83.             //    for (int j = 0; j < TILE_COUNT; ++j)
  84.             //    {
  85.             //        g.FillRectangle(new SolidBrush(Color.AliceBlue), new Rectangle
  86.             //        {
  87.             //            Height = SIZE,
  88.             //            Width = SIZE,
  89.             //            X = j * SIZE,
  90.             //            Y = i * SIZE
  91.             //        });
  92.             //        g.DrawRectangle(new Pen(Color.Black), new Rectangle
  93.             //        {
  94.             //            Height = SIZE,
  95.             //            Width = SIZE,
  96.             //            X = j * SIZE,
  97.             //            Y = i * SIZE
  98.             //        });
  99.             //    }
  100.             //}
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment