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

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: LogNoteForm.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 Poderosa.UI;
  11. namespace Poderosa.Forms
  12. {
  13. /// <summary>
  14. /// LogNoteForm 偺奣梫偺愢柧偱偡丅
  15. /// </summary>
  16. internal class LogNoteForm : System.Windows.Forms.Form
  17. {
  18. private System.Windows.Forms.TextBox _textBox;
  19. private System.Windows.Forms.Button _okButton;
  20. private System.Windows.Forms.Button _cancelButton;
  21. private System.Windows.Forms.Button _insertButton;
  22. /// <summary>
  23. /// 昁梫側僨僓僀僫曄悢偱偡丅
  24. /// </summary>
  25. private System.ComponentModel.Container components = null;
  26. public LogNoteForm()
  27. {
  28. //
  29. // Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
  30. //
  31. InitializeComponent();
  32. //
  33. // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
  34. //
  35. this._okButton.Text = GApp.Strings.GetString("Common.OK");
  36. this._cancelButton.Text = GApp.Strings.GetString("Common.Cancel");
  37. this._insertButton.Text = GApp.Strings.GetString("Form.LogNoteForm._insertButton");
  38. this.Text = GApp.Strings.GetString("Form.LogNoteForm.Text");
  39. }
  40. /// <summary>
  41. /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
  42. /// </summary>
  43. protected override void Dispose( bool disposing )
  44. {
  45. if( disposing )
  46. {
  47. if(components != null)
  48. {
  49. components.Dispose();
  50. }
  51. }
  52. base.Dispose( disposing );
  53. }
  54. #region Windows Form Designer generated code
  55. /// <summary>
  56. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  57. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  58. /// </summary>
  59. private void InitializeComponent()
  60. {
  61. this._textBox = new System.Windows.Forms.TextBox();
  62. this._okButton = new System.Windows.Forms.Button();
  63. this._cancelButton = new System.Windows.Forms.Button();
  64. this._insertButton = new System.Windows.Forms.Button();
  65. this.SuspendLayout();
  66. // 
  67. // _textBox
  68. // 
  69. this._textBox.Location = new System.Drawing.Point(8, 8);
  70. this._textBox.Name = "_textBox";
  71. this._textBox.Size = new System.Drawing.Size(336, 19);
  72. this._textBox.TabIndex = 0;
  73. this._textBox.Text = "";
  74. // 
  75. // _okButton
  76. // 
  77. this._okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  78. this._okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  79. this._okButton.Location = new System.Drawing.Point(208, 32);
  80. this._okButton.Name = "_okButton";
  81. this._okButton.Size = new System.Drawing.Size(64, 24);
  82. this._okButton.TabIndex = 1;
  83. // 
  84. // _cancelButton
  85. // 
  86. this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  87. this._cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  88. this._cancelButton.Location = new System.Drawing.Point(280, 32);
  89. this._cancelButton.Name = "_cancelButton";
  90. this._cancelButton.Size = new System.Drawing.Size(64, 23);
  91. this._cancelButton.TabIndex = 2;
  92. // 
  93. // _insertButton
  94. // 
  95. this._insertButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  96. this._insertButton.Location = new System.Drawing.Point(8, 32);
  97. this._insertButton.Name = "_insertButton";
  98. this._insertButton.Size = new System.Drawing.Size(72, 23);
  99. this._insertButton.TabIndex = 3;
  100. this._insertButton.Click += new EventHandler(OnClickInsertButton);
  101. // 
  102. // LogNoteForm
  103. // 
  104. this.AcceptButton = this._okButton;
  105. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  106. this.CancelButton = this._cancelButton;
  107. this.ClientSize = new System.Drawing.Size(346, 61);
  108. this.Controls.Add(this._insertButton);
  109. this.Controls.Add(this._cancelButton);
  110. this.Controls.Add(this._okButton);
  111. this.Controls.Add(this._textBox);
  112. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  113. this.MaximizeBox = false;
  114. this.MinimizeBox = false;
  115. this.Name = "LogNoteForm";
  116. this.ShowInTaskbar = false;
  117. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  118. this.ResumeLayout(false);
  119. }
  120. #endregion
  121. protected override bool ProcessDialogKey(Keys k) {
  122. if(k==Keys.Escape) {
  123. this.DialogResult = DialogResult.Cancel;
  124. Close();
  125. return true;
  126. }
  127. else
  128. return base.ProcessDialogKey(k);
  129. }
  130. public string ResultText {
  131. get {
  132. return _textBox.Text;
  133. }
  134. }
  135. private void OnClickInsertButton(object sender, EventArgs args) {
  136. //僐儞僥僉僗僩儊僯儏乕傪偮偔傞
  137. ContextMenu menu = new ContextMenu();
  138. menu.MenuItems.Add(CreateMenuItem(0, GApp.Strings.GetString("Menu.LogNoteForm.Time"), new EventHandler(OnInsertTime)));
  139. menu.MenuItems.Add(CreateMenuItem(1, GApp.Strings.GetString("Menu.LogNoteForm.DateTime"), new EventHandler(OnInsertDateTime)));
  140. menu.Show(this, new Point(_insertButton.Left, _insertButton.Bottom));
  141. }
  142. private MenuItem CreateMenuItem(int index, string text, EventHandler handler) {
  143. GMenuItem mex = new GMenuItem();
  144. mex.Text = text;
  145. mex.Index = index;
  146. mex.Click += handler;
  147. return mex;
  148. }
  149. private void OnInsertTime(object sender, EventArgs args) {
  150. InsertText(DateTime.Now.ToShortTimeString());
  151. }
  152. private void OnInsertDateTime(object sender, EventArgs args) {
  153. InsertText(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
  154. }
  155. private void InsertText(string t) {
  156. for(int i=0; i<t.Length; i++)
  157. Win32.SendMessage(_textBox.Handle, Win32.WM_CHAR, new IntPtr((int)t[i]), IntPtr.Zero);
  158. _textBox.Focus();
  159. }
  160. }
  161. }