本文整理汇总了C#中System.Windows.Forms.RichTextBox.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.RichTextBox.Dispose方法的具体用法?C# System.Windows.Forms.RichTextBox.Dispose怎么用?C# System.Windows.Forms.RichTextBox.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了System.Windows.Forms.RichTextBox.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
string[] arr = null;
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
arr = rtBox.Text.Replace("\r", string.Empty).Split('\n');
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
lines = new List<string>();
foreach (string s in arr)
lines.Add(s);
base.LoadSubtitle(subtitle, lines, fileName);
}
示例2: 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 = Utilities.RemoveHtmlTags(p.Text);
sb.AppendLine(string.Format("{0}\t{1}\t{2}\t", count.ToString().PadLeft(5, ' '), MakeTimeCode(p.StartTime), text));
sb.AppendLine("\t\t\t\t");
Paragraph next = subtitle.GetParagraphOrDefault(i + 1);
if (next == null || Math.Abs(p.EndTime.TotalMilliseconds - next.StartTime.TotalMilliseconds) > 50)
{
count++;
sb.AppendLine(string.Format("{0}\t{1}", count.ToString().PadLeft(5, ' '), MakeTimeCode(p.EndTime)));
}
count++;
}
var rtBox = new System.Windows.Forms.RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例3: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
return;
}
string text = rtBox.Text;
rtBox.Dispose();
LoadF4TextSubtitle(subtitle, text);
}
示例4: ToText
public override string ToText(Subtitle subtitle, string title)
{
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
rtBox.Text = base.ToText(subtitle, title);
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例5: ToText
public override string ToText(Subtitle subtitle, string title)
{
string format = "[{0}]{3}{3}{2}{3}{3}[{1}]{3}";
var sb = new StringBuilder();
foreach (Paragraph p in subtitle.Paragraphs)
{
sb.AppendLine(string.Format(format, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text, Environment.NewLine));
}
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例6: RtfToText
public string RtfToText(string rtf)
{
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
return rtBox.Text;
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("RtfTextConverterRichTextBox.RtfToText: " + exception.Message);
return string.Empty;
}
finally
{
rtBox.Dispose();
}
}
示例7: ToText
public override string ToText(Subtitle subtitle, string title)
{
string format = "{0}: {1} {2} [{3}]";
var sb = new StringBuilder();
int count = 1;
foreach (Paragraph p in subtitle.Paragraphs)
{
sb.AppendLine(string.Format(format, count, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text.Length));
sb.AppendLine(p.Text);
sb.AppendLine();
count++;
}
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例8: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var text = new StringBuilder();
if (lines.Count == 0 || !lines[0].Trim().StartsWith("{\\rtf1"))
return;
// load as text via RichTextBox
foreach (string s in lines)
text.AppendLine(s);
var rtBox = new System.Windows.Forms.RichTextBox();
rtBox.Rtf = text.ToString();
var lines2 = new List<string>();
foreach (string line in rtBox.Lines)
lines2.Add(line);
rtBox.Dispose();
text = new StringBuilder();
var u52 = new UnknownSubtitle52();
u52.LoadSubtitle(subtitle, lines2, fileName);
_errorCount = u52.ErrorCount;
}
示例9: ToText
public override string ToText(Subtitle subtitle, string title)
{
var sb = new StringBuilder();
sb.AppendLine(@"0 2 1.0 1.0 3.0 048 0400 0040 0500 100 100 0 100 0 6600 6600 01
CRULIC R1
ST 0 EB 3.10
@");
int index = 0;
foreach (Paragraph p in subtitle.Paragraphs)
{
//1 00:50:34:22 00:50:39:13
//Ich muss dafür sorgen,
//dass die Epsteins weiterleben
index++;
sb.AppendLine(string.Format("* {0}-{1} 00.00 00.0 1 {2} 00 16-090-090{3}{4}{3}@", EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), index.ToString().PadLeft(4, '0'), Environment.NewLine, Utilities.RemoveHtmlTags(p.Text)));
}
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例10: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
string text = string.Empty;
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
text = rtBox.Text.Replace("\r\n", "\n");
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
lines = new List<string>();
foreach (string line in text.Split('\n'))
lines.Add(line);
_errorCount = 0;
Paragraph p = null;
sb = new StringBuilder();
foreach (string line in lines)
{
string s = line.TrimEnd();
if (RegexTimeCode1.IsMatch(s))
{
try
{
if (p != null)
{
p.Text = sb.ToString().Trim();
subtitle.Paragraphs.Add(p);
}
sb = new StringBuilder();
string[] arr = s.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 3)
p = new Paragraph(DecodeTimeCode(arr[1]), DecodeTimeCode(arr[2]), string.Empty);
}
catch
{
_errorCount++;
p = null;
}
}
else if (p != null && s.Length > 0)
{
sb.AppendLine(s.Trim());
}
else if (s.Trim().Length > 0)
{
_errorCount++;
}
}
if (p != null)
{
p.Text = sb.ToString().Trim();
subtitle.Paragraphs.Add(p);
}
subtitle.Renumber(1);
}
示例11: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
string[] arr = null;
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
arr = rtBox.Text.Replace("\r", "").Split('\n');
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
var p = new Paragraph();
subtitle.Paragraphs.Clear();
foreach (string line in arr)
{
string s = line.Trim();
if (s.StartsWith('[') && s.EndsWith('>') && s.Length > 13 && s[12] == ']')
s = s.Substring(0, 13);
var match = regexTimeCodes.Match(s);
if (match.Success)
{
string[] parts = s.Replace("[", string.Empty).Replace("]", string.Empty).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 1)
{
try
{
if (!string.IsNullOrEmpty(p.Text))
{
p.EndTime = DecodeTimeCode(parts[0]);
subtitle.Paragraphs.Add(p);
p = new Paragraph();
}
else
{
p.StartTime = DecodeTimeCode(parts[0]);
}
}
catch (Exception exception)
{
_errorCount++;
System.Diagnostics.Debug.WriteLine(exception.Message);
}
}
}
else if (string.IsNullOrWhiteSpace(line))
{
}
else
{
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();
}
示例12: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
string text = string.Empty;
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
text = rtBox.Text.Replace("\r\n", "\n");
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
lines = new List<string>();
foreach (string line in text.Split('\n'))
lines.Add(line);
_errorCount = 0;
Paragraph p = null;
foreach (string line in lines)
{
string s = line.TrimEnd();
if (RegexTimeCode1.IsMatch(s))
{
try
{
if (p != null)
subtitle.Paragraphs.Add(p);
string[] arr = s.Split('\t');
if (arr.Length > 2)
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), arr[2].Trim());
else
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), string.Empty);
}
catch
{
_errorCount++;
p = null;
}
}
else if (s.StartsWith("\t\t"))
{
if (p != null)
p.Text = p.Text + Environment.NewLine + s.Trim();
}
else if (s.Trim().Length > 0)
{
_errorCount++;
}
}
if (p != null)
subtitle.Paragraphs.Add(p);
for (int j = 0; j < subtitle.Paragraphs.Count - 1; j++)
{
p = subtitle.Paragraphs[j];
Paragraph next = subtitle.Paragraphs[j + 1];
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MininumMillisecondsBetweenLines;
}
if (subtitle.Paragraphs.Count > 0)
{
p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
}
subtitle.RemoveEmptyLines();
subtitle.Renumber(1);
}
示例13: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
string[] arr = null;
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = rtf;
arr = rtBox.Text.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
bool expectStartTime = true;
var p = new Paragraph();
subtitle.Paragraphs.Clear();
foreach (string line in arr)
{
string s = line.Trim().Replace("*", string.Empty);
var match = regexTimeCodes.Match(s);
if (match.Success)
{
string[] parts = s.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 4)
{
try
{
if (!string.IsNullOrEmpty(p.Text))
{
subtitle.Paragraphs.Add(p);
p = new Paragraph();
}
p.StartTime = DecodeTimeCode(parts[1]);
p.EndTime = DecodeTimeCode(parts[2]);
expectStartTime = false;
}
catch (Exception exception)
{
_errorCount++;
System.Diagnostics.Debug.WriteLine(exception.Message);
}
}
}
else if (line.Trim().Length == 0)
{
if (p != null)
{
if (p.StartTime.TotalMilliseconds == 0 && p.EndTime.TotalMilliseconds == 0)
_errorCount++;
else
subtitle.Paragraphs.Add(p);
p = new Paragraph();
}
}
else if (line.Trim().Length > 0 && !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(1);
}
示例14: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
foreach (string line in lines)
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
return;
System.Windows.Forms.RichTextBox rtBox = null;
try
{
rtBox = new System.Windows.Forms.RichTextBox
{
Rtf = rtf
};
lines = new List<string>(rtBox.Text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None));
}
catch (ArgumentException)
{
// Invalid format
return;
}
finally
{
if (rtBox != null)
{
rtBox.Dispose();
}
}
_errorCount = 0;
Paragraph p = null;
foreach (string line in lines)
{
string s = line.TrimEnd();
if (RegexTimeCode1.IsMatch(s))
{
try
{
if (p != null)
subtitle.Paragraphs.Add(p);
string[] arr = s.Split('\t');
if (arr.Length > 2)
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), arr[2].Trim());
else
p = new Paragraph(DecodeTimeCode(arr[1]), new TimeCode(0, 0, 0, 0), string.Empty);
}
catch
{
_errorCount++;
p = null;
}
}
else if (s.StartsWith("\t\t"))
{
if (p != null)
p.Text = p.Text + Environment.NewLine + s.Trim();
}
else if (!string.IsNullOrWhiteSpace(s))
{
_errorCount++;
}
}
if (p != null)
subtitle.Paragraphs.Add(p);
for (int j = 0; j < subtitle.Paragraphs.Count - 1; j++)
{
p = subtitle.Paragraphs[j];
Paragraph next = subtitle.Paragraphs[j + 1];
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
}
if (subtitle.Paragraphs.Count > 0)
{
p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1];
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text);
}
subtitle.RemoveEmptyLines();
subtitle.Renumber();
}
示例15: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int i = 128;
Paragraph last = null;
while (i < buffer.Length - 20)
{
if (buffer[i] == 0x0b)
{
string timeCode = Encoding.ASCII.GetString(buffer, i + 1, 11);
if (timeCode != "00:00:00:00" && regexTimeCodes.IsMatch(timeCode))
{
var p = new Paragraph();
p.StartTime = DecodeTimeCode(timeCode.Split(':'));
bool italic = buffer[i + 22] == 3; // 3=italic, 1=normal
int textStart = i + 25; // text starts 25 chars after time code
int textLength = 0;
while (textStart + textLength < buffer.Length && buffer[textStart + textLength] != 0)
{
textLength++;
}
if (textLength > 0)
{
p.Text = Encoding.GetEncoding(1252).GetString(buffer, textStart, textLength);
int rtIndex = p.Text.IndexOf("{\\rtf1", StringComparison.Ordinal);
if (rtIndex >= 0 && rtIndex < 10)
{
var rtBox = new System.Windows.Forms.RichTextBox();
try
{
rtBox.Rtf = p.Text.Substring(rtIndex);
p.Text = rtBox.Text;
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
}
rtBox.Dispose();
}
else if (italic)
{
p.Text = "<i>" + p.Text + "</i>";
}
}
else
{
p.Text = string.Empty;
}
last = p;
subtitle.Paragraphs.Add(p);
}
}
i++;
}
if (last != null)
last.EndTime.TotalMilliseconds = last.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(last.Text);
for (i = 0; i < subtitle.Paragraphs.Count - 1; i++)
{
subtitle.Paragraphs[i].EndTime.TotalMilliseconds = subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds;
}
for (i = subtitle.Paragraphs.Count - 1; i >= 0; i--)
{
if (string.IsNullOrEmpty(subtitle.Paragraphs[i].Text))
subtitle.Paragraphs.RemoveAt(i);
}
var deletes = new List<int>();
for (i = 0; i < subtitle.Paragraphs.Count - 1; i++)
{
if (subtitle.Paragraphs[i].StartTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds)
{
subtitle.Paragraphs[i].Text += Environment.NewLine + subtitle.Paragraphs[i + 1].Text;
subtitle.Paragraphs[i].EndTime = subtitle.Paragraphs[i + 1].EndTime;
deletes.Add(i + 1);
}
}
deletes.Reverse();
foreach (int index in deletes)
{
subtitle.Paragraphs.RemoveAt(index);
}
for (i = 0; i < subtitle.Paragraphs.Count - 1; i++)
{
if (subtitle.Paragraphs[i].StartTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds)
{
}
else if (subtitle.Paragraphs[i].EndTime.TotalMilliseconds == subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds)
{
subtitle.Paragraphs[i].EndTime.TotalMilliseconds = subtitle.Paragraphs[i + 1].StartTime.TotalMilliseconds - 1;
}
}
subtitle.Renumber();
// adjust all times
if (buffer.Length > 1364)
//.........这里部分代码省略.........