private void createPackageBtn_Click(object sender, EventArgs e) { createPackageBtn.Enabled = false; try { uint version = Package.CurrentVersion; switch (packageVersion.SelectedIndex) { case 0: version = 13; break; case 1: version = 10; break; case 2: version = 9; break; case 3: version = 7; break; } CompressionMethod compression = CompressionMethod.None; bool fastCompression = true; switch (compressionMethod.SelectedIndex) { case 1: compression = CompressionMethod.Zlib; break; case 2: compression = CompressionMethod.Zlib; fastCompression = false; break; case 3: compression = CompressionMethod.LZ4; break; case 4: compression = CompressionMethod.LZ4; fastCompression = false; break; } // Fallback to Zlib, if the package version doesn't support LZ4 if (compression == CompressionMethod.LZ4 && version <= 9) { compression = CompressionMethod.Zlib; } var packager = new Packager(); packager.progressUpdate += this.PackageProgressUpdate; packager.CreatePackage(packagePath.Text, extractionPath.Text, version, compression, fastCompression); MessageBox.Show("Package created successfully."); } catch (Exception exc) { MessageBox.Show("Internal error!\r\n\r\n" + exc.ToString(), "Package Build Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { packageProgressLabel.Text = ""; packageProgress.Value = 0; createPackageBtn.Enabled = true; } }
private void extractPackageBtn_Click(object sender, EventArgs e) { extractPackageBtn.Enabled = false; try { var packager = new Packager(); packager.progressUpdate += this.PackageProgressUpdate; packager.UncompressPackage(packagePath.Text, extractionPath.Text); MessageBox.Show("Package extracted successfully."); } catch (Exception exc) { MessageBox.Show("Internal error!\r\n\r\n" + exc.ToString(), "Extraction Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { packageProgressLabel.Text = ""; packageProgress.Value = 0; extractPackageBtn.Enabled = true; } }