Advertisement
istomina_sofia

c# windowsforms 6

Jan 16th, 2022
882
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. namespace Лаба_6
  6. {
  7.     public partial class Form1 : Form
  8.     {
  9.         public Form1()
  10.         {
  11.             InitializeComponent();
  12.         }
  13.  
  14.         private void Clear_Click(object sender, EventArgs e)
  15.         {
  16.             Graphics clear = Graphics.FromHwnd(Picture.Handle);
  17.             clear.Clear(BackColor);
  18.         }
  19.  
  20.         private void Square_Click(object sender, EventArgs e)
  21.         {
  22.             Graphics clear = Graphics.FromHwnd(Picture.Handle);
  23.             clear.Clear(BackColor);
  24.  
  25.             Graphics square = Picture.CreateGraphics();
  26.             Pen pen = new Pen(Color.Black, 3f);
  27.             Rectangle rect = new Rectangle(165, 60, 250, 250);
  28.             square.DrawRectangle(pen, rect);
  29.             square.Dispose();
  30.         }
  31.  
  32.         private void Circle_Click(object sender, EventArgs e)
  33.         {
  34.             Graphics clear = Graphics.FromHwnd(Picture.Handle);
  35.             clear.Clear(BackColor);
  36.  
  37.             Graphics circle = Picture.CreateGraphics();
  38.             Pen pen = new Pen(Color.Black, 3f);
  39.             RectangleF rect = new RectangleF(165, 60, 250, 250);
  40.             circle.DrawEllipse(pen, rect);
  41.             circle.Dispose();
  42.         }
  43.  
  44.         private void Triangle_Click(object sender, EventArgs e)
  45.         {
  46.             Graphics clear = Graphics.FromHwnd(Picture.Handle);
  47.             clear.Clear(BackColor);
  48.  
  49.             Graphics triangle = Picture.CreateGraphics();
  50.             Pen pen = new Pen(Color.Black, 3f);
  51.             Point[] points = { new Point(290, 60), new Point(120, 320), new Point(460, 320) };
  52.             triangle.DrawPolygon(pen, points);
  53.             triangle.Dispose();
  54.         }
  55.     }
  56. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement