private void btnSavePak_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
long pakLen = _pakFormat.CompressedPakFilesize;
long pabLen = _pakFormat.CompressedPabFilesize;
QbItemBase qib;
try
{
_qbFile.AlignPointers();
qib = _qbFile.IsValid();
if (qib != null)
{
foreach (ListViewItem li in lstQbItems.Items)
{
if (li.Tag == qib)
{
li.Selected = true;
li.EnsureVisible();
showError("Invalid Item", QbFile.FormatIsValidErrorMessage(qib, qib.IsValid));
}
}
return;
}
_pakFile.ReplaceFile(_qbFile.Filename, _qbFile);
btnSavePak.Enabled = false;
}
catch (Exception ex)
{
showException("Save to PAK Error", ex);
return;
}
try
{
_pakFormat.SaveDebugQbKey();
}
catch (Exception ex)
{
showException("Save to User QB Key Error", ex);
return;
}
try
{
if (_pakFormat.IsCompressed)
{
if (_pakFormat.PakFormatType == PakFormatType.XBox)
{
if (pakLen > _pakFormat.CompressedPakFilesize)
showError("PAK Size", string.Format("The PAK file is {0} bytes larger than the original", (pakLen - _pakFormat.CompressedPakFilesize).ToString()));
if (pabLen > _pakFormat.CompressedPabFilesize)
showError("PAB Size", string.Format("The PAB file is {0} bytes larger than the original", (pabLen - _pakFormat.CompressedPabFilesize).ToString()));
}
}
}
catch (Exception ex)
{
showException("Compress Files Error", ex);
return;
}
refreshPakList();
updateStatusItems();
}
finally
{
this.Cursor = Cursors.Default;
}
}