本文整理汇总了C#中Nikse.SubtitleEdit.Logic.Subtitle.RemoveEmptyLines方法的典型用法代码示例。如果您正苦于以下问题:C# Subtitle.RemoveEmptyLines方法的具体用法?C# Subtitle.RemoveEmptyLines怎么用?C# Subtitle.RemoveEmptyLines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.Subtitle
的用法示例。
在下文中一共展示了Subtitle.RemoveEmptyLines方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CleanUp
private static void CleanUp(Subtitle subtitle)
{
foreach (Paragraph p in subtitle.Paragraphs)
{
p.Text = p.Text.Replace("<div>", string.Empty);
p.Text = p.Text.Replace("</div>", string.Empty);
p.Text = p.Text.Replace("<body>", string.Empty);
p.Text = p.Text.Replace("</body>", string.Empty);
p.Text = p.Text.Replace("</tt>", string.Empty);
p.Text = p.Text.Replace(" ", " ");
p.Text = p.Text.Replace(" ", " ");
p.Text = p.Text.Replace(" ", " ");
p.Text = p.Text.Replace("|", Environment.NewLine).Replace("<p>", Environment.NewLine).Replace("</p>", Environment.NewLine).Trim();
p.Text = p.Text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine).Trim();
p.Text = p.Text.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine).Trim();
}
subtitle.RemoveEmptyLines();
}
示例2: toolStripMenuItemInsertTextFromSub_Click
private void toolStripMenuItemInsertTextFromSub_Click(object sender, EventArgs e)
{
openFileDialog1.Title = _languageGeneral.OpenSubtitle;
openFileDialog1.FileName = string.Empty;
openFileDialog1.Filter = Utilities.GetOpenDialogFilter();
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
if (!File.Exists(openFileDialog1.FileName))
return;
var fi = new FileInfo(openFileDialog1.FileName);
if (fi.Length > 1024 * 1024 * 10) // max 10 mb
{
if (MessageBox.Show(string.Format(_language.FileXIsLargerThan10Mb + Environment.NewLine +
Environment.NewLine +
_language.ContinueAnyway,
openFileDialog1.FileName), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
return;
}
Encoding encoding = null;
var tmp = new Subtitle();
SubtitleFormat format = tmp.LoadSubtitle(openFileDialog1.FileName, out encoding, encoding);
if (format != null)
{
if (format.IsFrameBased)
tmp.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
tmp.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
if (Configuration.Settings.General.RemoveBlankLinesWhenOpening)
tmp.RemoveEmptyLines();
if (SubtitleListview1.SelectedIndices.Count < 1)
return;
MakeHistoryForUndo(_language.BeforeColumnShiftCellsDown);
int index = FirstSelectedIndex;
for (int i = 0; i < tmp.Paragraphs.Count; i++)
{
{
for (int k = _subtitle.Paragraphs.Count - 2; k > index; k--)
{
_subtitle.Paragraphs[k + 1].Text = _subtitle.Paragraphs[k].Text;
}
}
}
for (int i = 0; i + index < _subtitle.Paragraphs.Count && i < tmp.Paragraphs.Count; i++)
_subtitle.Paragraphs[index + i].Text = tmp.Paragraphs[i].Text;
if (IsFramesRelevant && CurrentFrameRate > 0)
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
RefreshSelectedParagraph();
}
}
}
示例3: ToolStripMenuItemInsertSubtitleClick
private void ToolStripMenuItemInsertSubtitleClick(object sender, EventArgs e)
{
openFileDialog1.Title = _languageGeneral.OpenSubtitle;
openFileDialog1.FileName = string.Empty;
openFileDialog1.Filter = Utilities.GetOpenDialogFilter();
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
if (!File.Exists(openFileDialog1.FileName))
return;
var fi = new FileInfo(openFileDialog1.FileName);
if (fi.Length > 1024 * 1024 * 10) // max 10 mb
{
if (MessageBox.Show(string.Format(_language.FileXIsLargerThan10Mb + Environment.NewLine +
Environment.NewLine +
_language.ContinueAnyway,
openFileDialog1.FileName), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
return;
}
MakeHistoryForUndo(string.Format(_language.BeforeInsertLine, openFileDialog1.FileName));
Encoding encoding = null;
var subtitle = new Subtitle();
SubtitleFormat format = subtitle.LoadSubtitle(openFileDialog1.FileName, out encoding, encoding);
if (format != null)
{
SaveSubtitleListviewIndexes();
if (format.IsFrameBased)
subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
subtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
if (Configuration.Settings.General.RemoveBlankLinesWhenOpening)
subtitle.RemoveEmptyLines();
int index = FirstSelectedIndex + 1;
if (index < 0)
index = 0;
foreach (Paragraph p in subtitle.Paragraphs)
{
_subtitle.Paragraphs.Insert(index, new Paragraph(p));
index++;
}
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
index = FirstSelectedIndex;
if (index < 0)
index = 0;
Paragraph current = _subtitle.GetParagraphOrDefault(index);
if (current != null)
{
Paragraph original = Utilities.GetOriginalParagraph(index, current, _subtitleAlternate.Paragraphs);
if (original != null)
{
index = _subtitleAlternate.GetIndex(original);
foreach (Paragraph p in subtitle.Paragraphs)
{
_subtitleAlternate.Paragraphs.Insert(index, new Paragraph(p));
index++;
}
if (subtitle.Paragraphs.Count > 0)
_subtitleAlternate.Renumber(1);
}
}
}
_subtitle.Renumber(1);
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndexes();
}
}
}
示例4: buttonConvert_Click
//.........这里部分代码省略.........
}
if (comboBoxSubtitleFormats.Text == new AdvancedSubStationAlpha().Name && _assStyle != null)
{
sub.Header = _assStyle;
}
else if (comboBoxSubtitleFormats.Text == new SubStationAlpha().Name && _ssaStyle != null)
{
sub.Header = _ssaStyle;
}
int prevIndex = -1;
foreach (Paragraph p in sub.Paragraphs)
{
string prevText = string.Empty;
var prev = sub.GetParagraphOrDefault(prevIndex);
if (prev != null)
prevText = prev.Text;
prevIndex++;
if (checkBoxRemoveTextForHI.Checked)
{
p.Text = _removeForHI.RemoveTextFromHearImpaired(p.Text, prevText);
}
if (checkBoxRemoveFormatting.Checked)
{
p.Text = Utilities.RemoveHtmlTags(p.Text);
if (p.Text.StartsWith("{") && p.Text.Length > 6 && p.Text[5] == '}')
p.Text = p.Text.Remove(0, 6);
if (p.Text.StartsWith("{") && p.Text.Length > 6 && p.Text[4] == '}')
p.Text = p.Text.Remove(0, 5);
}
}
sub.RemoveEmptyLines();
if (checkBoxFixCasing.Checked)
{
_changeCasing.FixCasing(sub, Utilities.AutoDetectGoogleLanguage(sub));
_changeCasingNames.Initialize(sub);
_changeCasingNames.FixCasing();
}
double fromFrameRate;
double toFrameRate;
if (double.TryParse(comboBoxFrameRateFrom.Text.Replace(",", "."), NumberStyles.AllowDecimalPoint , CultureInfo.InvariantCulture, out fromFrameRate) &&
double.TryParse(comboBoxFrameRateTo.Text.Replace(",", "."), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out toFrameRate))
{
sub.ChangeFramerate(fromFrameRate, toFrameRate);
}
if (timeUpDownAdjust.TimeCode.TotalMilliseconds > 0.00001)
{
var totalMilliseconds = timeUpDownAdjust.TimeCode.TotalMilliseconds;
if (radioButtonShowEarlier.Checked)
totalMilliseconds *= -1;
sub.AddTimeToAllParagraphs(TimeSpan.FromMilliseconds(totalMilliseconds));
}
while (worker1.IsBusy && worker2.IsBusy && worker3.IsBusy)
{
Application.DoEvents();
System.Threading.Thread.Sleep(100);
}
ThreadDoWorkParameter parameter = new ThreadDoWorkParameter(checkBoxFixCommonErrors.Checked, checkBoxMultipleReplace.Checked, checkBoxSplitLongLines.Checked, checkBoxAutoBalance.Checked, checkBoxSetMinimumDisplayTimeBetweenSubs.Checked, item, sub, GetCurrentSubtitleFormat(), GetCurrentEncoding(), Configuration.Settings.Tools.BatchConvertLanguage, fileName, toFormat, format);
if (!worker1.IsBusy)
worker1.RunWorkerAsync(parameter);