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

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. this.groupBox2.Enter += new System.EventHandler(this.groupBox2_Enter);
  123. // 
  124. // radioButtonGreen
  125. // 
  126. this.radioButtonGreen.Location = new System.Drawing.Point(16, 120);
  127. this.radioButtonGreen.Name = "radioButtonGreen";
  128. this.radioButtonGreen.TabIndex = 2;
  129. this.radioButtonGreen.Text = "Green";
  130. this.radioButtonGreen.CheckedChanged += new System.EventHandler(this.radioButtonGreen_CheckedChanged);
  131. // 
  132. // radioButtonRed
  133. // 
  134. this.radioButtonRed.Location = new System.Drawing.Point(16, 72);
  135. this.radioButtonRed.Name = "radioButtonRed";
  136. this.radioButtonRed.TabIndex = 1;
  137. this.radioButtonRed.Text = "Red";
  138. this.radioButtonRed.CheckedChanged += new System.EventHandler(this.radioButtonRed_CheckedChanged);
  139. // 
  140. // radioButtonBlack
  141. // 
  142. this.radioButtonBlack.Location = new System.Drawing.Point(16, 32);
  143. this.radioButtonBlack.Name = "radioButtonBlack";
  144. this.radioButtonBlack.TabIndex = 0;
  145. this.radioButtonBlack.Text = "Black";
  146. this.radioButtonBlack.CheckedChanged += new System.EventHandler(this.radioButtonBlack_CheckedChanged);
  147. // 
  148. // buttonOK
  149. // 
  150. this.buttonOK.Location = new System.Drawing.Point(40, 200);
  151. this.buttonOK.Name = "buttonOK";
  152. this.buttonOK.TabIndex = 2;
  153. this.buttonOK.Text = "OK";
  154. this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
  155. // 
  156. // buttonCancel
  157. // 
  158. this.buttonCancel.Location = new System.Drawing.Point(200, 200);
  159. this.buttonCancel.Name = "buttonCancel";
  160. this.buttonCancel.TabIndex = 3;
  161. this.buttonCancel.Text = "Cancel";
  162. this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
  163. // 
  164. // SettingDialog
  165. // 
  166. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  167. this.ClientSize = new System.Drawing.Size(328, 254);
  168. this.Controls.Add(this.buttonCancel);
  169. this.Controls.Add(this.buttonOK);
  170. this.Controls.Add(this.groupBox2);
  171. this.Controls.Add(this.groupBox1);
  172. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  173. this.ImeMode = System.Windows.Forms.ImeMode.Disable;
  174. this.MaximizeBox = false;
  175. this.MinimizeBox = false;
  176. this.Name = "SettingDialog";
  177. this.Text = "Setting";
  178. this.groupBox1.ResumeLayout(false);
  179. this.groupBox2.ResumeLayout(false);
  180. this.ResumeLayout(false);
  181. }
  182. #endregion
  183. private void radioButtonSingle_CheckedChanged(object sender, System.EventArgs e)
  184. {
  185. if(radioButtonSingle.Checked) {
  186. penWidth=4;
  187. radioButtonDouble.Checked=false;
  188. radioButtonTriple.Checked=false;
  189. }
  190. }
  191. private void radioButtonDouble_CheckedChanged(object sender, System.EventArgs e)
  192. {
  193. if(radioButtonDouble.Checked) 
  194. {
  195. penWidth=8;
  196. radioButtonSingle.Checked=false;
  197. radioButtonTriple.Checked=false;
  198. }
  199. }
  200. private void radioButtonTriple_CheckedChanged(object sender, System.EventArgs e)
  201. {
  202. if(radioButtonTriple.Checked) 
  203. {
  204. penWidth=12;
  205. radioButtonDouble.Checked=false;
  206. radioButtonSingle.Checked=false;
  207. }
  208. }
  209. private void radioButtonBlack_CheckedChanged(object sender, System.EventArgs e)
  210. {
  211. if(radioButtonBlack.Checked) {
  212. penColor=Color.Black;
  213. radioButtonRed.Checked=false;
  214. radioButtonGreen.Checked=false;
  215. }
  216. }
  217. private void radioButtonRed_CheckedChanged(object sender, System.EventArgs e)
  218. {
  219. if(radioButtonRed.Checked) 
  220. {
  221. penColor=Color.Red;
  222. radioButtonBlack.Checked=false;
  223. radioButtonGreen.Checked=false;
  224. }
  225. }
  226. private void radioButtonGreen_CheckedChanged(object sender, System.EventArgs e)
  227. {
  228. if(radioButtonGreen.Checked) 
  229. {
  230. penColor=Color.Green;
  231. radioButtonRed.Checked=false;
  232. radioButtonBlack.Checked=false;
  233. }
  234. }
  235. private void buttonOK_Click(object sender, System.EventArgs e)
  236. {
  237. PaintClient.SettingDialog.ActiveForm.Close();
  238. }
  239. private void buttonCancel_Click(object sender, System.EventArgs e)
  240. {
  241. this.Close();
  242. }
  243. private void groupBox2_Enter(object sender, System.EventArgs e)
  244. {
  245. }
  246. //属性
  247. public int PenWidth {
  248. get {
  249. return penWidth;
  250. }
  251. set {
  252. penWidth=value;
  253. }
  254. }
  255. public Color PenColor {
  256. get {
  257. return penColor;
  258. }
  259. set {
  260. penColor=value;
  261. }
  262. }
  263. }
  264. }