本文整理汇总了C#中Nikse.SubtitleEdit.Core.Paragraph.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.ToString方法的具体用法?C# Paragraph.ToString怎么用?C# Paragraph.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Core.Paragraph
的用法示例。
在下文中一共展示了Paragraph.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveStartTime
private int MoveStartTime(string fixAction, int noOfShortDisplayTimes, Paragraph p, Paragraph temp, Paragraph next)
{
if (AllowFix(p, fixAction))
{
string oldCurrent = p.ToString();
if (next != null && next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > p.EndTime.TotalMilliseconds)
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
p.StartTime.TotalMilliseconds = p.EndTime.TotalMilliseconds - temp.Duration.TotalMilliseconds;
noOfShortDisplayTimes++;
AddFixToListView(p, fixAction, oldCurrent, p.ToString());
}
return noOfShortDisplayTimes;
}
示例2: FixOverlappingDisplayTimes
public void FixOverlappingDisplayTimes()
{
// negative display time
string fixAction = _language.FixOverlappingDisplayTime;
int noOfOverlappingDisplayTimesFixed = 0;
for (int i = 0; i < Subtitle.Paragraphs.Count; i++)
{
var p = Subtitle.Paragraphs[i];
var oldP = new Paragraph(p);
if (p.Duration.TotalMilliseconds < 0) // negative display time...
{
bool isFixed = false;
string status = string.Format(_language.StartTimeLaterThanEndTime,
i + 1, p.StartTime, p.EndTime, p.Text, Environment.NewLine);
var prev = Subtitle.GetParagraphOrDefault(i - 1);
var next = Subtitle.GetParagraphOrDefault(i + 1);
double wantedDisplayTime = Utilities.GetOptimalDisplayMilliseconds(p.Text) * 0.9;
if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + wantedDisplayTime)
{
if (AllowFix(p, fixAction))
{
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + wantedDisplayTime;
isFixed = true;
}
}
else if (next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + 500.0)
{
if (AllowFix(p, fixAction))
{
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 500.0;
isFixed = true;
}
}
else if (prev == null || next.StartTime.TotalMilliseconds - wantedDisplayTime > prev.EndTime.TotalMilliseconds)
{
if (AllowFix(p, fixAction))
{
p.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - wantedDisplayTime;
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
isFixed = true;
}
}
else
{
LogStatus(_language.FixOverlappingDisplayTimes, string.Format(_language.UnableToFixStartTimeLaterThanEndTime,
i + 1, p), true);
_totalErrors++;
}
if (isFixed)
{
noOfOverlappingDisplayTimesFixed++;
status = string.Format(_language.XFixedToYZ, status, Environment.NewLine, p);
LogStatus(_language.FixOverlappingDisplayTimes, status);
AddFixToListView(p, fixAction, oldP.ToString(), p.ToString());
}
}
}
// overlapping display time
for (int i = 1; i < Subtitle.Paragraphs.Count; i++)
{
Paragraph p = Subtitle.Paragraphs[i];
Paragraph prev = Subtitle.GetParagraphOrDefault(i - 1);
Paragraph target = prev;
string oldCurrent = p.ToString();
string oldPrevious = prev.ToString();
double prevWantedDisplayTime = Utilities.GetOptimalDisplayMilliseconds(prev.Text, Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds);
double currentWantedDisplayTime = Utilities.GetOptimalDisplayMilliseconds(p.Text, Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds);
double prevOptimalDisplayTime = Utilities.GetOptimalDisplayMilliseconds(prev.Text);
double currentOptimalDisplayTime = Utilities.GetOptimalDisplayMilliseconds(p.Text);
bool canBeEqual = _format != null && (_format.GetType() == typeof(AdvancedSubStationAlpha) || _format.GetType() == typeof(SubStationAlpha));
if (!canBeEqual)
canBeEqual = Configuration.Settings.Tools.FixCommonErrorsFixOverlapAllowEqualEndStart;
double diff = prev.EndTime.TotalMilliseconds - p.StartTime.TotalMilliseconds;
if (!prev.StartTime.IsMaxTime && !p.StartTime.IsMaxTime && diff >= 0 && !(canBeEqual && diff == 0))
{
int diffHalf = (int)(diff / 2);
if (!Configuration.Settings.Tools.FixCommonErrorsFixOverlapAllowEqualEndStart && p.StartTime.TotalMilliseconds == prev.EndTime.TotalMilliseconds &&
prev.Duration.TotalMilliseconds > 100)
{
if (AllowFix(target, fixAction))
{
if (!canBeEqual)
{
bool okEqual = true;
if (prev.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
prev.EndTime.TotalMilliseconds--;
else if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
p.StartTime.TotalMilliseconds++;
else
okEqual = false;
if (okEqual)
{
noOfOverlappingDisplayTimesFixed++;
AddFixToListView(target, fixAction, oldPrevious, prev.ToString());
//.........这里部分代码省略.........