/****************************************************************************************
**************************File Name: NewCanvas.cs,Version 1.0, 8 November 2004***********
*****************************Author:Karthik Janaswami************************************
** This windows is used for create a new canvas. **
** You can change the canvas size setting and canvas background color in this windows **
*****************************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace GraEditor
{
//Create new canvas
public class NewCanvasCfg : System.Windows.Forms.Form
{
private System.Windows.Forms.NumericUpDown widthUD;
private System.Windows.Forms.NumericUpDown hightUD;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnBackColor;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.Button buttonCancel;
///
///
///
private System.ComponentModel.Container components = null;
public NewCanvasCfg()
{
//
// Windows
//
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
public Size CanvasSize
{
get
{
return new Size((int)this.widthUD.Value,(int)this.hightUD.Value);
}
set
{
this.widthUD.Value = value.Width;
this.hightUD.Value = value.Height;
}
}
public Color CanvasBackColor // Canvas background color
{
get { return btnBackColor.BackColor;}
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.widthUD = new System.Windows.Forms.NumericUpDown();
this.hightUD = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.btnBackColor = new System.Windows.Forms.Button();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.buttonCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.widthUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.hightUD)).BeginInit();
this.SuspendLayout();
//
// widthUD
//
this.widthUD.Increment = new System.Decimal(new int[] {
50,
0,
0,
0});
this.widthUD.Location = new System.Drawing.Point(72, 16);
this.widthUD.Maximum = new System.Decimal(new int[] {
5000,
0,
0,
0});
this.widthUD.Minimum = new System.Decimal(new int[] {
50,
0,
0,
0});
this.widthUD.Name = "widthUD";
this.widthUD.Size = new System.Drawing.Size(80, 21);
this.widthUD.TabIndex = 0;
this.widthUD.Value = new System.Decimal(new int[] {
600,
0,
0,
0});
//
// hightUD
//
this.hightUD.Increment = new System.Decimal(new int[] {
50,
0,
0,
0});
this.hightUD.Location = new System.Drawing.Point(72, 48);
this.hightUD.Maximum = new System.Decimal(new int[] {
5000,
0,
0,
0});
this.hightUD.Minimum = new System.Decimal(new int[] {
50,
0,
0,
0});
this.hightUD.Name = "hightUD";
this.hightUD.Size = new System.Drawing.Size(80, 21);
this.hightUD.TabIndex = 1;
this.hightUD.Value = new System.Decimal(new int[] {
600,
0,
0,
0});
this.hightUD.ValueChanged += new System.EventHandler(this.hightUD_ValueChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 23);
this.label1.TabIndex = 2;
this.label1.Text = "Width:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 23);
this.label2.TabIndex = 3;
this.label2.Text = "Height:";
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(16, 120);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(56, 23);
this.btnOK.TabIndex = 4;
this.btnOK.Text = "OK";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 88);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 5;
this.label3.Text = "BackColor:";
//
// btnBackColor
//
this.btnBackColor.BackColor = System.Drawing.Color.White;
this.btnBackColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnBackColor.Location = new System.Drawing.Point(112, 88);
this.btnBackColor.Name = "btnBackColor";
this.btnBackColor.Size = new System.Drawing.Size(40, 24);
this.btnBackColor.TabIndex = 6;
this.btnBackColor.Click += new System.EventHandler(this.btnBackColor_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(96, 120);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(56, 23);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// NewCanvasCfg
//
this.AcceptButton = this.btnOK;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(178, 151);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.btnBackColor);
this.Controls.Add(this.label3);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.hightUD);
this.Controls.Add(this.widthUD);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "NewCanvasCfg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "NewCanvas";
this.Load += new System.EventHandler(this.NewCanvasCfg_Load);
((System.ComponentModel.ISupportInitialize)(this.widthUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.hightUD)).EndInit();
this.ResumeLayout(false);
}
#endregion
// Set background color
private void btnBackColor_Click(object sender, System.EventArgs e)
{
this.colorDialog1.Color = this.btnBackColor.BackColor;
if(DialogResult.OK == this.colorDialog1.ShowDialog())
{
this.btnBackColor.BackColor = this.colorDialog1.Color;
}
}
private void btnOK_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void NewCanvasCfg_Load(object sender, System.EventArgs e)
{
}
private void buttonCancel_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void hightUD_ValueChanged(object sender, System.EventArgs e)
{
}
}
}