PlayIntervalSettingDialog.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace PaintDotNet
  11. {
  12. /// <summary>
  13. /// 播放器间隔
  14. /// </summary>
  15. public partial class PlayIntervalSettingDialog : PdnBaseForm
  16. {
  17. private Label label1;
  18. public TextBox textBox1;
  19. private Label label2;
  20. public Button button1;
  21. private Button button2;
  22. public PlayIntervalSettingDialog()
  23. {
  24. InitializeComponent();
  25. this.label1.Text = PdnResources.GetString("Menu.Timedelay.Text") + ":";
  26. this.button1.Text = PdnResources.GetString("Menu.confirm.Text");
  27. this.button2.Text = PdnResources.GetString("Menu.cancel.text");
  28. this.Text = PdnResources.GetString("Menu.Playerinterval.Text");
  29. }
  30. private void InitializeComponent()
  31. {
  32. this.label1 = new System.Windows.Forms.Label();
  33. this.textBox1 = new System.Windows.Forms.TextBox();
  34. this.label2 = new System.Windows.Forms.Label();
  35. this.button1 = new System.Windows.Forms.Button();
  36. this.button2 = new System.Windows.Forms.Button();
  37. this.SuspendLayout();
  38. //
  39. // label1
  40. //
  41. this.label1.AutoSize = true;
  42. this.label1.Location = new System.Drawing.Point(33, 30);
  43. this.label1.Name = "label1";
  44. this.label1.Size = new System.Drawing.Size(41, 12);
  45. this.label1.TabIndex = 0;
  46. this.label1.Text = "延时:";
  47. //
  48. // textBox1
  49. //
  50. this.textBox1.Location = new System.Drawing.Point(80, 26);
  51. this.textBox1.Name = "textBox1";
  52. this.textBox1.Size = new System.Drawing.Size(81, 21);
  53. this.textBox1.TabIndex = 1;
  54. this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
  55. //
  56. // label2
  57. //
  58. this.label2.AutoSize = true;
  59. this.label2.Location = new System.Drawing.Point(167, 30);
  60. this.label2.Name = "label2";
  61. this.label2.Size = new System.Drawing.Size(17, 12);
  62. this.label2.TabIndex = 2;
  63. this.label2.Text = "ms";
  64. //
  65. // button1
  66. //
  67. this.button1.Location = new System.Drawing.Point(272, 24);
  68. this.button1.Name = "button1";
  69. this.button1.Size = new System.Drawing.Size(75, 23);
  70. this.button1.TabIndex = 3;
  71. this.button1.Text = "确认";
  72. this.button1.UseVisualStyleBackColor = true;
  73. //
  74. // button2
  75. //
  76. this.button2.Location = new System.Drawing.Point(272, 65);
  77. this.button2.Name = "button2";
  78. this.button2.Size = new System.Drawing.Size(75, 23);
  79. this.button2.TabIndex = 4;
  80. this.button2.Text = "取消";
  81. this.button2.UseVisualStyleBackColor = true;
  82. this.button2.Click += new System.EventHandler(this.button2_Click);
  83. //
  84. // PlayIntervalSettingDialog
  85. //
  86. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  87. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
  88. this.ClientSize = new System.Drawing.Size(372, 110);
  89. this.Controls.Add(this.button2);
  90. this.Controls.Add(this.button1);
  91. this.Controls.Add(this.label2);
  92. this.Controls.Add(this.textBox1);
  93. this.Controls.Add(this.label1);
  94. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  95. this.MaximizeBox = false;
  96. this.MinimizeBox = false;
  97. this.Name = "PlayIntervalSettingDialog";
  98. this.Text = "播放器间隔";
  99. this.Controls.SetChildIndex(this.label1, 0);
  100. this.Controls.SetChildIndex(this.textBox1, 0);
  101. this.Controls.SetChildIndex(this.label2, 0);
  102. this.Controls.SetChildIndex(this.button1, 0);
  103. this.Controls.SetChildIndex(this.button2, 0);
  104. this.ResumeLayout(false);
  105. this.PerformLayout();
  106. }
  107. /// <summary>
  108. /// 取消按钮
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. private void button2_Click(object sender, EventArgs e)
  113. {
  114. this.Close();
  115. }
  116. /// <summary>
  117. /// 限制只可以输入0-9数字以及退格键
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  122. {
  123. if (e.KeyChar != '\b')//这是允许输入退格键 
  124.             {
  125. int len = this.textBox1.Text.Length;
  126. if (len < 1 && e.KeyChar == '0')
  127. {
  128. e.Handled = true;
  129. }
  130. else if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字 
  131.                 {
  132. e.Handled = true;
  133. }
  134. }
  135. }
  136. }
  137. }