using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Menu_Drawing_Designer
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{

int dFunction = 0;
Color dColor = Color.Red;

private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemFunction;
private System.Windows.Forms.MenuItem menuItemColor;
private System.Windows.Forms.MenuItem menuItemClear;
private System.Windows.Forms.MenuItem menuItemQuit;
private System.Windows.Forms.MenuItem menuItemRectangle;
private System.Windows.Forms.MenuItem menuItemEllipse;
private System.Windows.Forms.MenuItem menuItemRed;
private System.Windows.Forms.MenuItem menuItemGreen;
private System.Windows.Forms.MenuItem menuItemBlue;
private System.Windows.Forms.MenuItem menuItem1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItemFunction = new System.Windows.Forms.MenuItem();
this.menuItemRectangle = new System.Windows.Forms.MenuItem();
this.menuItemEllipse = new System.Windows.Forms.MenuItem();
this.menuItemColor = new System.Windows.Forms.MenuItem();
this.menuItemRed = new System.Windows.Forms.MenuItem();
this.menuItemGreen = new System.Windows.Forms.MenuItem();
this.menuItemBlue = new System.Windows.Forms.MenuItem();
this.menuItemClear = new System.Windows.Forms.MenuItem();
this.menuItemQuit = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemFunction,
this.menuItemColor,
this.menuItemClear,
this.menuItemQuit});
//
// menuItemFunction
//
this.menuItemFunction.Index = 0;
this.menuItemFunction.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemRectangle,
this.menuItem1,
this.menuItemEllipse});
this.menuItemFunction.Text = "Drawing &Function ";
//
// menuItemRectangle
//
this.menuItemRectangle.Index = 0;
this.menuItemRectangle.Text = "&Rectangle";
this.menuItemRectangle.Click += new System.EventHandler(this.menuItemRectangle_Click);
//
// menuItemEllipse
//
this.menuItemEllipse.Index = 2;
this.menuItemEllipse.Text = "&Ellipse";
this.menuItemEllipse.Click += new System.EventHandler(this.menuItemEllipse_Click);
//
// menuItemColor
//
this.menuItemColor.Index = 1;
this.menuItemColor.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemRed,
this.menuItemGreen,
this.menuItemBlue});
this.menuItemColor.Text = "Drawing C&olor";
//
// menuItemRed
//
this.menuItemRed.Index = 0;
this.menuItemRed.Text = "Re&d";
this.menuItemRed.Click += new System.EventHandler(this.menuItemRed_Click);
//
// menuItemGreen
//
this.menuItemGreen.Index = 1;
this.menuItemGreen.Text = "&Green";
this.menuItemGreen.Click += new System.EventHandler(this.menuItemGreen_Click);
//
// menuItemBlue
//
this.menuItemBlue.Index = 2;
this.menuItemBlue.Text = "&Blue";
this.menuItemBlue.Click += new System.EventHandler(this.menuItemBlue_Click);
//
// menuItemClear
//
this.menuItemClear.Index = 2;
this.menuItemClear.Text = "&Clear";
this.menuItemClear.Click += new System.EventHandler(this.menuItemClear_Click);
//
// menuItemQuit
//
this.menuItemQuit.Index = 3;
this.menuItemQuit.Text = "&Quit";
this.menuItemQuit.Click += new System.EventHandler(this.menuItemQuit_Click);
//
// menuItem1
//
this.menuItem1.Index = 1;
this.menuItem1.Text = "-";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(376, 289);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void menuItemClear_Click(object sender, System.EventArgs e)
{
dFunction = 0;
Invalidate();
}

private void menuItemQuit_Click(object sender, System.EventArgs e)
{
this.Close();
}

private void menuItemRectangle_Click(object sender, System.EventArgs e)
{
dFunction = 1;
Invalidate();
}

private void menuItemEllipse_Click(object sender, System.EventArgs e)
{
dFunction = 2;
Invalidate();
}

private void menuItemRed_Click(object sender, System.EventArgs e)
{
dColor = Color.Red;
Invalidate();
}

private void menuItemGreen_Click(object sender, System.EventArgs e)
{
dColor = Color.Green;
Invalidate();
}

private void menuItemBlue_Click(object sender, System.EventArgs e)
{
dColor = Color.Blue;
Invalidate();
}

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
Brush b = new SolidBrush(dColor);
if (dFunction == 1)
g.FillRectangle(b, 10,10,100,100);
if (dFunction == 2)
g.FillEllipse(b, 100,100,100,100);

}
}
}