本文整理汇总了C#中Nikse.SubtitleEdit.Logic.Subtitle.CalculateFrameNumbersFromTimeCodes方法的典型用法代码示例。如果您正苦于以下问题:C# Subtitle.CalculateFrameNumbersFromTimeCodes方法的具体用法?C# Subtitle.CalculateFrameNumbersFromTimeCodes怎么用?C# Subtitle.CalculateFrameNumbersFromTimeCodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.Subtitle
的用法示例。
在下文中一共展示了Subtitle.CalculateFrameNumbersFromTimeCodes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendTextVisuallyToolStripMenuItemClick
private void AppendTextVisuallyToolStripMenuItemClick(object sender, EventArgs e)
{
if (IsSubtitleLoaded)
{
ReloadFromSourceView();
if (MessageBox.Show(_language.SubtitleAppendPrompt, _language.SubtitleAppendPromptTitle, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
{
openFileDialog1.Title = _language.OpenSubtitleToAppend;
openFileDialog1.FileName = string.Empty;
openFileDialog1.Filter = Utilities.GetOpenDialogFilter();
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
bool success = false;
string fileName = openFileDialog1.FileName;
if (File.Exists(fileName))
{
var subtitleToAppend = new Subtitle();
Encoding encoding;
SubtitleFormat format = null;
// do not allow blu-ray/vobsub
string extension = Path.GetExtension(fileName).ToLower();
if (extension == ".sub" && (IsVobSubFile(fileName, false) || IsSpDvdSupFile(fileName)))
{
format = null;
}
else if (extension == ".sup" && IsBluRaySupFile(fileName))
{
format = null;
}
else
{
format = subtitleToAppend.LoadSubtitle(fileName, out encoding, null);
if (GetCurrentSubtitleFormat().IsFrameBased)
subtitleToAppend.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
subtitleToAppend.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
}
if (format != null)
{
if (subtitleToAppend != null && subtitleToAppend.Paragraphs.Count > 1)
{
var visualSync = new VisualSync();
visualSync.Initialize(toolStripButtonVisualSync.Image as Bitmap, subtitleToAppend, _fileName, _language.AppendViaVisualSyncTitle, CurrentFrameRate);
visualSync.ShowDialog(this);
if (visualSync.OKPressed)
{
if (MessageBox.Show(_language.AppendSynchronizedSubtitlePrompt, _language.SubtitleAppendPromptTitle, MessageBoxButtons.YesNo) == DialogResult.Yes)
{
int start = _subtitle.Paragraphs.Count +1;
var fr = CurrentFrameRate;
MakeHistoryForUndo(_language.BeforeAppend);
foreach (Paragraph p in visualSync.Paragraphs)
{
if (format.IsFrameBased)
p.CalculateFrameNumbersFromTimeCodes(fr);
_subtitle.Paragraphs.Add(new Paragraph(p));
}
if (format.GetType() == typeof(AdvancedSubStationAlpha) && GetCurrentSubtitleFormat().GetType() == typeof(AdvancedSubStationAlpha))
{
List<string> currentStyles = new List<string>();
if (_subtitle.Header != null)
currentStyles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
foreach (string styleName in AdvancedSubStationAlpha.GetStylesFromHeader(subtitleToAppend.Header))
{
bool alreadyExists = false;
foreach (string currentStyleName in currentStyles)
{
if (currentStyleName.ToLower().Trim() == styleName.ToLower().Trim())
alreadyExists = true;
}
if (!alreadyExists)
{
var newStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, subtitleToAppend.Header);
_subtitle.Header = AdvancedSubStationAlpha.AddSsaStyle(newStyle, _subtitle.Header);
}
}
}
_subtitle.Renumber(1);
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
// select appended lines
for (int i = start; i < _subtitle.Paragraphs.Count; i++)
SubtitleListview1.Items[i].Selected = true;
SubtitleListview1.EnsureVisible(start);
ShowStatus(string.Format(_language.SubtitleAppendedX, fileName));
success = true;
}
}
visualSync.Dispose();
}
}
}
if (!success)
//.........这里部分代码省略.........
示例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: LoadAlternateSubtitleFile
//.........这里部分代码省略.........
{
pac.BatchMode = true;
pac.LoadSubtitle(_subtitleAlternate, null, fileName);
format = pac;
}
}
if (format == null)
{
var cavena890 = new Cavena890();
if (cavena890.IsMine(null, fileName))
{
cavena890.LoadSubtitle(_subtitleAlternate, null, fileName);
format = cavena890;
}
}
if (format == null)
{
var spt = new Spt();
if (spt.IsMine(null, fileName))
{
spt.LoadSubtitle(_subtitleAlternate, null, fileName);
format = spt;
}
}
if (format == null)
{
var cheetahCaption = new CheetahCaption();
if (cheetahCaption.IsMine(null, fileName))
{
cheetahCaption.LoadSubtitle(_subtitleAlternate, null, fileName);
format = cheetahCaption;
}
}
if (format == null)
{
var capMakerPlus = new CapMakerPlus();
if (capMakerPlus.IsMine(null, fileName))
{
capMakerPlus.LoadSubtitle(_subtitleAlternate, null, fileName);
format = capMakerPlus;
}
}
if (format == null)
{
var captionate = new Captionate();
if (captionate.IsMine(null, fileName))
{
captionate.LoadSubtitle(_subtitleAlternate, null, fileName);
format = captionate;
}
}
if (format == null)
{
var ultech130 = new Ultech130();
if (ultech130.IsMine(null, fileName))
{
ultech130.LoadSubtitle(_subtitleAlternate, null, fileName);
format = ultech130;
}
}
if (format == null)
{
var nciCaption = new NciCaption();
if (nciCaption.IsMine(null, fileName))
{
nciCaption.LoadSubtitle(_subtitleAlternate, null, fileName);
format = nciCaption;
}
}
if (format == null)
{
var tsb4 = new TSB4();
if (tsb4.IsMine(null, fileName))
{
tsb4.LoadSubtitle(_subtitleAlternate, null, fileName);
format = tsb4;
}
}
if (format == null)
{
var avidStl = new AvidStl();
if (avidStl.IsMine(null, fileName))
{
avidStl.LoadSubtitle(_subtitleAlternate, null, fileName);
format = avidStl;
}
}
if (format == null)
return false;
if (format.IsFrameBased)
_subtitleAlternate.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
_subtitleAlternate.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
SetupAlternateEdit();
return true;
}
示例4: 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();
}
}
}
示例5: toolStripMenuItemImportTimeCodes_Click
private void toolStripMenuItemImportTimeCodes_Click(object sender, EventArgs e)
{
if (_subtitle.Paragraphs.Count < 1)
{
MessageBox.Show(_language.NoSubtitleLoaded, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
openFileDialog1.Title = _languageGeneral.OpenSubtitle;
openFileDialog1.FileName = string.Empty;
openFileDialog1.Filter = Utilities.GetOpenDialogFilter();
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
Encoding encoding = null;
Subtitle timeCodeSubtitle = new Subtitle();
SubtitleFormat format = timeCodeSubtitle.LoadSubtitle(openFileDialog1.FileName, out encoding, encoding);
if (format == null)
{
ShowUnknownSubtitle();
return;
}
if (timeCodeSubtitle.Paragraphs.Count != _subtitle.Paragraphs.Count && !string.IsNullOrEmpty(_language.ImportTimeCodesDifferentNumberOfLinesWarning))
{
if (MessageBox.Show(string.Format(_language.ImportTimeCodesDifferentNumberOfLinesWarning, timeCodeSubtitle.Paragraphs.Count, _subtitle.Paragraphs.Count), _title, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
return;
}
MakeHistoryForUndo(_language.BeforeTimeCodeImport);
if (GetCurrentSubtitleFormat().IsFrameBased)
timeCodeSubtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
timeCodeSubtitle.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
int count = 0;
for (int i = 0; i < timeCodeSubtitle.Paragraphs.Count; i++)
{
Paragraph existing = _subtitle.GetParagraphOrDefault(i);
Paragraph newTimeCode = timeCodeSubtitle.GetParagraphOrDefault(i);
if (existing == null || newTimeCode == null)
break;
existing.StartTime.TotalMilliseconds = newTimeCode.StartTime.TotalMilliseconds;
existing.EndTime.TotalMilliseconds = newTimeCode.EndTime.TotalMilliseconds;
existing.StartFrame = newTimeCode.StartFrame;
existing.EndFrame = newTimeCode.EndFrame;
count++;
}
ShowStatus(string.Format(_language.TimeCodeImportedFromXY, Path.GetFileName(openFileDialog1.FileName), count));
SaveSubtitleListviewIndexes();
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndexes();
}
}