Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Drawing to the screen-new
Dmitrij Solov
Nov 10 2016 5:12 PM
224
Reply
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;
//Ellipse Issue
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);
//Draw the ellipse
int
x = 5;
int
y = 5;
int
width = 200;
int
height = 100;
rect =
new
Rectangle(x, y, width, height);
e.Graphics.DrawEllipse(itsme, rect);
//fill the ellipse
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
; }
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
C# get the value of certain item in listbox
gridview row color change when condition is true