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

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: SendingLargeText.cs,v 1.2 2005/04/20 08:45:45 okajima Exp $
  4. */
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections;
  9. using System.ComponentModel;
  10. using System.Windows.Forms;
  11. using System.Threading;
  12. using System.Diagnostics;
  13. using Poderosa;
  14. using Poderosa.Communication;
  15. using Poderosa.Terminal;
  16. namespace Poderosa.Forms
  17. {
  18. /// <summary>
  19. /// SendingLargeText 偺奣梫偺愢柧偱偡丅
  20. /// </summary>
  21. internal class SendingLargeText : System.Windows.Forms.Form
  22. {
  23. private System.Windows.Forms.ProgressBar _progressBar;
  24. private System.Windows.Forms.Label _lineCountLabel;
  25. private System.Windows.Forms.Button _cancelButton;
  26. /// <summary>
  27. /// 昁梫側僨僓僀僫曄悢偱偡丅
  28. /// </summary>
  29. private System.ComponentModel.Container components = null;
  30. private PasteProcessor _proc;
  31. public SendingLargeText(PasteProcessor proc)
  32. {
  33. _proc = proc;
  34. Init();
  35. }
  36. private void Init() {
  37. InitializeComponent();
  38. //
  39. // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
  40. //
  41. this.Text = GApp.Strings.GetString("Form.SendingLargeText.Text");
  42. this._cancelButton.Text = GApp.Strings.GetString("Common.Cancel");
  43. _progressBar.Maximum = _proc.LineCount;
  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 僼僅乕儉 僨僓僀僫偱惗惉偝傟偨僐乕僪 
  60. /// <summary>
  61. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  62. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  63. /// </summary>
  64. private void InitializeComponent()
  65. {
  66. this._cancelButton = new System.Windows.Forms.Button();
  67. this._progressBar = new System.Windows.Forms.ProgressBar();
  68. this._lineCountLabel = new System.Windows.Forms.Label();
  69. this.SuspendLayout();
  70. // 
  71. // _cancelButton
  72. // 
  73. this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  74. this._cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  75. this._cancelButton.Location = new System.Drawing.Point(208, 56);
  76. this._cancelButton.Name = "_cancelButton";
  77. this._cancelButton.TabIndex = 0;
  78. this._cancelButton.Click += new System.EventHandler(OnCancel);
  79. // 
  80. // _progressBar
  81. // 
  82. this._progressBar.Location = new System.Drawing.Point(8, 24);
  83. this._progressBar.Name = "_progressBar";
  84. this._progressBar.Size = new System.Drawing.Size(272, 23);
  85. this._progressBar.Step = 1;
  86. this._progressBar.TabIndex = 1;
  87. // 
  88. // _lineCountLabel
  89. // 
  90. this._lineCountLabel.Location = new System.Drawing.Point(8, 8);
  91. this._lineCountLabel.Name = "_lineCountLabel";
  92. this._lineCountLabel.Size = new System.Drawing.Size(144, 16);
  93. this._lineCountLabel.TabIndex = 2;
  94. // 
  95. // SendingLargeText
  96. // 
  97. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  98. this.ClientSize = new System.Drawing.Size(292, 86);
  99. this.Controls.Add(this._lineCountLabel);
  100. this.Controls.Add(this._progressBar);
  101. this.Controls.Add(this._cancelButton);
  102. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  103. this.MaximizeBox = false;
  104. this.MinimizeBox = false;
  105. this.CancelButton = _cancelButton;
  106. this.Name = "SendingLargeText";
  107. this.ShowInTaskbar = false;
  108. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  109. this.ResumeLayout(false);
  110. }
  111. #endregion
  112. protected override void OnLoad(EventArgs e) {
  113. base.OnLoad (e);
  114. _proc.LineProcessed += new PasteProcessor.EventHandler(OnLineProcessed);
  115. _proc.Perform();
  116. }
  117. private void OnLineProcessed(int i) {
  118. if(i==-1) // finish
  119. Win32.SendMessage(this.Handle, GConst.WMG_SENDLINE_PROGRESS, IntPtr.Zero, new IntPtr(-1));
  120. else
  121. Win32.SendMessage(this.Handle, GConst.WMG_SENDLINE_PROGRESS, IntPtr.Zero, new IntPtr(i));
  122. }
  123. private void OnCancel(object sender, EventArgs args) {
  124. _proc.SetAbortFlag();
  125. }
  126. protected override void WndProc(ref Message m) {
  127. base.WndProc (ref m);
  128. if(m.Msg==GConst.WMG_SENDLINE_PROGRESS) {
  129. if(m.LParam.ToInt32()==-1) {
  130. this.DialogResult = DialogResult.OK;
  131. Close();
  132. }
  133. else {
  134. _progressBar.Value = m.LParam.ToInt32();
  135. _lineCountLabel.Text = String.Format(GApp.Strings.GetString("Form.SendingLargeText._progressLabel"), _progressBar.Value+1, _proc.LineCount);
  136. }
  137. }
  138. }
  139. }
  140. }