本文整理汇总了C#中Nikse.SubtitleEdit.Logic.Paragraph.CalculateFrameNumbersFromTimeCodes方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.CalculateFrameNumbersFromTimeCodes方法的具体用法?C# Paragraph.CalculateFrameNumbersFromTimeCodes怎么用?C# Paragraph.CalculateFrameNumbersFromTimeCodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.Paragraph
的用法示例。
在下文中一共展示了Paragraph.CalculateFrameNumbersFromTimeCodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitSelectedParagraph
//.........这里部分代码省略.........
lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}
if (lines.Length == 1)
{
string s = Utilities.AutoBreakLine(lines[0], 3, Configuration.Settings.General.SubtitleLineMaximumLength, 20);
lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}
if (lines.Length == 1)
{
string s = Utilities.AutoBreakLine(lines[0], 3, Convert.ToInt32(Configuration.Settings.General.SubtitleLineMaximumLength * 0.7), 18);
lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}
if (lines.Length == 1)
{
string s = Utilities.AutoBreakLine(lines[0], 3, Convert.ToInt32(Configuration.Settings.General.SubtitleLineMaximumLength * 0.5), 15);
lines = s.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
}
if (lines.Length == 2)
{
string a = lines[0].Trim();
string b = lines[1].Trim();
if (oldText.TrimStart().StartsWith("<i>") && oldText.TrimEnd().EndsWith("</i>") &&
Utilities.CountTagInText(oldText, "<i>") == 1 && Utilities.CountTagInText(oldText, "</i>") == 1)
{
a = a + "</i>";
b = "<i>" + b;
}
if (oldText.TrimStart().StartsWith("<b>") && oldText.TrimEnd().EndsWith("</b>") &&
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>-") && (a.EndsWith(".</i>") || a.EndsWith("!</i>") || a.EndsWith("?</i>")) &&
b.StartsWith("<i>-") && (b.EndsWith(".</i>") || b.EndsWith("!</i>") || b.EndsWith("?</i>")))
{
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> "))
originalCurrent.Text = originalCurrent.Text.Remove(3, 1);
if (originalNew.Text.StartsWith("<i> "))
originalCurrent.Text = originalCurrent.Text.Remove(3, 1);
}
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(originalNew);
_subtitleAlternate.Renumber(1);
}
}
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(1);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex);
ShowSource();
ShowStatus(_language.LineSplitted);
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
RefreshSelectedParagraph();
SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex, true);
}
}
示例2: addParagraphHereToolStripMenuItem_Click
private void addParagraphHereToolStripMenuItem_Click(object sender, EventArgs e)
{
audioVisualizer.ClearSelection();
Paragraph newParagraph = new Paragraph(audioVisualizer.NewSelectionParagraph);
if (newParagraph == null)
return;
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;
foreach (Paragraph p in _subtitle.Paragraphs)
{
if (p.StartTime.TotalMilliseconds > newParagraph.StartTime.TotalMilliseconds)
break;
index++;
}
MakeHistoryForUndo(Configuration.Settings.Language.Main.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(1);
}
_subtitleListViewIndex = -1;
_subtitle.Renumber(1);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(index);
textBoxListViewText.Focus();
audioVisualizer.NewSelectionParagraph = null;
ShowStatus(string.Format(_language.VideoControls.NewTextInsertAtX, newParagraph.StartTime.ToShortString()));
audioVisualizer.Invalidate();
}
示例3: InsertAfter
private void InsertAfter()
{
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];
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);
}
}
Paragraph prev = _subtitle.GetParagraphOrDefault(firstSelectedIndex - 1);
Paragraph next = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
if (prev != null)
{
int addMilliseconds = Configuration.Settings.General.MininumMillisecondsBetweenLines;
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)
{
_subtitleAlternate.InsertParagraphInCorrectTimeOrder(new Paragraph(newParagraph));
_subtitleAlternate.Renumber(1);
}
if (_networkSession != null)
{
_networkSession.TimerStop();
NetworkGetSendUpdates(new List<int>(), firstSelectedIndex, newParagraph);
}
else
{
_subtitle.Paragraphs.Insert(firstSelectedIndex, newParagraph);
_subtitle.Renumber(1);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(firstSelectedIndex);
ShowSource();
ShowStatus(_language.LineInserted);
}
示例4: InsertNewTextAtVideoPosition
private Paragraph InsertNewTextAtVideoPosition()
{
// current movie pos
double videoPositionInMilliseconds = mediaPlayer.CurrentPosition * 1000.0;
if (!mediaPlayer.IsPaused)
videoPositionInMilliseconds -= Configuration.Settings.General.SetStartEndHumanDelay;
var tc = new TimeCode(TimeSpan.FromMilliseconds(videoPositionInMilliseconds));
MakeHistoryForUndo(_language.BeforeInsertSubtitleAtVideoPosition + " " + tc.ToString());
// find index where to insert
int index = 0;
foreach (Paragraph p in _subtitle.Paragraphs)
{
if (p.StartTime.TotalMilliseconds > videoPositionInMilliseconds)
break;
index++;
}
// create and insert
var newParagraph = new Paragraph("", 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(1);
}
_subtitleListViewIndex = -1;
_subtitle.Renumber(1);
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
}
SubtitleListview1.SelectIndexAndEnsureVisible(index);
return newParagraph;
}