123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- /****************************************************************************************
- **************************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;
- /// <summary>
- ///
- /// </summary>
- 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 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- 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)
- {
-
- }
- }
- }
|