using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Radio_Check_Dialog
{
/// <summary>
/// Summary description for ColorFillDialogBox.
/// </summary>
public class ColorFillDialogBox : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox grpbox;
private System.Windows.Forms.CheckBox chkbox;
private System.Windows.Forms.Button btn_OK;
private System.Windows.Forms.Button btn_Cancel;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ColorFillDialogBox()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
string[] strColor = {"Black", "Blue", "Green", "Red", "White"};
for (int i = 0; i < strColor.Length; i++)
{
RadioButton radiobtn = new RadioButton();
radiobtn.Parent = grpbox;
radiobtn.Text = strColor[i];
radiobtn.Location = new Point(10, 20*(i+1));
radiobtn.Size = new Size(80, 15);
}
}
/// <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.grpbox = new System.Windows.Forms.GroupBox();
this.chkbox = new System.Windows.Forms.CheckBox();
this.btn_OK = new System.Windows.Forms.Button();
this.btn_Cancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// grpbox
//
this.grpbox.Location = new System.Drawing.Point(40, 16);
this.grpbox.Name = "grpbox";
this.grpbox.Size = new System.Drawing.Size(136, 200);
this.grpbox.TabIndex = 0;
this.grpbox.TabStop = false;
this.grpbox.Text = "Color";
//
// chkbox
//
this.chkbox.Location = new System.Drawing.Point(32, 240);
this.chkbox.Name = "chkbox";
this.chkbox.TabIndex = 1;
this.chkbox.Text = "Fill Rectangle";
//
// btn_OK
//
this.btn_OK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btn_OK.Location = new System.Drawing.Point(16, 288);
this.btn_OK.Name = "btn_OK";
this.btn_OK.TabIndex = 2;
this.btn_OK.Text = "OK";
//
// btn_Cancel
//
this.btn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btn_Cancel.Location = new System.Drawing.Point(128, 288);
this.btn_Cancel.Name = "btn_Cancel";
this.btn_Cancel.TabIndex = 3;
this.btn_Cancel.Text = "Cancel";
//
// ColorFillDialogBox
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(216, 341);
this.ControlBox = false;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btn_Cancel,
this.btn_OK,
this.chkbox,
this.grpbox});
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ColorFillDialogBox";
this.ShowInTaskbar = false;
this.Text = "Color/Fill Select";
this.ResumeLayout(false);
}
#endregion
public Color ColorRect
{
get
{
for (int i = 0; i<grpbox.Controls.Count; i++) // index thru all radio buttons in group box
{
RadioButton radiobtn = (RadioButton)grpbox.Controls[i];
if (radiobtn.Checked)
return Color.FromName(radiobtn.Text);
}
return Color.Black; // default if nothing was selected
}
set
{
for (int i = 0; i<grpbox.Controls.Count; i++) // index thru all radio buttons in group box
{
RadioButton radiobtn = (RadioButton)grpbox.Controls[i];
if (value == Color.FromName(radiobtn.Text))
{
radiobtn.Checked = true;
break;
}
}
}
}
public bool Fill
{
get
{
return chkbox.Checked;
}
set
{
chkbox.Checked = value;
}
}
}
}