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.
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
-
- namespace WDrawingToTheScreen
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.FillEllipseRectangle);
- }
-
- private void FillEllipseRectangle(object sender, PaintEventArgs e)
- {
- MessageBox.Show("very well done!");
- Pen itsme = new Pen(Color.Green, 3);
-
- int x = 5;
- int y = 5;
- int width = 200;
- int height = 100;
- rect = new Rectangle(x, y, width, height);
- e.Graphics.DrawEllipse(itsme, rect);
-
- int x1= 5;
- int y1 = 5;
- int width1 = 200;
- int height1 = 100;
- rect1 = new Rectangle(x1, y1, width1, height1);
- SolidBrush redBrush = new SolidBrush(Color.Red);
- e.Graphics.FillEllipse(redBrush, this.rect1);
- }
- public System.Drawing.Rectangle rect { get; set; }
- public System.Drawing.Rectangle rect1 { get; set; }
- }
- }