Dmitrij Solov

Dmitrij Solov

  • NA
  • 43
  • 6.5k

Drawing to the screen-new

Nov 10 2016 5:12 PM
Hello, I want to draw an ellipse to the screen and then fill it. I have the following code, but the program doesn't run fast, I have to minimize and to maximize the window in order to draw the ellipse. I just want the program to run fast.
 
  1. using System;  
  2. using System.ComponentModel;  
  3. using System.Drawing;  
  4. using System.Windows.Forms;  
  5. //Ellipse Issue  
  6. namespace WDrawingToTheScreen  
  7. {  
  8.     public partial class Form1 : Form  
  9.     {  
  10.         public Form1()  
  11.         {  
  12.             InitializeComponent();      
  13.         }  
  14.         private void button1_Click(object sender, EventArgs e)  
  15.         {  
  16.             this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.FillEllipseRectangle);           
  17.         }  
  18.   
  19.         private void FillEllipseRectangle(object sender, PaintEventArgs e)  
  20.         {  
  21.             MessageBox.Show("very well done!");  
  22.             Pen itsme = new Pen(Color.Green, 3);  
  23.             //Draw the ellipse  
  24.             int x = 5;  
  25.             int y = 5;  
  26.             int width = 200;  
  27.             int height = 100;  
  28.             rect = new Rectangle(x, y, width, height);  
  29.             e.Graphics.DrawEllipse(itsme, rect);  
  30.             //fill the ellipse  
  31.             int x1= 5;  
  32.             int y1 = 5;  
  33.             int width1 = 200;  
  34.             int height1 = 100;  
  35.             rect1 = new Rectangle(x1, y1, width1, height1);  
  36.             SolidBrush redBrush = new SolidBrush(Color.Red);  
  37.             e.Graphics.FillEllipse(redBrush, this.rect1);  
  38.         }  
  39.         public System.Drawing.Rectangle rect { getset; }  
  40.         public System.Drawing.Rectangle rect1 { getset; }  
  41.     }  


Answers (1)