NewCanvas.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /****************************************************************************************
  2. **************************File Name: NewCanvas.cs,Version 1.0, 8 November 2004***********
  3. *****************************Author:Karthik Janaswami************************************
  4. ** This windows is used for create a new canvas. **
  5. ** You can change the canvas size setting and canvas background color in this windows **
  6. *****************************************************************************************/
  7. using System;
  8. using System.Drawing;
  9. using System.Collections;
  10. using System.ComponentModel;
  11. using System.Windows.Forms;
  12. namespace GraEditor
  13. {
  14. //Create new canvas
  15. public class NewCanvasCfg : System.Windows.Forms.Form
  16. {
  17. private System.Windows.Forms.NumericUpDown widthUD;
  18. private System.Windows.Forms.NumericUpDown hightUD;
  19. private System.Windows.Forms.Label label1;
  20. private System.Windows.Forms.Label label2;
  21. private System.Windows.Forms.Button btnOK;
  22. private System.Windows.Forms.Label label3;
  23. private System.Windows.Forms.Button btnBackColor;
  24. private System.Windows.Forms.ColorDialog colorDialog1;
  25. private System.Windows.Forms.Button buttonCancel;
  26. /// <summary>
  27. ///
  28. /// </summary>
  29. private System.ComponentModel.Container components = null;
  30. public NewCanvasCfg()
  31. {
  32. //
  33. // Windows
  34. //
  35. InitializeComponent();
  36. }
  37. protected override void Dispose( bool disposing )
  38. {
  39. if( disposing )
  40. {
  41. if(components != null)
  42. {
  43. components.Dispose();
  44. }
  45. }
  46. base.Dispose( disposing );
  47. }
  48. public Size CanvasSize
  49. {
  50. get
  51. {
  52. return new Size((int)this.widthUD.Value,(int)this.hightUD.Value);
  53. }
  54. set
  55. {
  56. this.widthUD.Value = value.Width;
  57. this.hightUD.Value = value.Height;
  58. }
  59. }
  60. public Color CanvasBackColor // Canvas background color
  61. {
  62. get { return btnBackColor.BackColor;}
  63. }
  64. #region Windows 窗体设计器生成的代码
  65. /// <summary>
  66. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  67. /// 此方法的内容。
  68. /// </summary>
  69. private void InitializeComponent()
  70. {
  71. this.widthUD = new System.Windows.Forms.NumericUpDown();
  72. this.hightUD = new System.Windows.Forms.NumericUpDown();
  73. this.label1 = new System.Windows.Forms.Label();
  74. this.label2 = new System.Windows.Forms.Label();
  75. this.btnOK = new System.Windows.Forms.Button();
  76. this.label3 = new System.Windows.Forms.Label();
  77. this.btnBackColor = new System.Windows.Forms.Button();
  78. this.colorDialog1 = new System.Windows.Forms.ColorDialog();
  79. this.buttonCancel = new System.Windows.Forms.Button();
  80. ((System.ComponentModel.ISupportInitialize)(this.widthUD)).BeginInit();
  81. ((System.ComponentModel.ISupportInitialize)(this.hightUD)).BeginInit();
  82. this.SuspendLayout();
  83. //
  84. // widthUD
  85. //
  86. this.widthUD.Increment = new System.Decimal(new int[] {
  87. 50,
  88. 0,
  89. 0,
  90. 0});
  91. this.widthUD.Location = new System.Drawing.Point(72, 16);
  92. this.widthUD.Maximum = new System.Decimal(new int[] {
  93. 5000,
  94. 0,
  95. 0,
  96. 0});
  97. this.widthUD.Minimum = new System.Decimal(new int[] {
  98. 50,
  99. 0,
  100. 0,
  101. 0});
  102. this.widthUD.Name = "widthUD";
  103. this.widthUD.Size = new System.Drawing.Size(80, 21);
  104. this.widthUD.TabIndex = 0;
  105. this.widthUD.Value = new System.Decimal(new int[] {
  106. 600,
  107. 0,
  108. 0,
  109. 0});
  110. //
  111. // hightUD
  112. //
  113. this.hightUD.Increment = new System.Decimal(new int[] {
  114. 50,
  115. 0,
  116. 0,
  117. 0});
  118. this.hightUD.Location = new System.Drawing.Point(72, 48);
  119. this.hightUD.Maximum = new System.Decimal(new int[] {
  120. 5000,
  121. 0,
  122. 0,
  123. 0});
  124. this.hightUD.Minimum = new System.Decimal(new int[] {
  125. 50,
  126. 0,
  127. 0,
  128. 0});
  129. this.hightUD.Name = "hightUD";
  130. this.hightUD.Size = new System.Drawing.Size(80, 21);
  131. this.hightUD.TabIndex = 1;
  132. this.hightUD.Value = new System.Decimal(new int[] {
  133. 600,
  134. 0,
  135. 0,
  136. 0});
  137. this.hightUD.ValueChanged += new System.EventHandler(this.hightUD_ValueChanged);
  138. //
  139. // label1
  140. //
  141. this.label1.Location = new System.Drawing.Point(8, 16);
  142. this.label1.Name = "label1";
  143. this.label1.Size = new System.Drawing.Size(48, 23);
  144. this.label1.TabIndex = 2;
  145. this.label1.Text = "Width:";
  146. //
  147. // label2
  148. //
  149. this.label2.Location = new System.Drawing.Point(8, 48);
  150. this.label2.Name = "label2";
  151. this.label2.Size = new System.Drawing.Size(48, 23);
  152. this.label2.TabIndex = 3;
  153. this.label2.Text = "Height:";
  154. //
  155. // btnOK
  156. //
  157. this.btnOK.Location = new System.Drawing.Point(16, 120);
  158. this.btnOK.Name = "btnOK";
  159. this.btnOK.Size = new System.Drawing.Size(56, 23);
  160. this.btnOK.TabIndex = 4;
  161. this.btnOK.Text = "OK";
  162. this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
  163. //
  164. // label3
  165. //
  166. this.label3.Location = new System.Drawing.Point(8, 88);
  167. this.label3.Name = "label3";
  168. this.label3.Size = new System.Drawing.Size(72, 23);
  169. this.label3.TabIndex = 5;
  170. this.label3.Text = "BackColor:";
  171. //
  172. // btnBackColor
  173. //
  174. this.btnBackColor.BackColor = System.Drawing.Color.White;
  175. this.btnBackColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
  176. this.btnBackColor.Location = new System.Drawing.Point(112, 88);
  177. this.btnBackColor.Name = "btnBackColor";
  178. this.btnBackColor.Size = new System.Drawing.Size(40, 24);
  179. this.btnBackColor.TabIndex = 6;
  180. this.btnBackColor.Click += new System.EventHandler(this.btnBackColor_Click);
  181. //
  182. // buttonCancel
  183. //
  184. this.buttonCancel.Location = new System.Drawing.Point(96, 120);
  185. this.buttonCancel.Name = "buttonCancel";
  186. this.buttonCancel.Size = new System.Drawing.Size(56, 23);
  187. this.buttonCancel.TabIndex = 7;
  188. this.buttonCancel.Text = "Cancel";
  189. this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
  190. //
  191. // NewCanvasCfg
  192. //
  193. this.AcceptButton = this.btnOK;
  194. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  195. this.ClientSize = new System.Drawing.Size(178, 151);
  196. this.Controls.Add(this.buttonCancel);
  197. this.Controls.Add(this.btnBackColor);
  198. this.Controls.Add(this.label3);
  199. this.Controls.Add(this.btnOK);
  200. this.Controls.Add(this.label2);
  201. this.Controls.Add(this.label1);
  202. this.Controls.Add(this.hightUD);
  203. this.Controls.Add(this.widthUD);
  204. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  205. this.Name = "NewCanvasCfg";
  206. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  207. this.Text = "NewCanvas";
  208. this.Load += new System.EventHandler(this.NewCanvasCfg_Load);
  209. ((System.ComponentModel.ISupportInitialize)(this.widthUD)).EndInit();
  210. ((System.ComponentModel.ISupportInitialize)(this.hightUD)).EndInit();
  211. this.ResumeLayout(false);
  212. }
  213. #endregion
  214. // Set background color
  215. private void btnBackColor_Click(object sender, System.EventArgs e)
  216. {
  217. this.colorDialog1.Color = this.btnBackColor.BackColor;
  218. if(DialogResult.OK == this.colorDialog1.ShowDialog())
  219. {
  220. this.btnBackColor.BackColor = this.colorDialog1.Color;
  221. }
  222. }
  223. private void btnOK_Click(object sender, System.EventArgs e)
  224. {
  225. this.DialogResult = DialogResult.OK;
  226. this.Close();
  227. }
  228. private void NewCanvasCfg_Load(object sender, System.EventArgs e)
  229. {
  230. }
  231. private void buttonCancel_Click(object sender, System.EventArgs e)
  232. {
  233. this.DialogResult = DialogResult.Cancel;
  234. this.Close();
  235. }
  236. private void hightUD_ValueChanged(object sender, System.EventArgs e)
  237. {
  238. }
  239. }
  240. }