本文整理汇总了C#中Paragraph.CalculateTimeCodesFromFrameNumbers方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.CalculateTimeCodesFromFrameNumbers方法的具体用法?C# Paragraph.CalculateTimeCodesFromFrameNumbers怎么用?C# Paragraph.CalculateTimeCodesFromFrameNumbers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paragraph
的用法示例。
在下文中一共展示了Paragraph.CalculateTimeCodesFromFrameNumbers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
Paragraph paragraph = null;
_errorCount = 0;
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
string s = line.Trim();
if (RegexTimeCode.IsMatch(s))
{
if (paragraph != null)
subtitle.Paragraphs.Add(paragraph);
paragraph = new Paragraph();
string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 5)
{
try
{
paragraph.StartFrame = int.Parse(parts[0]);
paragraph.EndFrame = int.Parse(parts[1]);
paragraph.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.CurrentFrameRate);
}
catch
{
_errorCount++;
}
}
}
else if (paragraph != null && s.Length > 0)
{
paragraph.Text = (paragraph.Text + Environment.NewLine + s).Trim();
if (paragraph.Text.Length > 2000)
{
_errorCount += 100;
return;
}
}
else if (s.Length > 0 && !s.StartsWith('ý'))
{
_errorCount++;
}
}
if (paragraph != null)
subtitle.Paragraphs.Add(paragraph);
subtitle.Renumber();
}
示例2: SplitSelectedParagraph
//.........这里部分代码省略.........
lines = s.SplitToLines();
}
if (lines.Length == 1)
{
string s = Utilities.AutoBreakLine(lines[0], 3, 20, languageOriginal);
lines = s.SplitToLines();
}
if (lines.Length == 1)
{
string s = Utilities.AutoBreakLine(lines[0], 3, 18, languageOriginal);
lines = s.SplitToLines();
}
if (lines.Length == 1)
{
string s = Utilities.AutoBreakLine(lines[0], 3, 15, languageOriginal);
lines = s.SplitToLines();
}
if (lines.Length == 2)
{
string a = lines[0].Trim();
string b = lines[1].Trim();
if (oldText.TrimStart().StartsWith("<i>", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("</i>", StringComparison.Ordinal) &&
Utilities.CountTagInText(oldText, "<i>") == 1 && Utilities.CountTagInText(oldText, "</i>") == 1)
{
a = a + "</i>";
b = "<i>" + b;
}
if (oldText.TrimStart().StartsWith("<b>", StringComparison.Ordinal) && oldText.TrimEnd().EndsWith("</b>", StringComparison.Ordinal) &&
Utilities.CountTagInText(oldText, "<b>") == 1 && Utilities.CountTagInText(oldText, "</b>") == 1)
{
a = a + "</b>";
b = "<b>" + b;
}
if (a.StartsWith('-') && (a.EndsWith('.') || a.EndsWith('!') || a.EndsWith('?')) &&
b.StartsWith('-') && (b.EndsWith('.') || b.EndsWith('!') || b.EndsWith('?')))
{
a = a.TrimStart('-').TrimStart();
b = b.TrimStart('-').TrimStart();
}
if (a.StartsWith("<i>-", StringComparison.Ordinal) && (a.EndsWith(".</i>", StringComparison.Ordinal) || a.EndsWith("!</i>", StringComparison.Ordinal) || a.EndsWith("?</i>", StringComparison.Ordinal)) &&
b.StartsWith("<i>-", StringComparison.Ordinal) && (b.EndsWith(".</i>", StringComparison.Ordinal) || b.EndsWith("!</i>", StringComparison.Ordinal) || b.EndsWith("?</i>", StringComparison.Ordinal)))
{
a = a.Remove(3, 1).Replace(" ", " ");
b = b.Remove(3, 1).Replace(" ", " ");
}
lines[0] = a;
lines[1] = b;
originalCurrent.Text = Utilities.AutoBreakLine(lines[0]);
originalNew.Text = Utilities.AutoBreakLine(lines[1]);
}
else if (lines.Length == 1)
{
originalNew.Text = string.Empty;
}
if (originalCurrent != null && originalNew != null)
{
if (originalCurrent.Text.StartsWith("<i> ", StringComparison.Ordinal))
originalCurrent.Text = originalCurrent.Text.Remove(3, 1);
if (originalNew.Text.StartsWith("<i> ", StringComparison.Ordinal))
originalCurrent.Text = originalCurrent.Text.Remove(3, 1);
}
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
_subtitleAlternate.Renumber();
}
}
if (_networkSession != null)
{
_networkSession.TimerStop();
SetDurationInSeconds(currentParagraph.Duration.TotalSeconds);
_networkSession.UpdateLine(_subtitle.GetIndex(currentParagraph), currentParagraph);
NetworkGetSendUpdates(new List<int>(), firstSelectedIndex + 1, newParagraph);
}
else
{
if (GetCurrentSubtitleFormat().IsFrameBased)
{
if (currentParagraph != null)
{
currentParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
currentParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
}
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
}
_subtitle.Paragraphs.Insert(firstSelectedIndex + 1, newParagraph);
_subtitle.Renumber();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex);
ShowSource();
ShowStatus(_language.LineSplitted);
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
RefreshSelectedParagraph();
SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true);
}
}
示例3: InsertAfter
private void InsertAfter()
{
var format = GetCurrentSubtitleFormat();
bool useExtraForStyle = format.HasStyleSupport;
var formatType = format.GetType();
var styles = new List<string>();
if (formatType == typeof(AdvancedSubStationAlpha) || formatType == typeof(SubStationAlpha))
styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
else if (formatType == typeof(TimedText10) || formatType == typeof(ItunesTimedText))
styles = TimedText10.GetStylesFromHeader(_subtitle.Header);
else if (formatType == typeof(Sami) || formatType == typeof(SamiModern))
styles = Sami.GetStylesFromHeader(_subtitle.Header);
string style = "Default";
if (styles.Count > 0)
style = styles[0];
MakeHistoryForUndo(_language.BeforeInsertLine);
int firstSelectedIndex = 0;
if (SubtitleListview1.SelectedItems.Count > 0)
firstSelectedIndex = SubtitleListview1.SelectedItems[0].Index + 1;
var newParagraph = new Paragraph();
if (useExtraForStyle)
{
newParagraph.Extra = style;
if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText))
{
if (styles.Count > 0)
newParagraph.Style = style;
newParagraph.Extra = TimedText10.SetExtra(newParagraph);
}
}
var prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1);
var next = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
if (prev != null)
{
int addMilliseconds = Configuration.Settings.General.MinimumMillisecondsBetweenLines;
if (addMilliseconds < 1)
addMilliseconds = 1;
newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds;
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs;
if (next != null && newParagraph.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds)
newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1;
}
else if (next != null)
{
newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 2000;
newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
}
else
{
newParagraph.StartTime.TotalMilliseconds = 1000;
newParagraph.EndTime.TotalMilliseconds = 3000;
}
if (GetCurrentSubtitleFormat().IsFrameBased)
{
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
}
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
var currentOriginal = Utilities.GetOriginalParagraph(firstSelectedIndex - 1, _subtitle.Paragraphs[firstSelectedIndex - 1], _subtitleAlternate.Paragraphs);
if (currentOriginal != null)
{
_subtitleAlternate.Paragraphs.Insert(_subtitleAlternate.Paragraphs.IndexOf(currentOriginal) + 1, new Paragraph(newParagraph));
}
else
{
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
}
_subtitleAlternate.Renumber();
}
if (_networkSession != null)
{
_networkSession.TimerStop();
NetworkGetSendUpdates(new List<int>(), firstSelectedIndex, newParagraph);
}
else
{
_subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph);
_subtitle.Renumber();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex);
ShowSource();
ShowStatus(_language.LineInserted);
}
示例4: addParagraphHereToolStripMenuItem_Click
private void addParagraphHereToolStripMenuItem_Click(object sender, EventArgs e)
{
audioVisualizer.ClearSelection();
var newParagraph = new Paragraph(audioVisualizer.NewSelectionParagraph);
var format = GetCurrentSubtitleFormat();
bool useExtraForStyle = format.HasStyleSupport;
var styles = new List<string>();
if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha))
styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
else if (format.GetType() == typeof(TimedText10) || format.GetType() == typeof(ItunesTimedText))
styles = TimedText10.GetStylesFromHeader(_subtitle.Header);
else if (format.GetType() == typeof(Sami) || format.GetType() == typeof(SamiModern))
styles = Sami.GetStylesFromHeader(_subtitle.Header);
string style = "Default";
if (styles.Count > 0)
style = styles[0];
if (useExtraForStyle)
newParagraph.Extra = style;
mediaPlayer.Pause();
// find index where to insert
int index = 0;
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
{
var p = _subtitle.Paragraphs[i];
if (p.StartTime.TotalMilliseconds > newParagraph.StartTime.TotalMilliseconds &&
(!p.StartTime.IsMaxTime || !HasSmallerStartTimes(_subtitle, i + 1, newParagraph.StartTime.TotalMilliseconds)))
{
break;
}
index++;
}
MakeHistoryForUndo(_language.BeforeInsertLine);
// create and insert
if (format.IsFrameBased)
{
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
}
if (_networkSession != null)
{
_networkSession.TimerStop();
NetworkGetSendUpdates(new List<int>(), index, newParagraph);
}
else
{
_subtitle.Paragraphs.Insert(index, newParagraph);
if (_subtitleAlternate != null && SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
{
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
_subtitleAlternate.Renumber();
}
_subtitleListViewIndex = -1;
_subtitle.Renumber();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(index);
textBoxListViewText.Focus();
audioVisualizer.NewSelectionParagraph = null;
ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString()));
audioVisualizer.Invalidate();
}
示例5: InsertNewTextAtVideoPosition
private Paragraph InsertNewTextAtVideoPosition()
{
// current movie Position
double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * TimeCode.BaseUnit;
if (!mediaPlayer.IsPaused)
videoPositionInMilliseconds -= Configuration.Settings.General.SetStartEndHumanDelay;
var tc = new TimeCode(videoPositionInMilliseconds);
MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + " " + tc);
// find index where to insert
int index = 0;
foreach (var p in _subtitle.Paragraphs)
{
if (p.StartTime.TotalMilliseconds > videoPositionInMilliseconds)
break;
index++;
}
// create and insert
var newParagraph = new Paragraph(string.Empty, videoPositionInMilliseconds, videoPositionInMilliseconds + Configuration.Settings.General.NewEmptyDefaultMs);
if (GetCurrentSubtitleFormat().IsFrameBased)
{
newParagraph.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
newParagraph.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
}
if (_networkSession != null)
{
_networkSession.TimerStop();
NetworkGetSendUpdates(new List<int>(), index, newParagraph);
}
else
{
_subtitle.Paragraphs.Insert(index, newParagraph);
// check if original is available - and insert new paragraph in the original too
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
_subtitleAlternate.Renumber();
}
_subtitleListViewIndex = -1;
_subtitle.Renumber();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(index);
return newParagraph;
}