本文整理汇总了C#中Paragraph类的典型用法代码示例。如果您正苦于以下问题:C# Paragraph类的具体用法?C# Paragraph怎么用?C# Paragraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Paragraph类属于命名空间,在下文中一共展示了Paragraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WriteSubtitleBlock
public static void WriteSubtitleBlock(FileStream fs, Paragraph p, int number)
{
fs.WriteByte(0);
fs.WriteByte((byte)(number % 256)); // number - low byte
fs.WriteByte((byte)(number / 256)); // number - high byte
fs.WriteByte(0xff);
fs.WriteByte(0);
WriteTimeCode(fs, p.StartTime);
WriteTimeCode(fs, p.EndTime);
fs.WriteByte(1);
fs.WriteByte(2);
fs.WriteByte(0);
var buffer = Encoding.GetEncoding(1252).GetBytes(p.Text.Replace(Environment.NewLine, "Š"));
if (buffer.Length <= 128)
{
fs.Write(buffer, 0, buffer.Length);
for (int i = buffer.Length; i < TextLength; i++)
{
fs.WriteByte(0x8f);
}
}
else
{
for (int i = 0; i < TextLength; i++)
{
fs.WriteByte(buffer[i]);
}
}
}
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:29,代码来源:AvidStl.cs
示例2: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
//00:03:15:22 00:03:23:10 This is line one.
//This is line two.
subtitle.Paragraphs.Clear();
_errorCount = 0;
foreach (string line in lines)
{
if (RegexTimeCodes.IsMatch(line))
{
string temp = line.Substring(0, RegexTimeCodes.Match(line).Length);
string start = temp.Substring(0, 11);
string end = temp.Substring(12, 11);
string[] startParts = start.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
string[] endParts = end.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
string text = line.Remove(0, RegexTimeCodes.Match(line).Length - 1).Trim();
text = text.Replace("//", Environment.NewLine);
var p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
subtitle.Paragraphs.Add(p);
}
}
else
{
_errorCount += 10;
}
}
subtitle.Renumber();
}
开发者ID:YangEunYong,项目名称:subtitleedit,代码行数:32,代码来源:DvdSubtitleSystem.cs
示例3: Add
/// <summary>
/// Add a new paragraph.
/// </summary>
protected void Add(string text, bool updateVisible)
{
Paragraph ce = null;
if (mParagraphs.Count < maxEntries)
{
ce = new Paragraph();
}
else
{
ce = mParagraphs[0];
mParagraphs.RemoveAt(0);
}
ce.text = text;
mParagraphs.Add(ce);
if (textLabel != null && textLabel.font != null)
{
// Rebuild the line
ce.lines = textLabel.font.WrapText(ce.text, maxWidth / textLabel.transform.localScale.y, true, true).Split(mSeparator);
// Recalculate the total number of lines
mTotalLines = 0;
foreach (Paragraph p in mParagraphs) mTotalLines += p.lines.Length;
}
// Update the visible text
if (updateVisible) UpdateVisibleText();
}
开发者ID:light17,项目名称:Thunder,代码行数:33,代码来源:UITextList.cs
示例4: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
var s = line.Trim();
if (s.Length > 35 && RegexTimeCodes.IsMatch(s))
{
try
{
string timePart = s.Substring(4, 10).TrimEnd();
var start = DecodeTimeCode(timePart);
timePart = s.Substring(15, 10).Trim();
var end = DecodeTimeCode(timePart);
var paragraph = new Paragraph { StartTime = start, EndTime = end };
paragraph.Text = s.Substring(38).Replace(" \\n ", Environment.NewLine).Replace("\\n", Environment.NewLine);
subtitle.Paragraphs.Add(paragraph);
}
catch
{
_errorCount++;
}
}
}
subtitle.Renumber();
}
开发者ID:LeonCheung,项目名称:subtitleedit,代码行数:27,代码来源:ZeroG.cs
示例5: Add
/// <summary>
/// Add a new paragraph.
/// </summary>
protected void Add (string text, bool updateVisible)
{
Paragraph ce = null;
if (mParagraphs.Count < maxEntries)
{
ce = new Paragraph();
}
else
{
ce = mParagraphs[0];
mParagraphs.RemoveAt(0);
}
ce.text = text;
mParagraphs.Add(ce);
if (textLabel != null && textLabel.font != null)
{
// Rebuild the line
Vector3 scale = textLabel.transform.localScale;
string line;
textLabel.font.WrapText(ce.text, out line, maxWidth / scale.x, maxHeight / scale.y,
textLabel.maxLineCount, textLabel.supportEncoding, textLabel.symbolStyle);
ce.lines = line.Split(mSeparator);
// Recalculate the total number of lines
mTotalLines = 0;
for (int i = 0, imax = mParagraphs.Count; i < imax; ++i) mTotalLines += mParagraphs[i].lines.Length;
}
// Update the visible text
if (updateVisible) UpdateVisibleText();
}
开发者ID:Burnknee,项目名称:IpadApp,代码行数:38,代码来源:UITextList.cs
示例6: GenerateParagraphWithHyperLink
/// <summary>
/// Generates a hyperlink and embed it
/// in a paragraph tag
/// </summary>
/// <param name="mainDocPart">The main doc part.</param>
/// <param name="hyperLink">The hyper link.</param>
/// <returns></returns>
public static Paragraph GenerateParagraphWithHyperLink(MainDocumentPart mainDocPart, String hyperLink)
{
//this will be display as
//the text
String urlLabel = hyperLink;
//build the hyperlink
//file:// ensure that document does not corrupt
System.Uri uri = new Uri(@"file://" + hyperLink);
//add it to the document
HyperlinkRelationship rel = mainDocPart.AddHyperlinkRelationship(uri, true);
//get the hyperlink id
string relationshipId = rel.Id;
//create the new paragraph tag
Paragraph newParagraph = new Paragraph(
new DocumentFormat.OpenXml.Wordprocessing.Hyperlink(
new ProofError() { Type = ProofingErrorValues.GrammarStart },
new DocumentFormat.OpenXml.Wordprocessing.Run(
new DocumentFormat.OpenXml.Wordprocessing.RunProperties(
new RunStyle() { Val = "Hyperlink" }),
new DocumentFormat.OpenXml.Wordprocessing.Text(urlLabel)
)) { History = OnOffValue.FromBoolean(true), Id = relationshipId });
return newParagraph;
}
开发者ID:shaanino,项目名称:dmt,代码行数:35,代码来源:OpenXmlHelpers.cs
示例7: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
Paragraph p = null;
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
if (regexTimeCodes.IsMatch(line))
{
p = new Paragraph(DecodeTimeCode(line), new TimeCode(0,0,0,0), string.Empty);
subtitle.Paragraphs.Add(p);
}
else if (line.Trim().Length == 0)
{
// skip these lines
}
else if (line.Trim().Length > 0 && p != null)
{
if (string.IsNullOrEmpty(p.Text))
p.Text = line;
else
p.Text = p.Text + Environment.NewLine + line;
}
}
foreach (Paragraph p2 in subtitle.Paragraphs)
{
p2.Text = Utilities.AutoBreakLine(p2.Text);
}
subtitle.RecalculateDisplayTimes(Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds, null);
subtitle.Renumber(1);
}
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:31,代码来源:YouTubeTranscript.cs
示例8: ToText
public override string ToText(Subtitle subtitle, string title)
{
//TIMEIN: 01:00:01:09 DURATION: 01:20 TIMEOUT: --:--:--:--
//Broadcasting
//from an undisclosed location...
//TIMEIN: 01:00:04:12 DURATION: 04:25 TIMEOUT: 01:00:09:07
const string paragraphWriteFormat = "TIMEIN: {0}\tDURATION: {1}\tTIMEOUT: {2}\r\n{3}\r\n";
var sb = new StringBuilder();
foreach (Paragraph p in subtitle.Paragraphs)
{
// to avoid rounding errors in duration
var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds);
var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds);
var durationCalc = new Paragraph(
new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)),
new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)),
string.Empty);
string startTime = string.Format("{0:00}:{1:00}:{2:00}:{3:00}", p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, startFrame);
string timeOut = string.Format("{0:00}:{1:00}:{2:00}:{3:00}", p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, endFrame);
string timeDuration = string.Format("{0:00}:{1:00}", durationCalc.Duration.Seconds, MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds));
sb.AppendLine(string.Format(paragraphWriteFormat, startTime, timeDuration, timeOut, p.Text));
}
return sb.ToString().Trim();
}
开发者ID:YangEunYong,项目名称:subtitleedit,代码行数:28,代码来源:SwiftText.cs
示例9: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
//00:01:54:19,00:01:56:17,We should be thankful|they accepted our offer.
_errorCount = 0;
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
if (line.IndexOf(':') == 2 && RegexTimeCodes.IsMatch(line))
{
string start = line.Substring(0, 11);
string end = line.Substring(13, 11);
try
{
var startTime = DecodeTimeCodeFramesFourParts(start.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries));
var endTime = DecodeTimeCodeFramesFourParts(end.Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries));
var p = new Paragraph(startTime, endTime, DecodeText(line.Substring(25).Trim()));
subtitle.Paragraphs.Add(p);
}
catch
{
_errorCount++;
}
}
else if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("//", StringComparison.Ordinal) && !line.StartsWith('$'))
{
_errorCount++;
}
}
subtitle.Renumber();
}
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:31,代码来源:SpruceWithSpace.cs
示例10: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
int number = 0;
foreach (string line in lines)
{
if (!string.IsNullOrWhiteSpace(line) && line[0] != '$')
{
if (RegexTimeCodes.Match(line).Success)
{
string[] threePart = line.Split(new[] { "\t,\t" }, StringSplitOptions.None);
var p = new Paragraph();
if (threePart.Length == 3 &&
GetTimeCode(p.StartTime, threePart[0]) &&
GetTimeCode(p.EndTime, threePart[1]))
{
number++;
p.Number = number;
p.Text = threePart[2].TrimEnd().Replace(" | ", Environment.NewLine).Replace("|", Environment.NewLine);
p.Text = DecodeStyles(p.Text);
subtitle.Paragraphs.Add(p);
}
}
else
{
_errorCount++;
}
}
}
}
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:30,代码来源:DvdStudioPro.cs
示例11: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
//0001 : 01:07:25:08,01:07:29:00,10
_errorCount = 0;
Paragraph p = null;
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
if (line.IndexOf(':') == 5 && RegexTimeCodes.IsMatch(line))
{
if (p != null)
subtitle.Paragraphs.Add(p);
string start = line.Substring(7, 11);
string end = line.Substring(19, 11);
string[] startParts = start.Split(SplitCharColon);
string[] endParts = end.Split(SplitCharColon);
if (startParts.Length == 4 && endParts.Length == 4)
{
p = new Paragraph(DecodeTimeCodeFramesFourParts(startParts), DecodeTimeCodeFramesFourParts(endParts), string.Empty);
}
}
else if (p != null && RegexText.IsMatch(line))
{
if (string.IsNullOrEmpty(p.Text))
p.Text = line.Substring(5).Trim();
else
p.Text += Environment.NewLine + line.Substring(5).Trim();
}
else if (line.Length < 10 && RegexSomeCodes.IsMatch(line))
{
}
else if (string.IsNullOrWhiteSpace(line))
{
// skip these lines
}
else if (p != null)
{
if (p.Text != null && Utilities.GetNumberOfLines(p.Text) > 3)
{
_errorCount++;
}
else
{
if (!line.TrimEnd().EndsWith(": --:--:--:--,--:--:--:--,-1", StringComparison.Ordinal))
{
if (string.IsNullOrEmpty(p.Text))
p.Text = line.Trim();
else
p.Text += Environment.NewLine + line.Trim();
}
}
}
}
if (p != null && !string.IsNullOrEmpty(p.Text))
subtitle.Paragraphs.Add(p);
subtitle.Renumber();
}
开发者ID:ARASHz4,项目名称:subtitleedit,代码行数:60,代码来源:StructuredTitles.cs
示例12: NewParagraph
public Paragraph NewParagraph()
{
Paragraph p = new Paragraph();
if (this.DefaultParagraphStyle != null)
p.InsertInProperties(new ParagraphStyleId() { Val = this.DefaultParagraphStyle });
return p;
}
开发者ID:TimNFL,项目名称:PEACReportsDemo,代码行数:7,代码来源:ParagraphStyleCollection.cs
示例13: ToText
public override string ToText(Subtitle subtitle, string title)
{
var sb = new StringBuilder();
sb.AppendLine("#\tAppearance\tCaption\t");
sb.AppendLine();
int count = 1;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
string text = HtmlUtil.RemoveHtmlTags(p.Text);
// to avoid rounding errors in duration
var startFrame = MillisecondsToFramesMaxFrameRate(p.StartTime.Milliseconds);
var endFrame = MillisecondsToFramesMaxFrameRate(p.EndTime.Milliseconds);
var durationCalc = new Paragraph(
new TimeCode(p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, FramesToMillisecondsMax999(startFrame)),
new TimeCode(p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, FramesToMillisecondsMax999(endFrame)),
string.Empty);
sb.AppendLine(string.Format("{0}\t{1}\t{2:00}:{3:00}\t{4}\r\n{5}\r\n", count, MakeTimeCode(p.StartTime), durationCalc.Duration.Seconds, MillisecondsToFramesMaxFrameRate(durationCalc.Duration.Milliseconds), MakeTimeCode(p.EndTime), text));
count++;
}
return sb.ToString();
}
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:25,代码来源:UnknownSubtitle22.cs
示例14: ParagraphEventArgs
public ParagraphEventArgs(double seconds, Paragraph p, Paragraph b, MouseDownParagraphType mouseDownParagraphType)
{
Seconds = seconds;
Paragraph = p;
BeforeParagraph = b;
MouseDownParagraphType = mouseDownParagraphType;
}
开发者ID:m1croN,项目名称:subtitleedit,代码行数:7,代码来源:AudioVisualizer.cs
示例15: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
var paragraph = new Paragraph();
_errorCount = 0;
subtitle.Paragraphs.Clear();
foreach (string line in lines)
{
if (regexTimeCode.IsMatch(line) && line.Length > 24)
{
string[] parts = line.Substring(0, 11).Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
try
{
var start = DecodeTimeCode(parts);
parts = line.Substring(12, 11).Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
var end = DecodeTimeCode(parts);
paragraph = new Paragraph();
paragraph.StartTime = start;
paragraph.EndTime = end;
paragraph.Text = line.Substring(24).Trim().Replace("\t", Environment.NewLine);
subtitle.Paragraphs.Add(paragraph);
}
catch
{
_errorCount++;
}
}
}
}
subtitle.Renumber(1);
}
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:34,代码来源:DigiBeta.cs
示例16: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
//<a class="caption" starttime="0" duration="16000">[♪techno music♪]</a>
StringBuilder temp = new StringBuilder();
foreach (string l in lines)
temp.Append(l);
string all = temp.ToString();
if (!all.Contains("class=\"caption\""))
return;
Paragraph paragraph = new Paragraph();
_errorCount = 0;
subtitle.Paragraphs.Clear();
for (int i = 0; i < lines.Count; i++)
{
string line = lines[i].Trim();
int indexOfStart = line.IndexOf("starttime=");
int indexOfDuration = line.IndexOf("duration=");
if (line.Contains("class=\"caption\"") && indexOfStart > 0 && indexOfDuration > 0)
{
string startTime = "0";
int index = indexOfStart +10;
while (index < line.Length && "0123456789\"'.,".Contains(line[index].ToString()))
{
if ("0123456789,.".Contains(line[index].ToString()))
startTime += line[index].ToString();
index++;
}
string duration = "0";
index = indexOfDuration + 9;
while (index < line.Length && "0123456789\"'.,".Contains(line[index].ToString()))
{
if ("0123456789,.".Contains(line[index].ToString()))
duration += line[index].ToString();
index++;
}
string text = string.Empty;
index = line.IndexOf(">", indexOfDuration);
if (index > 0 && index+ 1 < line.Length)
{
text = line.Substring(index + 1).Trim();
index = text.IndexOf("</");
if (index > 0)
text = text.Substring(0, index);
text = text.Replace("<br />", Environment.NewLine);
}
int startMilliseconds;
int durationMilliseconds;
if (text.Length > 0 && int.TryParse(startTime, out startMilliseconds) && int.TryParse(duration, out durationMilliseconds))
subtitle.Paragraphs.Add(new Paragraph(text, startMilliseconds, startMilliseconds + durationMilliseconds));
}
}
subtitle.Renumber(1);
}
开发者ID:IlgnerBri,项目名称:subtitleedit,代码行数:60,代码来源:UnknownSubtitle9.cs
示例17: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
bool expectStartTime = true;
var p = new Paragraph();
subtitle.Paragraphs.Clear();
char[] splitChar = { ':' };
foreach (string line in lines)
{
string s = line.Trim().Replace("*", string.Empty);
var match = RegexTimeCodes.Match(s);
if (match.Success)
{
string[] parts = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
try
{
if (!string.IsNullOrEmpty(p.Text))
{
subtitle.Paragraphs.Add(p);
p = new Paragraph();
}
p.StartTime = DecodeTimeCode(parts[1], splitChar);
p.EndTime = DecodeTimeCode(parts[2], splitChar);
expectStartTime = false;
}
catch (Exception exception)
{
_errorCount++;
System.Diagnostics.Debug.WriteLine(exception.Message);
}
}
}
else if (string.IsNullOrWhiteSpace(line))
{
if (p.StartTime.TotalMilliseconds == 0 && p.EndTime.TotalMilliseconds == 0)
_errorCount++;
else
subtitle.Paragraphs.Add(p);
p = new Paragraph();
}
else if (!expectStartTime)
{
p.Text = (p.Text + Environment.NewLine + line).Trim();
if (p.Text.Length > 500)
{
_errorCount += 10;
return;
}
while (p.Text.Contains(Environment.NewLine + " "))
p.Text = p.Text.Replace(Environment.NewLine + " ", Environment.NewLine);
}
}
if (!string.IsNullOrEmpty(p.Text))
subtitle.Paragraphs.Add(p);
subtitle.RemoveEmptyLines();
subtitle.Renumber();
}
开发者ID:YangEunYong,项目名称:subtitleedit,代码行数:60,代码来源:UnknownSubtitle66.cs
示例18: MakeTimeCode
private static string MakeTimeCode(TimeCode timeCode, Paragraph last)
{
double start = 0;
if (last != null)
start = last.EndTime.TotalSeconds;
return string.Format("{0:0.0#}", (timeCode.TotalSeconds - start));
}
开发者ID:athikan,项目名称:subtitleedit,代码行数:7,代码来源:UnknownSubtitle25.cs
示例19: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
//<Time begin="0:03:24.8" end="0:03:29.4" /><clear/>Man stjæler ikke fra Chavo, nej.
subtitle.Paragraphs.Clear();
_errorCount = 0;
foreach (string line in lines)
{
try
{
if (line.Contains("<Time ") && line.Contains(" begin=") && line.Contains("end="))
{
int indexOfBegin = line.IndexOf(" begin=", StringComparison.Ordinal);
int indexOfEnd = line.IndexOf(" end=", StringComparison.Ordinal);
string begin = line.Substring(indexOfBegin + 7, 11);
string end = line.Substring(indexOfEnd + 5, 11);
string[] startParts = begin.Split(new[] { ':', '.', '"' }, StringSplitOptions.RemoveEmptyEntries);
string[] endParts = end.Split(new[] { ':', '.', '"' }, StringSplitOptions.RemoveEmptyEntries);
if (startParts.Length == 4 && endParts.Length == 4)
{
string text = line.Substring(line.LastIndexOf("/>", StringComparison.Ordinal) + 2);
var p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
subtitle.Paragraphs.Add(p);
}
}
}
catch
{
_errorCount++;
}
}
subtitle.Renumber();
}
开发者ID:lalberto8085,项目名称:subtitleedit,代码行数:34,代码来源:RealTime.cs
示例20: DrawParagraph
private static void DrawParagraph(Graphics grph, Paragraph para)
{
foreach (TextLine line in para.Lines)
DrawTextLine(grph, line);
para.Draw(grph);
}
开发者ID:mjmoura,项目名称:tesseractdotnet,代码行数:7,代码来源:Program.cs
注:本文中的Paragraph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论