using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Draw_Shape_Ellipse_Circle_Star
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void DrawEllipse(PaintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddEllipse(100, 15, 100, 70);
System.Drawing.Region r = new System.Drawing.Region(gp);
Graphics gr = e.Graphics;
gr.FillRegion(Brushes.LawnGreen, r);
}
private void DrawStar(PaintEventArgs e)
{
System.Drawing.Point[] p = new System.Drawing.Point[8];
p[0] = new Point(0, 50);
p[1] = new Point(40, 40);
p[2] = new Point(50, 0);
p[3] = new Point(60, 40);
p[4] = new Point(100, 50);
p[5] = new Point(60, 60);
p[6] = new Point(50, 100);
p[7] = new Point(40, 60);
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddPolygon(p);
System.Drawing.Region r = new System.Drawing.Region(gp);
Graphics gr = e.Graphics;
gr.FillRegion(Brushes.BlueViolet, r);
}
private void DrawRectangle(PaintEventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
Rectangle rc = new Rectangle(220, 15, 100, 70);
gp.AddRectangle(rc);
System.Drawing.Region r = new System.Drawing.Region(gp);
Graphics gr = e.Graphics;
gr.FillRegion(Brushes.OrangeRed, r);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
DrawStar(e);
DrawEllipse(e);
DrawRectangle(e);
}
}
}
Download the project of Visual Studio 2013 in DropBox Download