UpdateCue.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.Runtime.InteropServices;
  9. using System.Diagnostics;
  10. using US.Browser.IE.BLL;
  11. namespace US.Browser.IE
  12. {
  13. /// <summary>
  14. /// 文件下载区域
  15. /// </summary>
  16. [System.Runtime.InteropServices.ComVisible(true)]
  17. public partial class UpdateCue : Form
  18. {
  19. public static StaticClass _USE;
  20. public static UpdateCue _UDE;
  21. System.Windows.Forms.Timer _UT;
  22. /// <summary>
  23. /// 初始化更新
  24. /// </summary>
  25. /// <param name="USE"></param>
  26. /// <returns></returns>
  27. public static UpdateCue NewUpCF(StaticClass USE)
  28. {
  29. if (_UDE == null) { _UDE = new UpdateCue(); _USE = USE; }
  30. return _UDE;
  31. }
  32. /// <summary>
  33. /// 更新页面初始
  34. /// </summary>
  35. public UpdateCue()
  36. {
  37. InitializeComponent(); UpC.ObjectForScripting = this; UpC.ScriptErrorsSuppressed = true;
  38. Point _UTL = new Point((Int32)(Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, (Int32)(Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);
  39. this.PointToScreen(_UTL); this.Location = _UTL; UpC.IsWebBrowserContextMenuEnabled = false;
  40. UpC.Url = new System.Uri(Application.StartupPath + "\\html\\UpdateCue.html"); IsGX();
  41. }
  42. /// <summary>
  43. /// 判断是否需要更新浏览器
  44. /// </summary>
  45. private void IsGX()
  46. {
  47. _UT = new System.Windows.Forms.Timer();
  48. _UT.Tick += new EventHandler(_UT_Elapsed);
  49. _UT.Interval = 3600000; _UT.Start();//3600000
  50. }
  51. /// <summary>
  52. /// 获取版本
  53. /// </summary>
  54. /// <param name="sender"></param>
  55. /// <param name="e"></param>
  56. void _UT_Elapsed(object sender, EventArgs e)
  57. {
  58. if (BLL.USIE.isnet()) { showp(true); }
  59. }
  60. /// <summary>
  61. /// 检测更新
  62. /// </summary>
  63. public bool showp(bool UTF)
  64. {
  65. string UST = USClientCommunicate.GetPage("http://seo.1473.cn/Client/ver.txt");
  66. if (UST.Length > 1 && UST != StaticClass.ver) { _UT.Stop(); _UT.Dispose(); this.Visible = true; if (UTF) { this.SendToBack(); } else { this.BringToFront(); } return true; } return false;
  67. }
  68. /// <summary>
  69. /// 网络上下载安装包
  70. /// </summary>
  71. public void UpCNow()
  72. {
  73. UpC.Navigate("http://seo.1473.cn/Client/云端.msi");
  74. UpC.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(UpC_DocumentCompleted);
  75. }
  76. /// <summary>
  77. /// 下载安装包完毕
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. void UpC_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
  82. {
  83. this.Hide(); UpC.DocumentCompleted -= UpC_DocumentCompleted;
  84. }
  85. /// <summary>
  86. /// 点击稍后更新
  87. /// </summary>
  88. public void UpCNext()
  89. {
  90. this.Hide(); IsGX();
  91. }
  92. #region 窗体拖动
  93. //窗体拖动
  94. [DllImport("user32.dll")]
  95. public static extern bool ReleaseCapture();//API函数
  96. [DllImport("user32.dll")]
  97. public static extern bool SendMessage(IntPtr hwdn, int wMsg, int mParam, int lParam);//接受发送来的消息 并处理
  98. public const int WM_SYSCOMMAND = 0x0112;//该变量表示将向Windows发送消息的类型
  99. public const int SC_MOVE = 0xF010;//该变量表示发送消息的附加消息
  100. public const int HTCAPTION = 0x0002;
  101. /// <summary>
  102. /// 拖动
  103. /// </summary>
  104. public void _Main_Drag()
  105. {
  106. ReleaseCapture();//该函数从当前线程中释放鼠标捕获事件,并恢复鼠标输入处理
  107. SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
  108. }
  109. #endregion
  110. }
  111. }