NewForm.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace GraphicalCS
  7. {
  8. /// <summary>
  9. /// newForm 的摘要说明。
  10. /// </summary>
  11. public class NewForm : System.Windows.Forms.Form
  12. {
  13. private System.Windows.Forms.TextBox txtBox;
  14. private System.Windows.Forms.Button btnSubmit;
  15. private System.Windows.Forms.Button btnCancle;
  16. private string OutPut;
  17. private bool boolvalue;
  18. private System.Windows.Forms.FontDialog fontDialog;
  19. private System.Windows.Forms.Button btnFont;
  20. /// <summary>
  21. /// 必需的设计器变量。
  22. /// </summary>
  23. private System.ComponentModel.Container components = null;
  24. public string outText
  25. {
  26. get
  27. {
  28. return OutPut;
  29. }
  30. }
  31. public Size txtSize
  32. {
  33. get
  34. {
  35. return new Size(this.txtBox.Font.Height*2*this.txtBox.Text.Length, this.txtBox.Font.Height);
  36. }
  37. }
  38. public Font TxtFont
  39. {
  40. get
  41. {
  42. return this.txtBox.Font;
  43. }
  44. }
  45. public bool cancle
  46. {
  47. get
  48. {
  49. return boolvalue;
  50. }
  51. }
  52. public NewForm()
  53. {
  54. //
  55. // Windows 窗体设计器支持所必需的
  56. //
  57. InitializeComponent();
  58. //
  59. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  60. //
  61. this.txtBox.Focus();
  62. }
  63. /// <summary>
  64. /// 清理所有正在使用的资源。
  65. /// </summary>
  66. protected override void Dispose( bool disposing )
  67. {
  68. if( disposing )
  69. {
  70. if(components != null)
  71. {
  72. components.Dispose();
  73. }
  74. }
  75. base.Dispose( disposing );
  76. }
  77. #region Windows 窗体设计器生成的代码
  78. /// <summary>
  79. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  80. /// 此方法的内容。
  81. /// </summary>
  82. private void InitializeComponent()
  83. {
  84. this.txtBox = new System.Windows.Forms.TextBox();
  85. this.btnSubmit = new System.Windows.Forms.Button();
  86. this.btnCancle = new System.Windows.Forms.Button();
  87. this.fontDialog = new System.Windows.Forms.FontDialog();
  88. this.btnFont = new System.Windows.Forms.Button();
  89. this.SuspendLayout();
  90. //
  91. // txtBox
  92. //
  93. this.txtBox.Location = new System.Drawing.Point(32, 32);
  94. this.txtBox.Name = "txtBox";
  95. this.txtBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  96. this.txtBox.Size = new System.Drawing.Size(160, 21);
  97. this.txtBox.TabIndex = 0;
  98. this.txtBox.Text = "";
  99. //
  100. // btnSubmit
  101. //
  102. this.btnSubmit.Location = new System.Drawing.Point(208, 32);
  103. this.btnSubmit.Name = "btnSubmit";
  104. this.btnSubmit.Size = new System.Drawing.Size(56, 23);
  105. this.btnSubmit.TabIndex = 0;
  106. this.btnSubmit.Text = "Submit";
  107. this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
  108. //
  109. // btnCancle
  110. //
  111. this.btnCancle.Location = new System.Drawing.Point(280, 32);
  112. this.btnCancle.Name = "btnCancle";
  113. this.btnCancle.Size = new System.Drawing.Size(56, 23);
  114. this.btnCancle.TabIndex = 1;
  115. this.btnCancle.Text = "Cancle";
  116. this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
  117. //
  118. // btnFont
  119. //
  120. this.btnFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  121. this.btnFont.Location = new System.Drawing.Point(208, 64);
  122. this.btnFont.Name = "btnFont";
  123. this.btnFont.TabIndex = 2;
  124. this.btnFont.Text = "Font";
  125. this.btnFont.Click += new System.EventHandler(this.btnFont_Click);
  126. //
  127. // NewForm
  128. //
  129. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  130. this.ClientSize = new System.Drawing.Size(344, 102);
  131. this.Controls.Add(this.btnFont);
  132. this.Controls.Add(this.btnCancle);
  133. this.Controls.Add(this.btnSubmit);
  134. this.Controls.Add(this.txtBox);
  135. this.Name = "NewForm";
  136. this.Text = "InputText";
  137. this.ResumeLayout(false);
  138. }
  139. #endregion
  140. private void btnSubmit_Click(object sender, System.EventArgs e)
  141. {
  142. boolvalue = false;
  143. OutPut = this.txtBox.Text;
  144. this.Hide();
  145. }
  146. private void btnCancle_Click(object sender, System.EventArgs e)
  147. {
  148. boolvalue = true;
  149. this.Hide();
  150. }
  151. private void btnFont_Click(object sender, System.EventArgs e)
  152. {
  153. if(fontDialog.ShowDialog() == DialogResult.OK)
  154. {
  155. this.txtBox.Font = fontDialog.Font;
  156. }
  157. }
  158. }
  159. }