Beispiel #1
0
        private void btnProduce_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(name.Text.Trim()))
            {
                MessageBox.Show("压缩包名称不能为空,请填写!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                name.Focus();
                return;
            }
            // 建立新线程
            if (btnProduce.Text == "生成(&G)")
            {
                //if (!File.Exists(txtSrc.Text))
                if (string.IsNullOrEmpty(txtSrc.Text.Trim()))
                {
                    MessageBox.Show(this, "请选择主入口程序!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnSrc_Click(sender, e);
                    return;
                }

                //if (txtDest.Text.Trim() == string.Empty)
                //{
                //    MessageBox.Show(this, "请选择程序发布目录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    btnSearDes_Click(sender, e);
                //    return;
                //}
                linkLabel1.Visible = false;
                var files = new List <string>();
                foreach (ListViewItem item in FileList.Items)
                {
                    if (item.Checked)
                    {
                        files.Add(item.Text);
                    }
                }

                //FileVersionInfo VerInfo = FileVersionInfo.GetVersionInfo(txtSrc.Text.Trim());

                var threadArgs = new ThreadArgs
                {
                    MainInfo = new XmlMainInfo
                    {
                        AppName     = txtSrc.Text.Trim(),
                        Version     = name.Text.Trim(),
                        IsMust      = checkBox1.Checked.ToString().ToUpper(),
                        Description = DescriptionValue.Text.Trim(),
                        UpdateTime  = DateTime.Now,
                        UpdateType  = "",
                    },
                    SavePath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Templates), Guid.NewGuid().ToString()),
                    //txtDest.Text.Trim(),

                    ExcludeInfo = new ExcludeInfo(AppPath)
                };

                threadArgs.ExcludeInfo.Files.AddRange(files);
                Directory.CreateDirectory(threadArgs.SavePath);


                threadArgs.IsZipFile = true;

                if (_xmlConfig == null)
                {
                    _xmlConfig = new UpdateXmlConfig(threadArgs);
                    _xmlConfig.XmlCreateProgressEvent += XmlConfig_XmlCreateProgressEvent;
                }

                prbProd.Minimum = 0;
                prbProd.Value   = 0;
                prbProd.Maximum = 100;

                _xmlConfig.Start();
                btnProduce.Text    = "停止(&S)";
                linkLabel1.Text    = threadArgs.SavePath;
                linkLabel1.Visible = true;
            }
            else
            {
                linkLabel1.Visible = false;
                _xmlConfig.Stop();
                btnProduce.Text = "生成(&G)";
            }
        }