alexandrheathen

Untitled

Apr 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using DrawingClassLib;
  12.  
  13.  
  14. namespace DrawingApp
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.         protected bool Draw;
  19.         public Form1()
  20.         {
  21.             Draw = false;
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void PictureBox_Paint(object sender, PaintEventArgs e)
  26.         {
  27.             if (Draw)
  28.             {
  29.                 Graphics graph = PictureBox.CreateGraphics();
  30.                 Shape[] shape = new Shape[20];
  31.                 for (int i = 0; i < 4; i++)
  32.                 {
  33.                     shape[i] = new DrawingClassLib.Point();
  34.                     System.Threading.Thread.Sleep(20);
  35.                 }
  36.  
  37.                 for (int i = 4; i < 8; i++)
  38.                 {
  39.                     shape[i] = new Circle();
  40.                     System.Threading.Thread.Sleep(20);
  41.                 }
  42.  
  43.                 for (int i = 8; i < 12; i++)
  44.                 {
  45.                     shape[i] = new Ellipse();
  46.                     System.Threading.Thread.Sleep(10);
  47.                 }
  48.  
  49.                 for (int i = 12; i < 16; i++)
  50.                 {
  51.                     shape[i] = new Segment();
  52.                     System.Threading.Thread.Sleep(10);
  53.                 }
  54.  
  55.                 for (int i = 16; i < shape.Length; i++)
  56.                 {
  57.                     shape[i] = new DrawingClassLib.Rectangle();
  58.                     System.Threading.Thread.Sleep(10);
  59.                 }
  60.  
  61.                 for (int i = 0; i < shape.Length; i++)
  62.                 {
  63.                     shape[i].Draw(graph);
  64.                 }
  65.             }
  66.         }
  67.  
  68.         private void drawShape_Click(object sender, EventArgs e)
  69.         {
  70.             Draw = true;            
  71.             Refresh();
  72.            
  73.         }
  74.  
  75.         private void clearButton_Click(object sender, EventArgs e)
  76.         {
  77.             Refresh();
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment