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

namespace Context_Menu_CDlgBox
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItemColor;
private System.Windows.Forms.MenuItem menuItemFont;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.FontDialog fontDialog1;
/// <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.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItemColor = new System.Windows.Forms.MenuItem();
this.menuItemFont = new System.Windows.Forms.MenuItem();
this.label1 = new System.Windows.Forms.Label();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.fontDialog1 = new System.Windows.Forms.FontDialog();
this.SuspendLayout();
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemColor,
this.menuItemFont});
//
// menuItemColor
//
this.menuItemColor.Index = 0;
this.menuItemColor.Text = "&Color";
this.menuItemColor.Click += new System.EventHandler(this.menuItemColor_Click);
//
// menuItemFont
//
this.menuItemFont.Index = 1;
this.menuItemFont.Text = "&Font";
this.menuItemFont.Click += new System.EventHandler(this.menuItemFont_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(296, 64);
this.label1.TabIndex = 0;
this.label1.Text = "Right click to bring up the Context Menu";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 273);
this.ContextMenu = this.contextMenu1;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label1});
this.Name = "Form1";
this.Text = "Context menu with color and font dialog boxes";
this.ResumeLayout(false);

}
#endregion

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

private void menuItemColor_Click(object sender, System.EventArgs e)
{
colorDialog1.Color = this.ForeColor;
if (colorDialog1.ShowDialog() == DialogResult.OK)
this.ForeColor = colorDialog1.Color;
}

private void menuItemFont_Click(object sender, System.EventArgs e)
{
fontDialog1.Font = label1.Font;
if (fontDialog1.ShowDialog() == DialogResult.OK)
label1.Font = fontDialog1.Font;
}

}
}