using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; using System.Web.ClientServices; using UAS_MES.CustomControl.DataGrid_View; using UAS_MES.DataOperate; using UAS_MES.PublicForm; using UAS_MES.PublicMethod; using System.Net; using System.IO; using System.Reflection; using System.Threading; using UAS_MES.CustomControl; namespace UAS_MES { public partial class Form1 : Form { DataHelper dh; DataTable dt; LogStringBuilder sql = new LogStringBuilder(); //经过的步骤 string PastStep = ""; //拆分后的经过的步骤 Dictionary Step; //屏幕高度 int ScreenWidth; //屏幕宽度 int ScreenHeight; public Form1() { InitializeComponent(); } [DllImport("kernel32.dll")] public static extern bool d(int freq, int duration); private void button3_Click(object sender, EventArgs e) { d(800, 600); } private void Form1_Load(object sender, EventArgs e) { } private void button3_Click_1(object sender, EventArgs e) { // 禁用按钮 //this.button1.Enabled = false; //// 实例化业务对象 //PublicMethod.LongTimeWork workder = new PublicMethod.LongTimeWork(); //workder.ValueChanged += new PublicMethod.ValueChangedEventHandler(workder_ValueChanged); //// 使用异步方式调用长时间的方法 //Action handler = new Action(workder.LongTimeMethod); //handler.BeginInvoke(new AsyncCallback(this.AsyncCallback), handler); WebClient wc = new WebClient(); wc.DownloadProgressChanged += Wc_DownloadProgressChanged; wc.DownloadFileAsync(new Uri("http://218.17.158.219:8888/UAS_WinForm.zip"), "UAS_WinForm.zip"); //processBar1.Run(); } // 结束异步操作 private void AsyncCallback(IAsyncResult ar) { // 标准的处理步骤 Action handler = ar.AsyncState as Action; handler.EndInvoke(ar); MessageBox.Show("工作完成!"); System.Windows.Forms.MethodInvoker invoker = () => { // 重新启用按钮 this.button3.Enabled = true; }; if (this.InvokeRequired) { this.Invoke(invoker); } else { invoker(); } } private void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { Action act = () => { this.progressBar1.Value = e.ProgressPercentage; //this.label1.Text = e.ProgressPercentage + "%"; }; if (e.ProgressPercentage == 100) { ZipHelper.UnZip(@"H:\UAS_WinForm\UAS-MES\bin\Debug\icsharpcode-SharpZipLib-4ad264b.zip", @"D:\"); } this.Invoke(act); } //public static void Unzip() //{ // string _appPath = new DirectoryInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName).Parent.FullName; // string s7z = _appPath + @"\7-Zip\7z.exe"; // System.Diagnostics.Process pNew = new System.Diagnostics.Process(); // pNew.StartInfo.FileName = s7z; // pNew.StartInfo.Arguments = string.Format(" x \"{0}\\{1}\" -y -o\"{0}\"", _appPath, zipFileFullName); // //x "1" -y -o"2" 这段7z命令的意思: x是解压的意思 "{0}"的位置写要解压文件路径"{1}"这个1的位置写要解压的文件名 -y是覆盖的意思 -o是要解压的位置 // pNew.Start(); // //等待完成 // pNew.WaitForExit(); // //删除压缩包 // File.Delete(_appPath + @"\" + zipFileFullName); //} private void button4_Click(object sender, EventArgs e) { MessageBox.Show(textBoxWithPlaceHolder1.Text); } } //public class ZipHelper //{ // public static string zipFileFullName = "UAS_WinForm.zip"; // public static void Unzip() // { // string _appPath = new DirectoryInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName).Parent.FullName; // string s7z = _appPath + @"\7z.exe"; // System.Diagnostics.Process pNew = new System.Diagnostics.Process(); // pNew.StartInfo.FileName = s7z; // pNew.StartInfo.Arguments = string.Format(" x \"{0}\\{1}\" -y -o\"{0}\"", _appPath, zipFileFullName); // //x "1" -y -o"2" 这段7z命令的意思: x是解压的意思 "{0}"的位置写要解压文件路径"{1}"这个1的位置写要解压的文件名 -y是覆盖的意思 -o是要解压的位置 // pNew.Start(); // //等待完成 // pNew.WaitForExit(); // //删除压缩包 // //File.Delete(_appPath + @"\" + zipFileFullName); // } //} }