using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using US.Browser.IE.BLL;
namespace US.Browser.IE
{
///
/// 文件下载区域
///
[System.Runtime.InteropServices.ComVisible(true)]
public partial class UpdateCue : Form
{
public static StaticClass _USE;
public static UpdateCue _UDE;
System.Windows.Forms.Timer _UT;
///
/// 初始化更新
///
///
///
public static UpdateCue NewUpCF(StaticClass USE)
{
if (_UDE == null) { _UDE = new UpdateCue(); _USE = USE; }
return _UDE;
}
///
/// 更新页面初始
///
public UpdateCue()
{
InitializeComponent(); UpC.ObjectForScripting = this; UpC.ScriptErrorsSuppressed = true;
Point _UTL = new Point((Int32)(Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2, (Int32)(Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);
this.PointToScreen(_UTL); this.Location = _UTL; UpC.IsWebBrowserContextMenuEnabled = false;
UpC.Url = new System.Uri(Application.StartupPath + "\\html\\UpdateCue.html"); IsGX();
}
///
/// 判断是否需要更新浏览器
///
private void IsGX()
{
_UT = new System.Windows.Forms.Timer();
_UT.Tick += new EventHandler(_UT_Elapsed);
_UT.Interval = 3600000; _UT.Start();//3600000
}
///
/// 获取版本
///
///
///
void _UT_Elapsed(object sender, EventArgs e)
{
if (BLL.USIE.isnet()) { showp(true); }
}
///
/// 检测更新
///
public bool showp(bool UTF)
{
string UST = USClientCommunicate.GetPage("http://seo.1473.cn/Client/ver.txt");
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;
}
///
/// 网络上下载安装包
///
public void UpCNow()
{
UpC.Navigate("http://seo.1473.cn/Client/云端.msi");
UpC.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(UpC_DocumentCompleted);
}
///
/// 下载安装包完毕
///
///
///
void UpC_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.Hide(); UpC.DocumentCompleted -= UpC_DocumentCompleted;
}
///
/// 点击稍后更新
///
public void UpCNext()
{
this.Hide(); IsGX();
}
#region 窗体拖动
//窗体拖动
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();//API函数
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwdn, int wMsg, int mParam, int lParam);//接受发送来的消息 并处理
public const int WM_SYSCOMMAND = 0x0112;//该变量表示将向Windows发送消息的类型
public const int SC_MOVE = 0xF010;//该变量表示发送消息的附加消息
public const int HTCAPTION = 0x0002;
///
/// 拖动
///
public void _Main_Drag()
{
ReleaseCapture();//该函数从当前线程中释放鼠标捕获事件,并恢复鼠标输入处理
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
#endregion
}
}