本文整理汇总了C#中Nikse.SubtitleEdit.Core.Subtitle.CalculateTimeCodesFromFrameNumbers方法的典型用法代码示例。如果您正苦于以下问题:C# Subtitle.CalculateTimeCodesFromFrameNumbers方法的具体用法?C# Subtitle.CalculateTimeCodesFromFrameNumbers怎么用?C# Subtitle.CalculateTimeCodesFromFrameNumbers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Core.Subtitle
的用法示例。
在下文中一共展示了Subtitle.CalculateTimeCodesFromFrameNumbers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportTimeCodesInFramesOnSameSeperateLine
private Subtitle ImportTimeCodesInFramesOnSameSeperateLine(string[] lines)
{
Paragraph p = null;
var subtitle = new Subtitle();
var sb = new StringBuilder();
for (int idx = 0; idx < lines.Length; idx++)
{
string line = lines[idx];
string lineWithPerhapsOnlyNumbers = GetLineWithPerhapsOnlyNumbers(line);
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
foreach (char c in lineWithPerhapsOnlyNumbers)
{
if (!char.IsDigit(c))
allNumbers = false;
}
if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 2)
{
string[] arr = line.Replace('-', ' ').Replace('>', ' ').Replace('{', ' ').Replace('}', ' ').Replace('[', ' ').Replace(']', ' ').Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 2)
{
string[] start = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
string[] end = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
if (start.Length == 1 && end.Length == 1)
{
if (p != null)
{
p.Text = sb.ToString().Trim();
subtitle.Paragraphs.Add(p);
}
p = new Paragraph();
sb = new StringBuilder();
try
{
if (UseFrames)
{
p.StartFrame = int.Parse(start[0]);
p.EndFrame = int.Parse(end[0]);
p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
}
else
{
p.StartTime.TotalMilliseconds = double.Parse(start[0]);
p.EndTime.TotalMilliseconds = double.Parse(end[0]);
}
}
catch
{
p = null;
}
}
}
else if (arr.Length == 3)
{
string[] start = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
string[] end = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
string[] duration = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
if (end.Length == 1 && duration.Length == 1)
{
start = end;
end = duration;
}
if (start.Length == 1 && end.Length == 1)
{
if (p != null)
{
p.Text = sb.ToString().Trim();
subtitle.Paragraphs.Add(p);
}
p = new Paragraph();
sb = new StringBuilder();
try
{
if (UseFrames)
{
p.StartFrame = int.Parse(start[0]);
p.EndFrame = int.Parse(end[0]);
p.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
}
else
{
p.StartTime.TotalMilliseconds = double.Parse(start[0]);
p.EndTime.TotalMilliseconds = double.Parse(end[0]);
}
}
catch
{
p = null;
}
}
}
}
if (p != null && !allNumbers && line.Length > 1)
{
line = line.Trim();
if (line.StartsWith("}{}", StringComparison.Ordinal) || line.StartsWith("][]", StringComparison.Ordinal))
line = line.Remove(0, 3);
sb.AppendLine(line.Trim());
}
//.........这里部分代码省略.........