本文整理汇总了C#中Subtitle.CalculateFrameNumbersFromTimeCodes方法的典型用法代码示例。如果您正苦于以下问题:C# Subtitle.CalculateFrameNumbersFromTimeCodes方法的具体用法?C# Subtitle.CalculateFrameNumbersFromTimeCodes怎么用?C# Subtitle.CalculateFrameNumbersFromTimeCodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subtitle
的用法示例。
在下文中一共展示了Subtitle.CalculateFrameNumbersFromTimeCodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToText
public override string ToText(Subtitle subtitle, string title)
{
//1.
//8.03
//10.06
//- Labai aèiû.
//- Jûs rimtai?
//2.
//16.00
//19.06
//Kaip reikalai ðunø grobimo versle?
const string paragraphWriteFormat = "{0} {1} 1 1 0\r\n{2}";
var sb = new StringBuilder();
sb.AppendLine(@"ý Smart Titl Editor / Smart Titler (A)(C)1992-2001. Dragutin Nikolic
ý Serial No: XXXXXXXXXXXXXX
ý Korisnik: Prava i Prevodi - prevodioci
ý
ý KONFIGURACIONI PODACI
ý Dozvoljeno slova u redu: 30
ý Vremenska korekcija: 1.0000000000E+00
ý Radjeno vremenskih korekcija: TRUE
ý Slovni raspored ASCIR
ý
ý Kraj info blocka.");
sb.AppendLine();
int count = 0;
if (!subtitle.WasLoadedWithFrameNumbers)
subtitle.CalculateFrameNumbersFromTimeCodes(Configuration.Settings.General.CurrentFrameRate);
foreach (Paragraph p in subtitle.Paragraphs)
{
count++;
string text = Utilities.RemoveHtmlFontTag(p.Text);
sb.AppendLine(string.Format(paragraphWriteFormat, p.StartFrame, p.EndFrame, text));
}
return sb.ToString().Trim();
}
示例2: AppendTextVisuallyToolStripMenuItemClick
private void AppendTextVisuallyToolStripMenuItemClick(object sender, EventArgs e)
{
if (!IsSubtitleLoaded)
{
DisplaySubtitleNotLoadedMessage();
return;
}
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();
SubtitleFormat format = null;
// do not allow blu-ray/vobsub
string extension = Path.GetExtension(fileName).ToLowerInvariant();
if (extension == ".sub" && (IsVobSubFile(fileName, false) || FileUtil.IsSpDvdSup(fileName)))
{
format = null;
}
else if (extension == ".sup" && FileUtil.IsBluRaySup(fileName))
{
format = null;
}
else
{
Encoding encoding;
format = subtitleToAppend.LoadSubtitle(fileName, out encoding, null);
if (GetCurrentSubtitleFormat().IsFrameBased)
subtitleToAppend.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
else
subtitleToAppend.CalculateFrameNumbersFromTimeCodes(CurrentFrameRate);
}
if (format != null && subtitleToAppend.Paragraphs.Count > 1)
{
using (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 (var 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))
{
var currentStyles = new List<string>();
if (_subtitle.Header != null)
currentStyles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
foreach (var styleName in AdvancedSubStationAlpha.GetStylesFromHeader(subtitleToAppend.Header))
{
bool alreadyExists = false;
foreach (var currentStyleName in currentStyles)
{
if (currentStyleName.Trim().Equals(styleName.Trim(), StringComparison.OrdinalIgnoreCase))
alreadyExists = true;
}
if (!alreadyExists)
{
var newStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, subtitleToAppend.Header);
_subtitle.Header = AdvancedSubStationAlpha.AddSsaStyle(newStyle, _subtitle.Header);
}
}
}
_subtitle.Renumber();
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;
}
}
}
}
//.........这里部分代码省略.........
示例3: 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
{
var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName);
if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
return;
}
Encoding encoding;
var tmp = new Subtitle();
SubtitleFormat format = tmp.LoadSubtitle(openFileDialog1.FileName, out encoding, null);
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();
}
}
}
示例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
{
var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, openFileDialog1.FileName);
if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
return;
}
MakeHistoryForUndo(string.Format(_language.BeforeInsertLine, openFileDialog1.FileName));
Encoding encoding;
var subtitle = new Subtitle();
SubtitleFormat format = subtitle.LoadSubtitle(openFileDialog1.FileName, out encoding, null);
if (format != null)
{
SaveSubtitleListviewIndices();
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 (var 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;
var current = _subtitle.GetParagraphOrDefault(index);
if (current != null)
{
var original = Utilities.GetOriginalParagraph(index, current, _subtitleAlternate.Paragraphs);
if (original != null)
{
index = _subtitleAlternate.GetIndex(original);
foreach (var p in subtitle.Paragraphs)
{
_subtitleAlternate.Paragraphs.Insert(index, new Paragraph(p));
index++;
}
if (subtitle.Paragraphs.Count > 0)
_subtitleAlternate.Renumber();
}
}
}
_subtitle.Renumber();
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndices();
}
}
}
示例5: LoadAlternateSubtitleFile
//.........这里部分代码省略.........
if (pac.IsMine(null, fileName))
{
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;
}
示例6: toolStripMenuItemImportTimeCodes_Click
private void toolStripMenuItemImportTimeCodes_Click(object sender, EventArgs e)
{
if (_subtitle.Paragraphs.Count < 1)
{
DisplaySubtitleNotLoadedMessage();
return;
}
openFileDialog1.Title = _languageGeneral.OpenSubtitle;
openFileDialog1.FileName = string.Empty;
openFileDialog1.Filter = Utilities.GetOpenDialogFilter();
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
Encoding encoding;
var timeCodeSubtitle = new Subtitle();
SubtitleFormat format = timeCodeSubtitle.LoadSubtitle(openFileDialog1.FileName, out encoding, null);
if (format == null)
{
ShowUnknownSubtitle();
return;
}
if (timeCodeSubtitle.Paragraphs.Count != _subtitle.Paragraphs.Count)
{
var text = string.Format(_language.ImportTimeCodesDifferentNumberOfLinesWarning, timeCodeSubtitle.Paragraphs.Count, _subtitle.Paragraphs.Count);
if (MessageBox.Show(this, text, _title, MessageBoxButtons.YesNo) == 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++)
{
var existing = _subtitle.GetParagraphOrDefault(i);
var 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));
SaveSubtitleListviewIndices();
ShowSource();
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
RestoreSubtitleListviewIndices();
}
}