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

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: ServerInfo.cs,v 1.2 2005/04/20 08:45:45 okajima Exp $
  4. */
  5. using System;
  6. using System.Drawing;
  7. using System.Collections;
  8. using System.ComponentModel;
  9. using System.Windows.Forms;
  10. using System.Net;
  11. using System.Text;
  12. using Poderosa;
  13. using Poderosa.Toolkit;
  14. using EnumDescAttributeT = Poderosa.Toolkit.EnumDescAttribute;
  15. using Poderosa.Communication;
  16. using Poderosa.ConnectionParam;
  17. using Poderosa.Terminal;
  18. namespace Poderosa.Forms
  19. {
  20. /// <summary>
  21. /// ServerInfo 偺奣梫偺愢柧偱偡丅
  22. /// </summary>
  23. internal class ServerInfo : System.Windows.Forms.Form
  24. {
  25. private System.Windows.Forms.Button _okButton;
  26. private System.Windows.Forms.Label _serverNamesLabel;
  27. private System.Windows.Forms.TextBox _serverNamesBox;
  28. private System.Windows.Forms.Label _IPAddressLabel;
  29. private System.Windows.Forms.TextBox _IPAddressBox;
  30. private System.Windows.Forms.TextBox _protocolBox;
  31. private System.Windows.Forms.Label _protocolLabel;
  32. private System.Windows.Forms.TextBox _terminalTypeBox;
  33. private System.Windows.Forms.Label _terminalTypeLabel;
  34. private System.Windows.Forms.Label _parameterLabel;
  35. private System.Windows.Forms.TextBox _parameterBox;
  36. private System.Windows.Forms.Label _statsLabel;
  37. private System.Windows.Forms.Label _transmitBytes;
  38. private System.Windows.Forms.Label _receiveBytes;
  39. private System.Windows.Forms.Label _logLabel;
  40. private System.Windows.Forms.TextBox _logBox;
  41. /// <summary>
  42. /// 昁梫側僨僓僀僫曄悢偱偡丅
  43. /// </summary>
  44. private System.ComponentModel.Container components = null;
  45. public ServerInfo(TerminalConnection con)
  46. {
  47. //
  48. // Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
  49. //
  50. InitializeComponent();
  51. //
  52. // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
  53. //
  54. _serverNamesBox.Text = con.ServerName;
  55. _IPAddressBox.Text = con.ServerAddress==null? "" : con.ServerAddress.ToString();
  56. _protocolBox.Text = con.ProtocolDescription;
  57. _parameterBox.Lines = con.ConnectionParameter;
  58. _terminalTypeBox.Text = EnumDescAttributeT.For(typeof(TerminalType)).GetDescription(con.Param.TerminalType);
  59. string li = EnumDescAttributeT.For(typeof(LogType)).GetDescription(con.LogType);
  60. if(con.LogType!=LogType.None) li += "(" + con.LogPath + ")";
  61. _logBox.Text = li;
  62. _receiveBytes.Text = String.Format("{0,10}{1}", con.ReceivedDataSize, GApp.Strings.GetString("Caption.ServerInfo.BytesReceived"));
  63. _transmitBytes.Text = String.Format("{0,10}{1}", con.SentDataSize, GApp.Strings.GetString("Caption.ServerInfo.BytesSent"));
  64. this._okButton.Text = GApp.Strings.GetString("Common.OK");
  65. this._serverNamesLabel.Text = GApp.Strings.GetString("Form.ServerInfo._serverNamesLabel");
  66. this._IPAddressLabel.Text = GApp.Strings.GetString("Form.ServerInfo._IPAddressLabel");
  67. this._protocolLabel.Text = GApp.Strings.GetString("Form.ServerInfo._protocolLabel");
  68. this._terminalTypeLabel.Text = GApp.Strings.GetString("Form.ServerInfo._terminalTypeLabel");
  69. this._parameterLabel.Text = GApp.Strings.GetString("Form.ServerInfo._parameterLabel");
  70. this._statsLabel.Text = GApp.Strings.GetString("Form.ServerInfo._statsLabel");
  71. this._logLabel.Text = GApp.Strings.GetString("Form.ServerInfo._logLabel");
  72. this.Text = GApp.Strings.GetString("Form.ServerInfo.Text");
  73. }
  74. /// <summary>
  75. /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
  76. /// </summary>
  77. protected override void Dispose( bool disposing )
  78. {
  79. if( disposing )
  80. {
  81. if(components != null)
  82. {
  83. components.Dispose();
  84. }
  85. }
  86. base.Dispose( disposing );
  87. }
  88. #region Windows Form Designer generated code
  89. /// <summary>
  90. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  91. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  92. /// </summary>
  93. private void InitializeComponent()
  94. {
  95. this._okButton = new System.Windows.Forms.Button();
  96. this._serverNamesLabel = new System.Windows.Forms.Label();
  97. this._serverNamesBox = new System.Windows.Forms.TextBox();
  98. this._IPAddressLabel = new System.Windows.Forms.Label();
  99. this._IPAddressBox = new System.Windows.Forms.TextBox();
  100. this._protocolBox = new System.Windows.Forms.TextBox();
  101. this._protocolLabel = new System.Windows.Forms.Label();
  102. this._terminalTypeBox = new System.Windows.Forms.TextBox();
  103. this._terminalTypeLabel = new System.Windows.Forms.Label();
  104. this._parameterLabel = new System.Windows.Forms.Label();
  105. this._parameterBox = new System.Windows.Forms.TextBox();
  106. this._statsLabel = new System.Windows.Forms.Label();
  107. this._transmitBytes = new System.Windows.Forms.Label();
  108. this._receiveBytes = new System.Windows.Forms.Label();
  109. this._logLabel = new System.Windows.Forms.Label();
  110. this._logBox = new System.Windows.Forms.TextBox();
  111. this.SuspendLayout();
  112. // 
  113. // _okButton
  114. // 
  115. this._okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  116. this._okButton.Location = new System.Drawing.Point(112, 256);
  117. this._okButton.Name = "_okButton";
  118. this._okButton.FlatStyle = FlatStyle.System;
  119. this._okButton.TabIndex = 0;
  120. // 
  121. // _serverNamesLabel
  122. // 
  123. this._serverNamesLabel.Location = new System.Drawing.Point(8, 8);
  124. this._serverNamesLabel.Name = "_serverNamesLabel";
  125. this._serverNamesLabel.Size = new System.Drawing.Size(80, 16);
  126. this._serverNamesLabel.TabIndex = 1;
  127. this._serverNamesLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  128. // 
  129. // _serverNamesBox
  130. // 
  131. this._serverNamesBox.Location = new System.Drawing.Point(88, 8);
  132. this._serverNamesBox.Name = "_serverNamesBox";
  133. this._serverNamesBox.ReadOnly = true;
  134. this._serverNamesBox.Size = new System.Drawing.Size(224, 19);
  135. this._serverNamesBox.TabIndex = 2;
  136. this._serverNamesBox.Text = "";
  137. // 
  138. // _IPAddressLabel
  139. // 
  140. this._IPAddressLabel.Location = new System.Drawing.Point(8, 32);
  141. this._IPAddressLabel.Name = "_IPAddressLabel";
  142. this._IPAddressLabel.Size = new System.Drawing.Size(80, 16);
  143. this._IPAddressLabel.TabIndex = 3;
  144. this._IPAddressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  145. // 
  146. // _IPAddressBox
  147. // 
  148. this._IPAddressBox.Location = new System.Drawing.Point(88, 32);
  149. this._IPAddressBox.Name = "_IPAddressBox";
  150. this._IPAddressBox.ReadOnly = true;
  151. this._IPAddressBox.Size = new System.Drawing.Size(224, 19);
  152. this._IPAddressBox.TabIndex = 4;
  153. this._IPAddressBox.Text = "";
  154. // 
  155. // _protocolBox
  156. // 
  157. this._protocolBox.Location = new System.Drawing.Point(88, 56);
  158. this._protocolBox.Name = "_protocolBox";
  159. this._protocolBox.ReadOnly = true;
  160. this._protocolBox.Size = new System.Drawing.Size(224, 19);
  161. this._protocolBox.TabIndex = 5;
  162. this._protocolBox.Text = "";
  163. // 
  164. // _protocolLabel
  165. // 
  166. this._protocolLabel.Location = new System.Drawing.Point(8, 56);
  167. this._protocolLabel.Name = "_protocolLabel";
  168. this._protocolLabel.Size = new System.Drawing.Size(80, 16);
  169. this._protocolLabel.TabIndex = 6;
  170. this._protocolLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  171. // 
  172. // _terminalTypeBox
  173. // 
  174. this._terminalTypeBox.Location = new System.Drawing.Point(88, 80);
  175. this._terminalTypeBox.Name = "_terminalTypeBox";
  176. this._terminalTypeBox.ReadOnly = true;
  177. this._terminalTypeBox.Size = new System.Drawing.Size(224, 19);
  178. this._terminalTypeBox.TabIndex = 5;
  179. this._terminalTypeBox.Text = "";
  180. // 
  181. // _terminalTypeLabel
  182. // 
  183. this._terminalTypeLabel.Location = new System.Drawing.Point(8, 80);
  184. this._terminalTypeLabel.Name = "_terminalTypeLabel";
  185. this._terminalTypeLabel.Size = new System.Drawing.Size(80, 16);
  186. this._terminalTypeLabel.TabIndex = 6;
  187. this._terminalTypeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  188. // 
  189. // _parameterLabel
  190. // 
  191. this._parameterLabel.Location = new System.Drawing.Point(8, 104);
  192. this._parameterLabel.Name = "_parameterLabel";
  193. this._parameterLabel.Size = new System.Drawing.Size(80, 16);
  194. this._parameterLabel.TabIndex = 7;
  195. this._parameterLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  196. // 
  197. // _parameterBox
  198. // 
  199. this._parameterBox.Location = new System.Drawing.Point(88, 104);
  200. this._parameterBox.Multiline = true;
  201. this._parameterBox.Name = "_parameterBox";
  202. this._parameterBox.ReadOnly = true;
  203. this._parameterBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  204. this._parameterBox.Size = new System.Drawing.Size(224, 80);
  205. this._parameterBox.TabIndex = 8;
  206. this._parameterBox.Text = "";
  207. // 
  208. // _statsLabel
  209. // 
  210. this._statsLabel.Location = new System.Drawing.Point(8, 224);
  211. this._statsLabel.Name = "_statsLabel";
  212. this._statsLabel.Size = new System.Drawing.Size(104, 16);
  213. this._statsLabel.TabIndex = 9;
  214. this._statsLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  215. // 
  216. // _transmitBytes
  217. // 
  218. this._transmitBytes.Location = new System.Drawing.Point(120, 224);
  219. this._transmitBytes.Name = "_transmitBytes";
  220. this._transmitBytes.Size = new System.Drawing.Size(184, 16);
  221. this._transmitBytes.TabIndex = 10;
  222. this._transmitBytes.Text = "0";
  223. this._transmitBytes.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  224. // 
  225. // _receiveBytes
  226. // 
  227. this._receiveBytes.Location = new System.Drawing.Point(120, 240);
  228. this._receiveBytes.Name = "_receiveBytes";
  229. this._receiveBytes.Size = new System.Drawing.Size(184, 16);
  230. this._receiveBytes.TabIndex = 11;
  231. this._receiveBytes.Text = "0";
  232. this._receiveBytes.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  233. // 
  234. // _logLabel
  235. // 
  236. this._logLabel.Location = new System.Drawing.Point(8, 192);
  237. this._logLabel.Name = "_logLabel";
  238. this._logLabel.Size = new System.Drawing.Size(80, 16);
  239. this._logLabel.TabIndex = 13;
  240. this._logLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  241. // 
  242. // _logBox
  243. // 
  244. this._logBox.Location = new System.Drawing.Point(88, 192);
  245. this._logBox.Name = "_logBox";
  246. this._logBox.ReadOnly = true;
  247. this._logBox.Size = new System.Drawing.Size(224, 19);
  248. this._logBox.TabIndex = 12;
  249. this._logBox.Text = "";
  250. // 
  251. // ServerInfo
  252. // 
  253. this.AcceptButton = this._okButton;
  254. this.CancelButton = this._okButton;
  255. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  256. this.ClientSize = new System.Drawing.Size(314, 287);
  257. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  258.   this._logLabel,
  259.   this._logBox,
  260.   this._receiveBytes,
  261.   this._transmitBytes,
  262.   this._statsLabel,
  263.   this._parameterBox,
  264.   this._parameterLabel,
  265.   this._protocolLabel,
  266.   this._protocolBox,
  267.   this._terminalTypeLabel,
  268.   this._terminalTypeBox,
  269.   this._IPAddressBox,
  270.   this._IPAddressLabel,
  271.   this._serverNamesBox,
  272.   this._serverNamesLabel,
  273.   this._okButton});
  274. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  275. this.MaximizeBox = false;
  276. this.MinimizeBox = false;
  277. this.Name = "ServerInfo";
  278. this.ShowInTaskbar = false;
  279. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  280. this.ResumeLayout(false);
  281. }
  282. #endregion
  283. private static string FormatStrings(string[] v) {
  284. StringBuilder b = new StringBuilder();
  285. if(v!=null) {
  286. foreach(string t in v) {
  287. if(b.Length>0) b.Append(", ");
  288. b.Append(t);
  289. }
  290. }
  291. else
  292. b.Append("-");
  293. return b.ToString();
  294. }
  295. private static string FormatIPs(IPAddress[] v) {
  296. StringBuilder b = new StringBuilder();
  297. if(v!=null) {
  298. foreach(IPAddress t in v) {
  299. if(b.Length>0) b.Append(", ");
  300. b.Append(t.ToString());
  301. }
  302. }
  303. else
  304. b.Append("-");
  305. return b.ToString();
  306. }
  307. }
  308. }