ftp.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Threading;
  9. using System.Runtime.InteropServices;
  10. using US.Browser.IE.BLL;
  11. using System.Reflection;
  12. namespace US.Browser.IE
  13. {
  14. [System.Runtime.InteropServices.ComVisible(true)]
  15. public partial class ftp : Form
  16. {
  17. private WebBrowser WB;
  18. private RespondWeb rwf;
  19. public static ftp uft;
  20. string json;
  21. #region 初始化加载ftp
  22. /// <summary>
  23. ///
  24. /// </summary>
  25. /// <param name="json"></param>
  26. public static void snews(string json, WebBrowser WB, RespondWeb rf)
  27. {
  28. if (uft != null) { }
  29. else { uft = new ftp(json, WB, rf); }
  30. }
  31. /// <summary>
  32. /// ftp加载
  33. /// </summary>
  34. public ftp(string json, RespondWeb rf)
  35. {
  36. init(json); rwf = rf;
  37. }
  38. /// <summary>
  39. /// ftp加载
  40. /// </summary>
  41. /// <param name="json"></param>
  42. public ftp(string json, WebBrowser WB, RespondWeb rf)
  43. {
  44. this.WB = WB; init(json); rwf = rf;
  45. }
  46. /// <summary>
  47. /// 页面生成
  48. /// </summary>
  49. public void init(string json)
  50. {
  51. InitializeComponent(); ftpBinit(); this.Hide(); this.json = json;
  52. ftpB.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(ftpB_DocumentCompleted);
  53. }
  54. /// <summary>
  55. /// 加载完毕
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. void ftpB_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  60. {
  61. completed(this.json); this.json = null;
  62. }
  63. /// <summary>
  64. /// 加载提示页面
  65. /// </summary>
  66. public void ftpBinit()
  67. {
  68. ftpB.ObjectForScripting = this; ftpB.ScriptErrorsSuppressed = true;
  69. this.ftpB.Url = new System.Uri(Application.StartupPath + "\\html\\ftp.html");
  70. }
  71. /// <summary>
  72. /// 加载成功
  73. /// </summary>
  74. /// <param name="json"></param>
  75. public void completed(string json)
  76. {
  77. this.ftpB.Document.InvokeScript("_setT", new object[] { json });
  78. }
  79. #endregion
  80. #region 窗口显示和消失
  81. /// <summary>
  82. /// 显示窗口
  83. /// </summary>
  84. public void _fs()
  85. {
  86. Size s = Screen.PrimaryScreen.WorkingArea.Size; Point WZ = new Point((Int32)(s.Width) - 5, (Int32)(s.Height - this.Height - 20));
  87. this.Show(); this.Location = WZ; animate(false, -this.Width - 20, this);
  88. }
  89. /// <summary>
  90. /// 窗口消失
  91. /// </summary>
  92. public void _fh()
  93. {
  94. animate(true, this.Width, this);
  95. }
  96. /// <summary>
  97. /// 动画函数
  98. /// </summary>
  99. /// <param name="e"></param>
  100. public static void animate(bool tf, int c, Form uf)
  101. {
  102. System.Windows.Forms.Timer _tt = new System.Windows.Forms.Timer(); int u, k = c < 0 ? -30 : 30, i = c / k, m = uf.Location.X + c;
  103. _tt.Tick += new EventHandler(delegate(object sender, EventArgs g)
  104. {
  105. u = i == 0 ? m : uf.Location.X + k; uf.Location = new Point(u, uf.Location.Y);
  106. if (i-- == 0) { _tt.Stop(); _tt.Dispose(); _tt = null; if (tf) { uf.Hide(); uf.Dispose(); } };
  107. });
  108. _tt.Interval = 10; _tt.Start();
  109. }
  110. /// <summary>
  111. /// 释放窗体
  112. /// </summary>
  113. public void dis()
  114. {
  115. this.Hide(); this.Dispose();
  116. }
  117. /// <summary>
  118. /// 窗口闪烁
  119. /// </summary>
  120. /// <param name="img"></param>
  121. public void xxs(string img, string tf, string ue)
  122. {
  123. try
  124. {
  125. StaticClass._twstart(img, tf, ue, WB, rwf);
  126. this.Dispose(); BLL.WindowHWND.freem();
  127. }
  128. catch (Exception e) { }
  129. }
  130. /// <summary>
  131. /// 查看内容提示
  132. /// </summary>
  133. public void cknr(string tf, string ue)
  134. {
  135. rwf.OpenLook(new object[] { tf, ue }, WB);
  136. }
  137. /// <summary>
  138. /// 设置id
  139. /// </summary>
  140. /// <param name="id"></param>
  141. public void setxx(string id)
  142. {
  143. USMain.id = id;
  144. }
  145. #endregion
  146. }
  147. }