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

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: GDialogBar.cs,v 1.2 2005/04/20 08:45:45 okajima Exp $
  4. */
  5. using System;
  6. using System.Text;
  7. using System.Diagnostics;
  8. using System.Collections;
  9. using System.ComponentModel;
  10. using System.Drawing;
  11. using System.Windows.Forms;
  12. using EnumDescAttributeT = Poderosa.Toolkit.EnumDescAttribute;
  13. using Poderosa.UI;
  14. using Poderosa.Toolkit;
  15. using Poderosa.Terminal;
  16. using Poderosa.Communication;
  17. using Poderosa.ConnectionParam;
  18. using Poderosa.Config;
  19. namespace Poderosa.Forms
  20. {
  21. /// <summary>
  22. /// GDialogBar 偺奣梫偺愢柧偱偡丅
  23. /// 
  24. /// 僣乕儖僶乕偼丄昗弨揑側傾僀僐儞偼24px僺僢僠丄傾僀僐儞帺懱偼16px丅廲朹偺僄儕傾偼8px
  25. /// </summary>
  26. internal class GDialogBar : System.Windows.Forms.UserControl
  27. {
  28. private GButton _newConnection;
  29. private GButton _newSerialConnection;
  30. private GButton _newCygwinConnection;
  31. private GButton _newSFUConnection;
  32. private GButton _openShortcut;
  33. private GButton _saveShortcut;
  34. private ToggleButton _singleStyle;
  35. private ToggleButton _divHorizontalStyle;
  36. private ToggleButton _divVerticalStyle;
  37. private ToggleButton _divHorizontal3Style;
  38. private ToggleButton _divVertical3Style;
  39. private System.Windows.Forms.Label _newLineLabel;
  40. private ComboBox _newLineOption;
  41. private ToggleButton _localEcho;
  42. private GButton _lineFeedRule;
  43. private ToggleButton _logSuspend;
  44. private GButton _commentLog;
  45. private GButton _serverInfo;
  46. private System.Windows.Forms.Label _encodingLabel;
  47. private ComboBox _encodingBox;
  48. private System.ComponentModel.IContainer components = null;
  49. private bool _toolTipInitialized;
  50. private ToolTip _toolTip;
  51. private bool _blockEventHandler;
  52. public GDialogBar()
  53. {
  54. // 偙偺屇傃弌偟偼丄Windows.Forms 僼僅乕儉 僨僓僀僫偱昁梫偱偡丅
  55. InitializeComponent();
  56. _newLineOption.BringToFront(); //擔杮岅丒塸岅偱庒姳攝抲傪曄偊傞搒崌偱丄偙傟傪僩僢僾偵傕偭偰偔傞
  57. ReloadLanguage(GEnv.Options.Language);
  58. _toolTipInitialized = false;
  59. // TODO: InitForm 傪屇傃弌偟偺屻偵弶婜壔張棟傪捛壛偟傑偡丅
  60. LoadImages();
  61. }
  62. public void ReloadLanguage(Language l) {
  63. this._encodingLabel.Text = GApp.Strings.GetString("Form.GDialogBar._encodingLabel");
  64. this._newLineLabel.Text = GApp.Strings.GetString("Form.GDialogBar._newLineLabel");
  65. this._newLineOption.Left = l==Language.Japanese? 340 : 356; //攝抲偺搒崌
  66. InitToolTip();
  67. }
  68. /// <summary>
  69. /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
  70. /// </summary>
  71. protected override void Dispose( bool disposing )
  72. {
  73. if( disposing )
  74. {
  75. if(components != null)
  76. {
  77. components.Dispose();
  78. }
  79. }
  80. base.Dispose( disposing );
  81. }
  82. #region Component Designer generated code
  83. /// <summary>
  84. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  85. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  86. /// this._newLineOption.Items.AddRange(EnumDescAttributeT.For(typeof(NewLine)).DescriptionCollection());
  87. /// 
  88. /// this._encodingBox.Items.AddRange(EnumDescAttributeT.For(typeof(EncodingType)).DescriptionCollection());
  89. /// </summary>
  90. private void InitializeComponent()
  91. {
  92. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(GDialogBar));
  93. this._openShortcut = new GButton();
  94. this._newConnection = new GButton();
  95. this._newSerialConnection = new GButton();
  96. this._newCygwinConnection = new GButton();
  97. this._newSFUConnection = new GButton();
  98. this._saveShortcut = new GButton();
  99. this._singleStyle = new ToggleButton();
  100. this._divHorizontalStyle = new ToggleButton();
  101. this._divVerticalStyle = new ToggleButton();
  102. this._divHorizontal3Style = new ToggleButton();
  103. this._divVertical3Style = new ToggleButton();
  104. this._newLineLabel = new System.Windows.Forms.Label();
  105. this._newLineOption = new ComboBox();
  106. this._logSuspend = new ToggleButton();
  107. this._lineFeedRule = new GButton();
  108. this._localEcho = new ToggleButton();
  109. this._serverInfo = new GButton();
  110. this._commentLog = new GButton();
  111. this._encodingLabel = new System.Windows.Forms.Label();
  112. this._encodingBox = new ComboBox();
  113. this.SuspendLayout();
  114. // 
  115. // _newConnection
  116. // 
  117. this._newConnection.BorderStyle = System.Windows.Forms.BorderStyle.None;
  118. this._newConnection.ForeColor = System.Drawing.SystemColors.ControlText;
  119. this._newConnection.Location = new System.Drawing.Point(8, 2);
  120. this._newConnection.Name = "_newConnection";
  121. this._newConnection.Size = new System.Drawing.Size(24, 23);
  122. this._newConnection.TabIndex = 0;
  123. this._newConnection.TabStop = false;
  124. this._newConnection.Click += new System.EventHandler(this.OpenNewConnection);
  125. this._newConnection.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  126. this._newConnection.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  127. this._newConnection.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  128. // 
  129. // _newSerialConnection
  130. // 
  131. this._newSerialConnection.BorderStyle = System.Windows.Forms.BorderStyle.None;
  132. this._newSerialConnection.ForeColor = System.Drawing.SystemColors.ControlText;
  133. this._newSerialConnection.Location = new System.Drawing.Point(32, 2);
  134. this._newSerialConnection.Name = "_newSerialConnection";
  135. this._newSerialConnection.Size = new System.Drawing.Size(24, 23);
  136. this._newSerialConnection.TabIndex = 0;
  137. this._newSerialConnection.TabStop = false;
  138. this._newSerialConnection.Click += new System.EventHandler(this.OpenNewSerialConnection);
  139. this._newSerialConnection.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  140. this._newSerialConnection.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  141. this._newSerialConnection.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  142. // 
  143. // _newCygwinConnection
  144. // 
  145. this._newCygwinConnection.BorderStyle = System.Windows.Forms.BorderStyle.None;
  146. this._newCygwinConnection.ForeColor = System.Drawing.SystemColors.ControlText;
  147. this._newCygwinConnection.Location = new System.Drawing.Point(56, 2);
  148. this._newCygwinConnection.Name = "_newCygwinConnection";
  149. this._newCygwinConnection.Size = new System.Drawing.Size(24, 23);
  150. this._newCygwinConnection.TabIndex = 0;
  151. this._newCygwinConnection.TabStop = false;
  152. this._newCygwinConnection.Click += new System.EventHandler(this.OpenNewCygwinConnection);
  153. this._newCygwinConnection.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  154. this._newCygwinConnection.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  155. this._newCygwinConnection.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  156. // 
  157. // _newSFUConnection
  158. // 
  159. this._newSFUConnection.BorderStyle = System.Windows.Forms.BorderStyle.None;
  160. this._newSFUConnection.ForeColor = System.Drawing.SystemColors.ControlText;
  161. this._newSFUConnection.Location = new System.Drawing.Point(80, 2);
  162. this._newSFUConnection.Name = "_newSFUConnection";
  163. this._newSFUConnection.Size = new System.Drawing.Size(24, 23);
  164. this._newSFUConnection.TabIndex = 0;
  165. this._newSFUConnection.TabStop = false;
  166. this._newSFUConnection.Click += new System.EventHandler(this.OpenNewSFUConnection);
  167. this._newSFUConnection.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  168. this._newSFUConnection.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  169. this._newSFUConnection.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  170. // 
  171. // _openShortcut
  172. // 
  173. this._openShortcut.BorderStyle = System.Windows.Forms.BorderStyle.None;
  174. this._openShortcut.ForeColor = System.Drawing.SystemColors.ControlText;
  175. this._openShortcut.Location = new System.Drawing.Point(112, 2);
  176. this._openShortcut.Name = "_openShortcut";
  177. this._openShortcut.Size = new System.Drawing.Size(24, 23);
  178. this._openShortcut.TabIndex = 0;
  179. this._openShortcut.TabStop = false;
  180. this._openShortcut.Click += new System.EventHandler(this.OpenShortCut);
  181. this._openShortcut.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  182. this._openShortcut.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  183. this._openShortcut.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  184. // 
  185. // _saveShortcut
  186. // 
  187. this._saveShortcut.BorderStyle = System.Windows.Forms.BorderStyle.None;
  188. this._saveShortcut.Enabled = false;
  189. this._saveShortcut.Location = new System.Drawing.Point(136, 2);
  190. this._saveShortcut.Name = "_saveShortcut";
  191. this._saveShortcut.Size = new System.Drawing.Size(24, 23);
  192. this._saveShortcut.TabIndex = 0;
  193. this._saveShortcut.TabStop = false;
  194. this._saveShortcut.Click += new System.EventHandler(this.SaveShortCut);
  195. this._saveShortcut.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  196. this._saveShortcut.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  197. this._saveShortcut.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  198. // 
  199. // _singleStyle
  200. // 
  201. this._singleStyle.BorderStyle = System.Windows.Forms.BorderStyle.None;
  202. this._singleStyle.Checked = false;
  203. this._singleStyle.TabStop = false;
  204. this._singleStyle.AutoToggle = false;
  205. this._singleStyle.Location = new System.Drawing.Point(168, 2);
  206. this._singleStyle.Name = "_singleStyle";
  207. this._singleStyle.Size = new System.Drawing.Size(24, 23);
  208. this._singleStyle.TabIndex = 1;
  209. this._singleStyle.Click += new System.EventHandler(this.ToggleSingleStyle);
  210. this._singleStyle.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  211. this._singleStyle.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  212. this._singleStyle.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  213. // 
  214. // _divHorizontalStyle
  215. // 
  216. this._divHorizontalStyle.BorderStyle = System.Windows.Forms.BorderStyle.None;
  217. this._divHorizontalStyle.Checked = false;
  218. this._divHorizontalStyle.AutoToggle = false;
  219. this._divHorizontalStyle.Location = new System.Drawing.Point(192, 2);
  220. this._divHorizontalStyle.Name = "_divHorizontalStyle";
  221. this._divHorizontalStyle.Size = new System.Drawing.Size(24, 23);
  222. this._divHorizontalStyle.TabStop = false;
  223. this._divHorizontalStyle.TabIndex = 2;
  224. this._divHorizontalStyle.Click += new System.EventHandler(this.ToggleDivHorizontalStyle);
  225. this._divHorizontalStyle.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  226. this._divHorizontalStyle.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  227. this._divHorizontalStyle.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  228. // 
  229. // _divVerticalStyle
  230. // 
  231. this._divVerticalStyle.BorderStyle = System.Windows.Forms.BorderStyle.None;
  232. this._divVerticalStyle.Checked = false;
  233. this._divVerticalStyle.AutoToggle = false;
  234. this._divVerticalStyle.Location = new System.Drawing.Point(216, 2);
  235. this._divVerticalStyle.Name = "_divVerticalStyle";
  236. this._divVerticalStyle.Size = new System.Drawing.Size(24, 23);
  237. this._divVerticalStyle.TabStop = false;
  238. this._divVerticalStyle.Click += new System.EventHandler(this.ToggleDivVerticalStyle);
  239. this._divVerticalStyle.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  240. this._divVerticalStyle.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  241. this._divVerticalStyle.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  242. // 
  243. // _divHorizontal3Style
  244. // 
  245. this._divHorizontal3Style.BorderStyle = System.Windows.Forms.BorderStyle.None;
  246. this._divHorizontal3Style.Checked = false;
  247. this._divHorizontal3Style.AutoToggle = false;
  248. this._divHorizontal3Style.Location = new System.Drawing.Point(240, 2);
  249. this._divHorizontal3Style.Name = "_divHorizontal3Style";
  250. this._divHorizontal3Style.Size = new System.Drawing.Size(24, 23);
  251. this._divHorizontal3Style.TabStop = false;
  252. this._divHorizontal3Style.Click += new System.EventHandler(this.ToggleDivHorizontal3Style);
  253. this._divHorizontal3Style.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  254. this._divHorizontal3Style.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  255. this._divHorizontal3Style.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  256. // 
  257. // _divVertical3Style
  258. // 
  259. this._divVertical3Style.BorderStyle = System.Windows.Forms.BorderStyle.None;
  260. this._divVertical3Style.Checked = false;
  261. this._divVertical3Style.AutoToggle = false;
  262. this._divVertical3Style.Location = new System.Drawing.Point(264, 2);
  263. this._divVertical3Style.Name = "_divVertical3Style";
  264. this._divVertical3Style.Size = new System.Drawing.Size(24, 23);
  265. this._divVertical3Style.TabStop = false;
  266. this._divVertical3Style.Click += new System.EventHandler(this.ToggleDivVertical3Style);
  267. this._divVertical3Style.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  268. this._divVertical3Style.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  269. this._divVertical3Style.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  270. // 
  271. // _newLineLabel
  272. // 
  273. this._newLineLabel.Location = new System.Drawing.Point(296, 7);
  274. this._newLineLabel.Name = "_newLineLabel";
  275. this._newLineLabel.Size = new System.Drawing.Size(60, 15);
  276. this._newLineLabel.TabIndex = 0;
  277. this._newLineLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  278. // 
  279. // _newLineOption
  280. // 
  281. this._newLineOption.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  282. this._newLineOption.Enabled = false;
  283. this._newLineOption.Items.AddRange(EnumDescAttributeT.For(typeof(NewLine)).DescriptionCollection());
  284. this._newLineOption.Location = new System.Drawing.Point(340, 4);
  285. this._newLineOption.Name = "_newLineOption";
  286. this._newLineOption.Size = new System.Drawing.Size(72, 20);
  287. this._newLineOption.TabIndex = 0;
  288. this._newLineOption.TabStop = false;
  289. this._newLineOption.SelectedIndexChanged += new System.EventHandler(this.ChangeNewLine);
  290. // 
  291. // _encodingLabel
  292. // 
  293. this._encodingLabel.Location = new System.Drawing.Point(416, 7);
  294. this._encodingLabel.Name = "_encodingLabel";
  295. this._encodingLabel.Size = new System.Drawing.Size(80, 15);
  296. this._encodingLabel.TabIndex = 0;
  297. this._encodingLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  298. // 
  299. // _encodingBox
  300. // 
  301. this._encodingBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  302. this._encodingBox.Enabled = false;
  303. this._encodingBox.Location = new System.Drawing.Point(496, 4);
  304. this._encodingBox.Name = "_encodingBox";
  305. this._encodingBox.Size = new System.Drawing.Size(96, 20);
  306. this._encodingBox.TabIndex = 0;
  307. this._encodingBox.TabStop = false;
  308. this._encodingBox.SelectedIndexChanged += new System.EventHandler(this.ChangeEncoding);
  309. this._encodingBox.Items.AddRange(EnumDescAttributeT.For(typeof(EncodingType)).DescriptionCollection());
  310. // 
  311. // _localEcho
  312. // 
  313. this._localEcho.BorderStyle = System.Windows.Forms.BorderStyle.None;
  314. this._localEcho.Checked = false;
  315. this._localEcho.Enabled = false;
  316. this._localEcho.Location = new System.Drawing.Point(600, 2);
  317. this._localEcho.Name = "_localEcho";
  318. this._localEcho.Size = new System.Drawing.Size(24, 23);
  319. this._localEcho.TabIndex = 0;
  320. this._localEcho.TabStop = false;
  321. this._localEcho.Click += new System.EventHandler(this.ToggleLocalEcho);
  322. this._localEcho.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  323. this._localEcho.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  324. this._localEcho.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  325. // 
  326. // _lineFeedRule
  327. // 
  328. this._lineFeedRule.BorderStyle = System.Windows.Forms.BorderStyle.None;
  329. this._lineFeedRule.Enabled = false;
  330. this._lineFeedRule.Location = new System.Drawing.Point(624, 2);
  331. this._lineFeedRule.Name = "_lineFeedRule";
  332. this._lineFeedRule.Size = new System.Drawing.Size(24, 23);
  333. this._lineFeedRule.TabIndex = 0;
  334. this._lineFeedRule.TabStop = false;
  335. this._lineFeedRule.Click += new System.EventHandler(this.LineFeedRule);
  336. this._lineFeedRule.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  337. this._lineFeedRule.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  338. this._lineFeedRule.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  339. // 
  340. // _logSuspend
  341. // 
  342. this._logSuspend.BorderStyle = System.Windows.Forms.BorderStyle.None;
  343. this._logSuspend.Checked = false;
  344. this._logSuspend.Enabled = false;
  345. this._logSuspend.Location = new System.Drawing.Point(650, 2);
  346. this._logSuspend.Name = "_logSuspend";
  347. this._logSuspend.Size = new System.Drawing.Size(24, 23);
  348. this._logSuspend.TabIndex = 0;
  349. this._logSuspend.TabStop = false;
  350. this._logSuspend.Click += new System.EventHandler(this.ToggleLogSwitch);
  351. this._logSuspend.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  352. this._logSuspend.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  353. this._logSuspend.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  354. // 
  355. // _commentLog
  356. // 
  357. this._commentLog.BorderStyle = System.Windows.Forms.BorderStyle.None;
  358. this._commentLog.Enabled = false;
  359. this._commentLog.Location = new System.Drawing.Point(672, 2);
  360. this._commentLog.Name = "_commentLog";
  361. this._commentLog.Size = new System.Drawing.Size(24, 23);
  362. this._commentLog.TabIndex = 0;
  363. this._commentLog.TabStop = false;
  364. this._commentLog.Click += new System.EventHandler(this.CommentLog);
  365. this._commentLog.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  366. this._commentLog.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  367. this._commentLog.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  368. // 
  369. // _serverInfo
  370. // 
  371. this._serverInfo.BorderStyle = System.Windows.Forms.BorderStyle.None;
  372. this._serverInfo.Enabled = false;
  373. this._serverInfo.Location = new System.Drawing.Point(704, 2);
  374. this._serverInfo.Name = "_serverInfo";
  375. this._serverInfo.Size = new System.Drawing.Size(24, 23);
  376. this._serverInfo.TabIndex = 0;
  377. this._serverInfo.TabStop = false;
  378. this._serverInfo.Click += new System.EventHandler(this.ShowServerInfo);
  379. this._serverInfo.MouseEnter += new System.EventHandler(this.OnMouseEnterToButton);
  380. this._serverInfo.MouseHover += new System.EventHandler(this.OnMouseHoverOnButton);
  381. this._serverInfo.MouseLeave += new System.EventHandler(this.OnMouseLeaveFromButton);
  382. // 
  383. // GDialogBar
  384. // 
  385. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  386.   this._newConnection,
  387.   this._newSerialConnection,
  388.   this._newCygwinConnection,
  389.   this._newSFUConnection,
  390.   this._openShortcut,
  391.   this._saveShortcut,
  392.   this._singleStyle,
  393.   this._divHorizontalStyle,
  394.   this._divVerticalStyle,
  395.   this._divHorizontal3Style,
  396.   this._divVertical3Style,
  397.   this._newLineLabel,
  398.   this._newLineOption,
  399.   this._encodingLabel,
  400.   this._encodingBox,
  401.   this._lineFeedRule,
  402.   this._commentLog,
  403.   this._logSuspend,
  404.   this._localEcho,
  405.   this._serverInfo});
  406. this.Name = "GDialogBar";
  407. this.Size = new System.Drawing.Size(664, 24);
  408. this.TabStop = false;
  409. this.ResumeLayout(false);
  410. }
  411. #endregion
  412. private void LoadImages() {
  413. this._openShortcut.Image = IconList.LoadIcon(IconList.ICON_OPEN);
  414. this._newConnection.Image = IconList.LoadIcon(IconList.ICON_NEWCONNECTION);
  415. this._newSerialConnection.Image = IconList.LoadIcon(IconList.ICON_SERIAL);
  416. this._newCygwinConnection.Image = IconList.LoadIcon(IconList.ICON_CYGWIN);
  417. this._newSFUConnection.Image = IconList.LoadIcon(IconList.ICON_SFU);
  418. this._saveShortcut.Image = IconList.LoadIcon(IconList.ICON_SAVE);
  419. this._singleStyle.Image = IconList.LoadIcon(IconList.ICON_SINGLE);
  420. this._divHorizontalStyle.Image = IconList.LoadIcon(IconList.ICON_DIVHORIZONTAL);
  421. this._divVerticalStyle.Image = IconList.LoadIcon(IconList.ICON_DIVVERTICAL);
  422. this._divHorizontal3Style.Image = IconList.LoadIcon(IconList.ICON_DIVHORIZONTAL3);
  423. this._divVertical3Style.Image = IconList.LoadIcon(IconList.ICON_DIVVERTICAL3);
  424. this._localEcho.Image = IconList.LoadIcon(IconList.ICON_LOCALECHO);
  425. this._lineFeedRule.Image = IconList.LoadIcon(IconList.ICON_LINEFEED);
  426. this._logSuspend.Image = IconList.LoadIcon(IconList.ICON_SUSPENDLOG);
  427. this._commentLog.Image = IconList.LoadIcon(IconList.ICON_COMMENTLOG);
  428. this._serverInfo.Image = IconList.LoadIcon(IconList.ICON_INFO);
  429. }
  430. public ToggleButton SuspendLogButton {
  431. get {
  432. return _logSuspend;
  433. }
  434. }
  435. public ToggleButton LocalEchoButton {
  436. get {
  437. return _localEcho;
  438. }
  439. }
  440. public GButton LineFeedRuleButton {
  441. get {
  442. return _lineFeedRule;
  443. }
  444. }
  445. public ComboBox NewLineBox {
  446. get {
  447. return _newLineOption;
  448. }
  449. }
  450. protected override void OnGotFocus(EventArgs args) {
  451. base.OnGotFocus(args);
  452. //GApp.GlobalCommandTarget.SetFocusToActiveConnection();
  453. //Debug.WriteLine("DialogBar gotfocus");
  454. }
  455. protected override void OnPaint(PaintEventArgs arg) {
  456. base.OnPaint(arg);
  457. //忋偵嬫愗傝慄傪堷偔
  458. Graphics g = arg.Graphics;
  459. Pen p = new Pen(Color.FromKnownColor(KnownColor.WindowFrame));
  460. g.DrawLine(p, 0, 0, Width, 0);
  461. p = new Pen(Color.FromKnownColor(KnownColor.Window));
  462. g.DrawLine(p, 0, 1, Width, 1);
  463. //僣乕儖僶乕偺嬫愗傝栚
  464. const int margin = 3;
  465. p = new Pen(Color.FromKnownColor(KnownColor.ControlDark));
  466. g.DrawLine(p, 108, margin, 108, this.Height-margin);
  467. g.DrawLine(p, 162, margin, 162, this.Height-margin);
  468. g.DrawLine(p, 292, margin, 292, this.Height-margin);
  469. g.DrawLine(p, 696, margin, 696, this.Height-margin);
  470. }
  471. private void OpenNewConnection(object sender, System.EventArgs e) {
  472. GApp.GlobalCommandTarget.NewConnectionWithDialog(null);
  473. }
  474. private void OpenNewSerialConnection(object sender, System.EventArgs e) {
  475. GApp.GlobalCommandTarget.NewSerialConnectionWithDialog(null);
  476. }
  477. private void OpenNewCygwinConnection(object sender, System.EventArgs e) {
  478. GApp.GlobalCommandTarget.NewCygwinConnectionWithDialog(null);
  479. }
  480. private void OpenNewSFUConnection(object sender, System.EventArgs e) {
  481. GApp.GlobalCommandTarget.NewSFUConnectionWithDialog(null);
  482. }
  483. private void OpenShortCut(object sender, System.EventArgs e) {
  484. GApp.GlobalCommandTarget.OpenShortCutWithDialog();
  485. }
  486. private void SaveShortCut(object sender, System.EventArgs e) {
  487. ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();
  488. t.SaveShortCut();
  489. t.Focus();
  490. }
  491. private void ChangeNewLine(object sender, System.EventArgs e) {
  492. if(_blockEventHandler) return;
  493. NewLine nl = (NewLine)_newLineOption.SelectedIndex;
  494. ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();
  495. t.SetTransmitNewLine(nl);
  496. t.Focus();
  497. }
  498. private void ChangeEncoding(object sender, System.EventArgs e) {
  499. if(_blockEventHandler) return;
  500. EncodingProfile enc = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex);
  501. ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();
  502. t.SetEncoding(enc);
  503. t.Focus();
  504. }
  505. private void ToggleLocalEcho(object sender, System.EventArgs e) {
  506. if(_blockEventHandler) return;
  507. ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();
  508. t.SetLocalEcho(!t.Connection.Param.LocalEcho);
  509. t.Focus();
  510. }
  511. private void LineFeedRule(object sender, System.EventArgs e) {
  512. if(_blockEventHandler) return;
  513. ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();
  514. t.ShowLineFeedRuleDialog();
  515. t.Focus();
  516. }
  517. private void ToggleLogSwitch(object sender, System.EventArgs e) {
  518. if(_blockEventHandler) return;
  519. ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();
  520. t.SetLogSuspended(!t.Connection.LogSuspended);
  521. t.Focus();
  522. }
  523. private void ToggleSingleStyle(object sender, System.EventArgs e) {
  524. if(_blockEventHandler) return;
  525. if(GApp.GlobalCommandTarget.SetFrameStyle(GFrameStyle.Single)==CommandResult.Ignored)
  526. _singleStyle.Checked = true;
  527. }
  528. private void ToggleDivHorizontalStyle(object sender, System.EventArgs e) {
  529. if(_blockEventHandler) return;
  530. if(GApp.GlobalCommandTarget.SetFrameStyle(GFrameStyle.DivHorizontal)==CommandResult.Ignored)
  531. _divHorizontalStyle.Checked = true;
  532. }
  533. private void ToggleDivVerticalStyle(object sender, System.EventArgs e) {
  534. if(_blockEventHandler) return;
  535. if(GApp.GlobalCommandTarget.SetFrameStyle(GFrameStyle.DivVertical)==CommandResult.Ignored)
  536. _divVerticalStyle.Checked = true;
  537. }
  538. private void ToggleDivHorizontal3Style(object sender, System.EventArgs e) {
  539. if(_blockEventHandler) return;
  540. if(GApp.GlobalCommandTarget.SetFrameStyle(GFrameStyle.DivHorizontal3)==CommandResult.Ignored)
  541. _divHorizontal3Style.Checked = true;
  542. }
  543. private void ToggleDivVertical3Style(object sender, System.EventArgs e) {
  544. if(_blockEventHandler) return;
  545. if(GApp.GlobalCommandTarget.SetFrameStyle(GFrameStyle.DivVertical3)==CommandResult.Ignored)
  546. _divVertical3Style.Checked = true;
  547. }
  548. public void EnableTerminalUI(bool enabled, TerminalConnection con) {
  549. _blockEventHandler = true;
  550. _saveShortcut.Enabled = enabled;
  551. _newLineOption.Enabled = enabled && !con.IsClosed;
  552. _logSuspend.Enabled = enabled && !con.IsClosed && con.TextLogger.IsActive;
  553. _localEcho.Enabled = enabled && !con.IsClosed;
  554. _lineFeedRule.Enabled = enabled && !con.IsClosed;
  555. _encodingBox.Enabled = enabled && !con.IsClosed;
  556. _serverInfo.Enabled = enabled;
  557. _commentLog.Enabled = enabled && !con.IsClosed && con.TextLogger.IsActive;
  558. if(enabled) {
  559. _newLineOption.SelectedIndex = (int)con.Param.TransmitNL;
  560. _encodingBox.SelectedIndex = (int)con.Param.EncodingProfile.Type;
  561. _logSuspend.Checked = con.LogSuspended;
  562. _localEcho.Checked = con.Param.LocalEcho;
  563. }
  564. _blockEventHandler = false;
  565. Invalidate(true);
  566. }
  567. public void ApplyOptions(ContainerOptions opt) {
  568. GFrameStyle f = opt.FrameStyle;
  569. _singleStyle.Checked         = f==GFrameStyle.Single;
  570. _divHorizontalStyle.Checked  = f==GFrameStyle.DivHorizontal;
  571. _divVerticalStyle.Checked    = f==GFrameStyle.DivVertical;
  572. _divHorizontal3Style.Checked = f==GFrameStyle.DivHorizontal3;
  573. _divVertical3Style.Checked   = f==GFrameStyle.DivVertical3;
  574. Invalidate(true);
  575. }
  576. private void OnMouseEnterToButton(object sender, EventArgs args) {
  577. if(!_toolTipInitialized) InitToolTip();
  578. GStatusBar sb = GApp.Frame.StatusBar;
  579. if(sender==_openShortcut)
  580. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._openShortcut"));
  581. else if(sender==_newConnection)
  582. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._newConnection"));
  583. else if(sender==_newSerialConnection)
  584. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._newSerialConnection"));
  585. else if(sender==_newCygwinConnection)
  586. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._newCygwinConnection"));
  587. else if(sender==_newSFUConnection)
  588. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._newSFUConnection"));
  589. else if(sender==_saveShortcut)
  590. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._saveShortcut"));
  591. else if(sender==_singleStyle)
  592. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._singleStyle"));
  593. else if(sender==_divHorizontalStyle)
  594. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._divHorizontalStyle"));
  595. else if(sender==_divVerticalStyle)
  596. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._divVerticalStyle"));
  597. else if(sender==_divHorizontal3Style)
  598. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._divHorizontal3Style"));
  599. else if(sender==_divVertical3Style)
  600. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._divVertical3Style"));
  601. else if(sender==_newLineOption)
  602. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._newLineOption"));
  603. else if(sender==_lineFeedRule)
  604. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._lineFeedRule"));
  605. else if(sender==_encodingBox)
  606. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._encodingBox"));
  607. else if(sender==_logSuspend)
  608. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._logSuspend"));
  609. else if(sender==_commentLog)
  610. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._commentLog"));
  611. else if(sender==_localEcho)
  612. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._localEcho"));
  613. else if(sender==_serverInfo)
  614. sb.SetStatusBarText(GApp.Strings.GetString("Caption.ToolBar._serverInfo"));
  615. else
  616. Debug.WriteLine("Unexpected toolbar object");
  617. }
  618. private void InitToolTip() {
  619. if(_toolTip!=null) _toolTip.RemoveAll();
  620. ToolTip tt = new ToolTip();
  621. tt.SetToolTip(_openShortcut, GApp.Strings.GetString("ToolTip.ToolBar._openShortcut"));
  622. tt.SetToolTip(_saveShortcut, GApp.Strings.GetString("ToolTip.ToolBar._saveShortcut"));
  623. tt.SetToolTip(_singleStyle, GApp.Strings.GetString("ToolTip.ToolBar._singleStyle"));
  624. tt.SetToolTip(_divHorizontalStyle, GApp.Strings.GetString("ToolTip.ToolBar._divHorizontalStyle"));
  625. tt.SetToolTip(_divVerticalStyle, GApp.Strings.GetString("ToolTip.ToolBar._divVerticalStyle"));
  626. tt.SetToolTip(_divHorizontal3Style, GApp.Strings.GetString("ToolTip.ToolBar._divHorizontal3Style"));
  627. tt.SetToolTip(_divVertical3Style, GApp.Strings.GetString("ToolTip.ToolBar._divVertical3Style"));
  628. tt.SetToolTip(_newConnection, GApp.Strings.GetString("ToolTip.ToolBar._newConnection"));
  629. tt.SetToolTip(_newSerialConnection, GApp.Strings.GetString("ToolTip.ToolBar._newSerialConnection"));
  630. tt.SetToolTip(_newCygwinConnection, GApp.Strings.GetString("ToolTip.ToolBar._newCygwinConnection"));
  631. tt.SetToolTip(_newSFUConnection, GApp.Strings.GetString("ToolTip.ToolBar._newSFUConnection"));
  632. tt.SetToolTip(_newLineLabel, GApp.Strings.GetString("ToolTip.ToolBar._newLineLabel"));
  633. tt.SetToolTip(_newLineOption, GApp.Strings.GetString("ToolTip.ToolBar._newLineLabel"));
  634. tt.SetToolTip(_encodingLabel, GApp.Strings.GetString("ToolTip.ToolBar._encodingLabel"));
  635. tt.SetToolTip(_encodingBox, GApp.Strings.GetString("ToolTip.ToolBar._encodingBox"));
  636. tt.SetToolTip(_localEcho, GApp.Strings.GetString("ToolTip.ToolBar._localEcho"));
  637. tt.SetToolTip(_lineFeedRule, GApp.Strings.GetString("ToolTip.ToolBar._lineFeedRule"));
  638. tt.SetToolTip(_logSuspend, GApp.Strings.GetString("ToolTip.ToolBar._logSuspend"));
  639. tt.SetToolTip(_commentLog, GApp.Strings.GetString("ToolTip.ToolBar._commentLog"));
  640. tt.SetToolTip(_serverInfo, GApp.Strings.GetString("ToolTip.ToolBar._serverInfo"));
  641. _toolTip = tt;
  642. _toolTipInitialized = true;
  643. }
  644. private void OnMouseLeaveFromButton(object sender, EventArgs args) {
  645. GApp.Frame.StatusBar.ClearStatusBarText();
  646. }
  647. private void OnMouseHoverOnButton(object sender, EventArgs args) {
  648. }
  649. private void CommentLog(object sender, EventArgs e) {
  650. GApp.GetConnectionCommandTarget().CommentLog();
  651. }
  652. private void ShowServerInfo(object sender, EventArgs e) {
  653. GApp.GetConnectionCommandTarget().ShowServerInfo();
  654. }
  655. }
  656. }