private void bgwA2SOutput_DoWork(object sender, DoWorkEventArgs e)
{
A2SControlEnabled(false);
string strDialogues;
string strDescriptions;
string strFolderPath;
string strFileNameWithExtension;
string strFileNameWithoutExtension;
string strFilePath;
string strDestDir = null;
int fileNum = lvASSFileSelection.Items.Count;
ssProgressBar.Maximum = fileNum;
ssProgressBar.Minimum = 0;
ssProgressBar.Step = 1;
ssProgressBar.Value = 0;
foreach (ListViewItem lviFile in lvASSFileSelection.Items)
{
strDestDir = tbSrtOutputFolder.Text;
strFilePath = (string)lviFile.Tag;
int lastSlash = strFilePath.LastIndexOf("\\");
strFolderPath = strFilePath.Substring(0, lastSlash);
strFileNameWithExtension = strFilePath.Substring(lastSlash + 1);
int lastDot = strFileNameWithExtension.LastIndexOf(".");
strFileNameWithoutExtension = strFileNameWithExtension.Substring(0, lastDot);
AssReader ar = new AssReader(strFilePath);
if (ar.IsValid())
{
foreach (ListViewItem lviType in lvVersionSelection.CheckedItems)
{
if (lviType.Index <= 4)
{
strDialogues = ar.ReadDialogues();
AssAnalyzerForSrt aafs = new AssAnalyzerForSrt(strDialogues, lviType.Index, rbChinEng.Checked);
string[] strSrtLines = aafs.Analyze();
SrtWriter sw = new SrtWriter(strDestDir, strFileNameWithoutExtension, lviType.Index);
sw.WriteSrtFile(strSrtLines);
}
else
{
string[] strAssDialogues;
string[] strAssDescriptions;
strDialogues = ar.ReadDialogues();
strDescriptions = ar.ReadDescription();
AssAnalyzerForAss aafa = new AssAnalyzerForAss(strDialogues, strDescriptions, lviType.Index, rbChinEng.Checked);
aafa.Analyze(out strAssDescriptions, out strAssDialogues);
AssWriter aw = new AssWriter(strDestDir, strFileNameWithoutExtension, lviType.Index);
aw.WriteAssFile(strAssDescriptions, strAssDialogues);
}
}
ZipPatcher(strDestDir, strFileNameWithoutExtension);
ssProgressBar.PerformStep();
}
else
{
MessageBox.Show("不是.ass文件!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
A2SControlEnabled(true);
}