/// <summary> /// 处理封包的线程函数 /// </summary> private void packThreadHandler(object packageData) { PackageData pd = (PackageData)packageData; PackageUtils.pack(pd.flist, pd.savefile, pd.pak, pd.sign); this.finishFlag = true; }
/// <summary> /// 处理解包的线程函数 /// </summary> private void unpackThreadHandler(object packageData) { PackageData pd = (PackageData)packageData; foreach (string f in pd.flist) { PackageUtils.unpack(pd.pakFile, f, pd.savefile + "\\" + f); } this.finishFlag = true; }
/// <summary> /// 解包按钮 /// </summary> private void button2_Click_1(object sender, EventArgs e) { if (exPakName == String.Empty) { MessageBox.Show("你还没拉入文件呢"); return; } string savePath = String.Empty; FolderBrowserDialog fdg = new FolderBrowserDialog(); fdg.Description = "选择资源提取到哪个目录"; if (fdg.ShowDialog() == DialogResult.OK) { savePath = fdg.SelectedPath; } List <string> flist = new List <string>(); foreach (object ob in this.listBox2.SelectedItems) { flist.Add(ob.ToString()); } PackageData swapData = new PackageData() { flist = flist, savefile = savePath, pakFile = this.exPakName, sign = String.Empty }; this.progressBar1.Style = ProgressBarStyle.Marquee; this.tabControl1.Enabled = false; this.Text = "Lyyneheym包管理器 [正在提取文件]"; paker = new Thread(new ParameterizedThreadStart(this.unpackThreadHandler)); paker.IsBackground = true; paker.Start(swapData); while (!finishFlag) { Application.DoEvents(); } this.tabControl1.Enabled = true; this.progressBar1.Style = ProgressBarStyle.Continuous; this.progressBar1.Value = 0; this.Text = "Lyyneheym包管理器"; finishFlag = false; }
/// <summary> /// 生成封包文件按钮 /// </summary> private void button1_Click(object sender, EventArgs e) { if (this.listBox1.Items.Count == 0) { MessageBox.Show("先加入文件"); return; } FileDialog fwindow = new SaveFileDialog(); fwindow.Filter = "dat文件|*.dat"; if (fwindow.ShowDialog() == DialogResult.OK) { List <string> flist = new List <string>(); foreach (string s in this.listBox1.Items) { flist.Add(s); } PackageData swapData = new PackageData() { flist = flist, savefile = fwindow.FileName, pak = this.comboBox1.SelectedItem.ToString(), sign = String.Empty }; this.progressBar1.Style = ProgressBarStyle.Marquee; this.tabControl1.Enabled = false; this.Text = "Lyyneheym包管理器 [正在生成封包文件]"; paker = new Thread(new ParameterizedThreadStart(this.packThreadHandler)); paker.IsBackground = true; paker.Start(swapData); while (!finishFlag) { Application.DoEvents(); } this.tabControl1.Enabled = true; this.progressBar1.Style = ProgressBarStyle.Continuous; this.progressBar1.Value = 0; this.Text = "Lyyneheym包管理器"; finishFlag = false; } }