Kyaria

Draw Ellipse

Jan 7th, 2018
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. namespace ellipse
  6. {
  7.     public partial class Form1 : Form
  8.     {
  9.         public int xE = 200;
  10.         public int yE = 200;
  11.         public int widthE = 100;
  12.         public int heightE = 60;
  13.  
  14.         Pen pen;
  15.         Graphics g;
  16.  
  17.         private void trackBar2_Scroll(object sender, EventArgs e)
  18.         {
  19.             if (checkBox1.Checked)
  20.             {
  21.                 trackBar2.Value = trackBar1.Value;
  22.                 trackBar1.Value = trackBar2.Value;
  23.             }
  24.  
  25.             widthE = trackBar1.Value * 10;
  26.             heightE = trackBar2.Value * 10;
  27.  
  28.             g.Clear(Color.White);
  29.             g.DrawEllipse(pen, xE - widthE, yE - heightE, widthE * 2, heightE * 2);
  30.         }
  31.  
  32.         private void checkBox1_CheckedChanged(object sender, EventArgs e)
  33.         {
  34.             if (checkBox1.Checked)
  35.             {
  36.                 trackBar2.Value = trackBar1.Value;
  37.                 trackBar2_Scroll(sender, e);
  38.             }
  39.         }
  40.  
  41.         public Form1()
  42.         {
  43.             InitializeComponent();
  44.  
  45.             pen = new Pen(Color.Black, 1);
  46.             g = this.CreateGraphics();
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment