NewCanvas.cs 8.1 KB

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