SettingDialog.cs
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:8k
源码类别:

C#编程

开发平台:

Others

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace PaintClient
  7. {
  8. /// <summary>
  9. /// SettingDialog 的摘要说明。
  10. /// </summary>
  11. public class SettingDialog : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.GroupBox groupBox1;
  14. private System.Windows.Forms.GroupBox groupBox2;
  15. private System.Windows.Forms.RadioButton radioButtonSingle;
  16. private System.Windows.Forms.RadioButton radioButtonDouble;
  17. private System.Windows.Forms.RadioButton radioButtonTriple;
  18. private System.Windows.Forms.RadioButton radioButtonBlack;
  19. private System.Windows.Forms.RadioButton radioButtonRed;
  20. private System.Windows.Forms.RadioButton radioButtonGreen;
  21. private System.Windows.Forms.Button buttonOK;
  22. private System.Windows.Forms.Button buttonCancel;
  23. /// <summary>
  24. /// 必需的设计器变量。
  25. /// </summary>
  26. private System.ComponentModel.Container components = null;
  27. //Add by myself
  28. private int penWidth=4;
  29. private Color penColor=Color.Black;
  30. public SettingDialog()
  31. {
  32. //
  33. // Windows 窗体设计器支持所必需的
  34. //
  35. InitializeComponent();
  36. //
  37. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  38. //
  39. }
  40. /// <summary>
  41. /// 清理所有正在使用的资源。
  42. /// </summary>
  43. protected override void Dispose( bool disposing )
  44. {
  45. if( disposing )
  46. {
  47. if(components != null)
  48. {
  49. components.Dispose();
  50. }
  51. }
  52. base.Dispose( disposing );
  53. }
  54. #region Windows 窗体设计器生成的代码
  55. /// <summary>
  56. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  57. /// 此方法的内容。
  58. /// </summary>
  59. private void InitializeComponent()
  60. {
  61. this.groupBox1 = new System.Windows.Forms.GroupBox();
  62. this.radioButtonTriple = new System.Windows.Forms.RadioButton();
  63. this.radioButtonDouble = new System.Windows.Forms.RadioButton();
  64. this.radioButtonSingle = new System.Windows.Forms.RadioButton();
  65. this.groupBox2 = new System.Windows.Forms.GroupBox();
  66. this.radioButtonGreen = new System.Windows.Forms.RadioButton();
  67. this.radioButtonRed = new System.Windows.Forms.RadioButton();
  68. this.radioButtonBlack = new System.Windows.Forms.RadioButton();
  69. this.buttonOK = new System.Windows.Forms.Button();
  70. this.buttonCancel = new System.Windows.Forms.Button();
  71. this.groupBox1.SuspendLayout();
  72. this.groupBox2.SuspendLayout();
  73. this.SuspendLayout();
  74. // 
  75. // groupBox1
  76. // 
  77. this.groupBox1.Controls.Add(this.radioButtonTriple);
  78. this.groupBox1.Controls.Add(this.radioButtonDouble);
  79. this.groupBox1.Controls.Add(this.radioButtonSingle);
  80. this.groupBox1.Location = new System.Drawing.Point(16, 16);
  81. this.groupBox1.Name = "groupBox1";
  82. this.groupBox1.Size = new System.Drawing.Size(136, 160);
  83. this.groupBox1.TabIndex = 0;
  84. this.groupBox1.TabStop = false;
  85. this.groupBox1.Text = "笔宽";
  86. // 
  87. // radioButtonTriple
  88. // 
  89. this.radioButtonTriple.Location = new System.Drawing.Point(16, 120);
  90. this.radioButtonTriple.Name = "radioButtonTriple";
  91. this.radioButtonTriple.TabIndex = 4;
  92. this.radioButtonTriple.Text = "Triple";
  93. this.radioButtonTriple.CheckedChanged += new System.EventHandler(this.radioButtonTriple_CheckedChanged);
  94. // 
  95. // radioButtonDouble
  96. // 
  97. this.radioButtonDouble.Location = new System.Drawing.Point(16, 72);
  98. this.radioButtonDouble.Name = "radioButtonDouble";
  99. this.radioButtonDouble.TabIndex = 3;
  100. this.radioButtonDouble.Text = "Double";
  101. this.radioButtonDouble.CheckedChanged += new System.EventHandler(this.radioButtonDouble_CheckedChanged);
  102. // 
  103. // radioButtonSingle
  104. // 
  105. this.radioButtonSingle.Location = new System.Drawing.Point(16, 32);
  106. this.radioButtonSingle.Name = "radioButtonSingle";
  107. this.radioButtonSingle.TabIndex = 2;
  108. this.radioButtonSingle.Text = "Single";
  109. this.radioButtonSingle.CheckedChanged += new System.EventHandler(this.radioButtonSingle_CheckedChanged);
  110. // 
  111. // groupBox2
  112. // 
  113. this.groupBox2.Controls.Add(this.radioButtonGreen);
  114. this.groupBox2.Controls.Add(this.radioButtonRed);
  115. this.groupBox2.Controls.Add(this.radioButtonBlack);
  116. this.groupBox2.Location = new System.Drawing.Point(176, 16);
  117. this.groupBox2.Name = "groupBox2";
  118. this.groupBox2.Size = new System.Drawing.Size(136, 160);
  119. this.groupBox2.TabIndex = 1;
  120. this.groupBox2.TabStop = false;
  121. this.groupBox2.Text = "颜色";
  122. // 
  123. // radioButtonGreen
  124. // 
  125. this.radioButtonGreen.Location = new System.Drawing.Point(16, 120);
  126. this.radioButtonGreen.Name = "radioButtonGreen";
  127. this.radioButtonGreen.TabIndex = 2;
  128. this.radioButtonGreen.Text = "Green";
  129. this.radioButtonGreen.CheckedChanged += new System.EventHandler(this.radioButtonGreen_CheckedChanged);
  130. // 
  131. // radioButtonRed
  132. // 
  133. this.radioButtonRed.Location = new System.Drawing.Point(16, 72);
  134. this.radioButtonRed.Name = "radioButtonRed";
  135. this.radioButtonRed.TabIndex = 1;
  136. this.radioButtonRed.Text = "Red";
  137. this.radioButtonRed.CheckedChanged += new System.EventHandler(this.radioButtonRed_CheckedChanged);
  138. // 
  139. // radioButtonBlack
  140. // 
  141. this.radioButtonBlack.Location = new System.Drawing.Point(16, 32);
  142. this.radioButtonBlack.Name = "radioButtonBlack";
  143. this.radioButtonBlack.TabIndex = 0;
  144. this.radioButtonBlack.Text = "Black";
  145. this.radioButtonBlack.CheckedChanged += new System.EventHandler(this.radioButtonBlack_CheckedChanged);
  146. // 
  147. // buttonOK
  148. // 
  149. this.buttonOK.Location = new System.Drawing.Point(40, 200);
  150. this.buttonOK.Name = "buttonOK";
  151. this.buttonOK.TabIndex = 2;
  152. this.buttonOK.Text = "OK";
  153. this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
  154. // 
  155. // buttonCancel
  156. // 
  157. this.buttonCancel.Location = new System.Drawing.Point(200, 200);
  158. this.buttonCancel.Name = "buttonCancel";
  159. this.buttonCancel.TabIndex = 3;
  160. this.buttonCancel.Text = "Cancel";
  161. this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
  162. // 
  163. // SettingDialog
  164. // 
  165. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  166. this.ClientSize = new System.Drawing.Size(328, 254);
  167. this.Controls.Add(this.buttonCancel);
  168. this.Controls.Add(this.buttonOK);
  169. this.Controls.Add(this.groupBox2);
  170. this.Controls.Add(this.groupBox1);
  171. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  172. this.ImeMode = System.Windows.Forms.ImeMode.Disable;
  173. this.MaximizeBox = false;
  174. this.MinimizeBox = false;
  175. this.Name = "SettingDialog";
  176. this.Text = "Setting";
  177. this.groupBox1.ResumeLayout(false);
  178. this.groupBox2.ResumeLayout(false);
  179. this.ResumeLayout(false);
  180. }
  181. #endregion
  182. private void radioButtonSingle_CheckedChanged(object sender, System.EventArgs e)
  183. {
  184. if(radioButtonSingle.Checked) {
  185. penWidth=4;
  186. radioButtonDouble.Checked=false;
  187. radioButtonTriple.Checked=false;
  188. }
  189. }
  190. private void radioButtonDouble_CheckedChanged(object sender, System.EventArgs e)
  191. {
  192. if(radioButtonDouble.Checked) 
  193. {
  194. penWidth=8;
  195. radioButtonSingle.Checked=false;
  196. radioButtonTriple.Checked=false;
  197. }
  198. }
  199. private void radioButtonTriple_CheckedChanged(object sender, System.EventArgs e)
  200. {
  201. if(radioButtonTriple.Checked) 
  202. {
  203. penWidth=12;
  204. radioButtonDouble.Checked=false;
  205. radioButtonSingle.Checked=false;
  206. }
  207. }
  208. private void radioButtonBlack_CheckedChanged(object sender, System.EventArgs e)
  209. {
  210. if(radioButtonBlack.Checked) {
  211. penColor=Color.Black;
  212. radioButtonRed.Checked=false;
  213. radioButtonGreen.Checked=false;
  214. }
  215. }
  216. private void radioButtonRed_CheckedChanged(object sender, System.EventArgs e)
  217. {
  218. if(radioButtonRed.Checked) 
  219. {
  220. penColor=Color.Red;
  221. radioButtonBlack.Checked=false;
  222. radioButtonGreen.Checked=false;
  223. }
  224. }
  225. private void radioButtonGreen_CheckedChanged(object sender, System.EventArgs e)
  226. {
  227. if(radioButtonGreen.Checked) 
  228. {
  229. penColor=Color.Green;
  230. radioButtonRed.Checked=false;
  231. radioButtonBlack.Checked=false;
  232. }
  233. }
  234. private void buttonOK_Click(object sender, System.EventArgs e)
  235. {
  236. PaintClient.SettingDialog.ActiveForm.Close();
  237. }
  238. private void buttonCancel_Click(object sender, System.EventArgs e)
  239. {
  240. this.Close();
  241. }
  242. //属性
  243. public int PenWidth {
  244. get {
  245. return penWidth;
  246. }
  247. set {
  248. penWidth=value;
  249. }
  250. }
  251. public Color PenColor {
  252. get {
  253. return penColor;
  254. }
  255. set {
  256. penColor=value;
  257. }
  258. }
  259. }
  260. }