EditEnvVariable.cs
上传用户:szltgg
上传日期:2019-05-16
资源大小:604k
文件大小:6k
源码类别:

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: EditEnvVariable.cs,v 1.2 2005/04/20 08:45:44 okajima Exp $
  4. */
  5. using System;
  6. using System.Drawing;
  7. using System.Collections;
  8. using System.ComponentModel;
  9. using System.Windows.Forms;
  10. namespace Poderosa.Forms
  11. {
  12. /// <summary>
  13. /// EditEnvVariable 偺奣梫偺愢柧偱偡丅
  14. /// </summary>
  15. internal class EditEnvVariable : System.Windows.Forms.Form
  16. {
  17. private bool _isNew;
  18. private EnvVariableList _parent;
  19. private System.Windows.Forms.Label _nameLabel;
  20. private TextBox _nameBox;
  21. private System.Windows.Forms.Label _valueLabel;
  22. private TextBox _valueBox;
  23. private System.Windows.Forms.Button _okButton;
  24. private System.Windows.Forms.Button _cancelButton;
  25. /// <summary>
  26. /// 昁梫側僨僓僀僫曄悢偱偡丅
  27. /// </summary>
  28. private System.ComponentModel.Container components = null;
  29. public EditEnvVariable(EnvVariableList p)
  30. {
  31. _parent = p;
  32. //
  33. // Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
  34. //
  35. InitializeComponent();
  36. //
  37. // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
  38. //
  39. this._nameLabel.Text = GApp.Strings.GetString("Form.EditEnvVariable._nameLabel");
  40. this._valueLabel.Text = GApp.Strings.GetString("Form.EditEnvVariable._valueLabel");
  41. this._okButton.Text = GApp.Strings.GetString("Common.OK");
  42. this._cancelButton.Text = GApp.Strings.GetString("Common.Cancel");
  43. this.Text = GApp.Strings.GetString("Form.EditEnvVariable.Text");
  44. }
  45. /// <summary>
  46. /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
  47. /// </summary>
  48. protected override void Dispose( bool disposing )
  49. {
  50. if( disposing )
  51. {
  52. if(components != null)
  53. {
  54. components.Dispose();
  55. }
  56. }
  57. base.Dispose( disposing );
  58. }
  59. #region Windows Form Designer generated code
  60. /// <summary>
  61. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  62. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  63. /// </summary>
  64. private void InitializeComponent()
  65. {
  66. this._nameLabel = new System.Windows.Forms.Label();
  67. this._nameBox = new TextBox();
  68. this._valueLabel = new System.Windows.Forms.Label();
  69. this._valueBox = new TextBox();
  70. this._okButton = new System.Windows.Forms.Button();
  71. this._cancelButton = new System.Windows.Forms.Button();
  72. this.SuspendLayout();
  73. // 
  74. // _nameLabel
  75. // 
  76. this._nameLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  77. this._nameLabel.Location = new System.Drawing.Point(8, 8);
  78. this._nameLabel.Name = "_nameLabel";
  79. this._nameLabel.Size = new System.Drawing.Size(56, 16);
  80. this._nameLabel.TabIndex = 0;
  81. // 
  82. // _nameBox
  83. // 
  84. this._nameBox.Location = new System.Drawing.Point(72, 8);
  85. this._nameBox.Name = "_nameBox";
  86. this._nameBox.Size = new System.Drawing.Size(216, 19);
  87. this._nameBox.TabIndex = 1;
  88. this._nameBox.Text = "";
  89. // 
  90. // _valueLabel
  91. // 
  92. this._valueLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  93. this._valueLabel.Location = new System.Drawing.Point(8, 32);
  94. this._valueLabel.Name = "_valueLabel";
  95. this._valueLabel.Size = new System.Drawing.Size(56, 16);
  96. this._valueLabel.TabIndex = 2;
  97. // 
  98. // _valueBox
  99. // 
  100. this._valueBox.Location = new System.Drawing.Point(72, 32);
  101. this._valueBox.Name = "_valueBox";
  102. this._valueBox.Size = new System.Drawing.Size(216, 19);
  103. this._valueBox.TabIndex = 3;
  104. this._valueBox.Text = "";
  105. // 
  106. // _okButton
  107. // 
  108. this._okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  109. this._okButton.Location = new System.Drawing.Point(136, 64);
  110. this._okButton.Name = "_okButton";
  111. this._okButton.FlatStyle = FlatStyle.System;
  112. this._okButton.TabIndex = 4;
  113. this._okButton.Click += new EventHandler(OnOK);
  114. // 
  115. // _cancelButton
  116. // 
  117. this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  118. this._cancelButton.Location = new System.Drawing.Point(216, 64);
  119. this._cancelButton.Name = "_cancelButton";
  120. this._cancelButton.FlatStyle = FlatStyle.System;
  121. this._cancelButton.TabIndex = 5;
  122. // 
  123. // EditEnvVariable
  124. // 
  125. this.AcceptButton = this._okButton;
  126. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  127. this.CancelButton = this._cancelButton;
  128. this.ClientSize = new System.Drawing.Size(292, 93);
  129. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  130.   this._cancelButton,
  131.   this._okButton,
  132.   this._valueBox,
  133.   this._valueLabel,
  134.   this._nameBox,
  135.   this._nameLabel});
  136. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  137. this.MaximizeBox = false;
  138. this.MinimizeBox = false;
  139. this.Name = "EditEnvVariable";
  140. this.ShowInTaskbar = false;
  141. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  142. this.ResumeLayout(false);
  143. }
  144. #endregion
  145. public string VarName {
  146. get {
  147. return _nameBox.Text;
  148. }
  149. set {
  150. _nameBox.Text = value;
  151. }
  152. }
  153. public string VarValue {
  154. get {
  155. return _valueBox.Text;
  156. }
  157. set {
  158. _valueBox.Text = value;
  159. }
  160. }
  161. public bool IsNewVariable {
  162. get {
  163. return _isNew;
  164. }
  165. set {
  166. _isNew = value;
  167. _nameBox.Enabled = _isNew;
  168. }
  169. }
  170. private void OnOK(object sender, EventArgs args) {
  171. this.DialogResult = DialogResult.None;
  172. string n = _nameBox.Text;
  173. if(n.Length==0)
  174. GUtil.Warning(this, GApp.Strings.GetString("Message.EditEnvVariable.EmptyName"));
  175. else if(n.IndexOf('=')!=-1 || n.IndexOf(' ')!=-1)
  176. GUtil.Warning(this, GApp.Strings.GetString("Message.EditEnvVariable.InvalidChars"));
  177. else if(_isNew && _parent.HasVariable(n))
  178. GUtil.Warning(this, GApp.Strings.GetString("Message.EditEnvVariable.DuplicatedName"));
  179. else //success
  180. this.DialogResult = DialogResult.OK;
  181. }
  182. }
  183. }