本文整理汇总了C#中System.Windows.Forms.RichTextBox.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Dispose方法的具体用法?C# RichTextBox.Dispose怎么用?C# RichTextBox.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
this._errorCount = 0;
StringBuilder sb = new StringBuilder();
foreach (string line in lines)
{
sb.AppendLine(line);
}
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
{
return;
}
RichTextBox rtBox = new RichTextBox();
try
{
rtBox.Rtf = rtf;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return;
}
string text = rtBox.Text;
rtBox.Dispose();
this.LoadF4TextSubtitle(subtitle, text);
}
示例2: ToText
public override string ToText(Subtitle subtitle, string title)
{
StringBuilder 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);
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++;
}
RichTextBox rtBox = new RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例3: ToText
public override string ToText(Subtitle subtitle, string title)
{
RichTextBox rtBox = new RichTextBox();
rtBox.Text = base.ToText(subtitle, title);
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例4: ToText
public override string ToText(Subtitle subtitle, string title)
{
const string format = "[{0}]{3}{3}{2}{3}{3}[{1}]{3}";
StringBuilder sb = new StringBuilder();
foreach (Paragraph p in subtitle.Paragraphs)
{
sb.AppendLine(string.Format(format, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), p.Text, Environment.NewLine));
}
RichTextBox rtBox = new RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例5: ToText
public override string ToText(Subtitle subtitle, string title)
{
const string format = "{0}: {1} {2} [{3}]";
StringBuilder 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++;
}
RichTextBox rtBox = new RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例6: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
this._errorCount = 0;
StringBuilder sb = new StringBuilder();
foreach (string line in lines)
{
sb.AppendLine(line);
}
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
{
return;
}
string[] arr = null;
RichTextBox rtBox = new RichTextBox();
try
{
rtBox.Rtf = rtf;
arr = rtBox.Text.Replace("\r\n", "\n").Split('\n');
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
List<string> list = new List<string>();
foreach (string s in arr)
{
list.Add(s);
}
base.LoadSubtitle(subtitle, list, fileName);
}
示例7: LoadTextFile
private void LoadTextFile(string fileName)
{
try
{
SubtitleListview1.Items.Clear();
Encoding encoding = Utilities.GetEncodingFromFile(fileName);
textBoxText.Text = File.ReadAllText(fileName, encoding);
// check for RTF file
if (fileName.ToLower().EndsWith(".rtf") && !textBoxText.Text.Trim().StartsWith("{\\rtf"))
{
var rtBox = new RichTextBox();
rtBox.Rtf = textBoxText.Text;
textBoxText.Text = rtBox.Text;
rtBox.Dispose();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例8: ToText
public override string ToText(Subtitle subtitle, string title)
{
StringBuilder 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, HtmlUtil.RemoveHtmlTags(p.Text)));
}
RichTextBox rtBox = new RichTextBox();
rtBox.Text = sb.ToString();
string rtf = rtBox.Rtf;
rtBox.Dispose();
return rtf;
}
示例9: downloadChangeLog
public static void downloadChangeLog(bool calledFromConfig)
{
// sort the list of patches with the newest first, this correctly display the change log
updateCheck.patchList.Sort(delegate(updateCheck.patches p1, updateCheck.patches p2) { return p2.patchVersion.CompareTo(p1.patchVersion); });
RichTextBox richTextBoxInput = new RichTextBox();
RichTextBox richTextBoxOutput = new RichTextBox();
//
// Download the change logs
//
foreach (updateCheck.patches thePatch in updateCheck.patchList)
{
if (thePatch.patchChangeLog.StartsWith("C:\\"))
{
System.IO.File.Copy(thePatch.patchChangeLog, Path.Combine(Path.GetTempPath(), "ChangeLog.rtf"), true);
return;
}
WebClient client = new WebClient();
try
{
client.DownloadFile(thePatch.patchChangeLog, Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"));
}
catch (Exception e)
{
if (calledFromConfig)
MessageBox.Show("Unable to access ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf\n\n" + e.Message, "ChangeLog access issue");
//smcLog.WriteLog("Unable to access ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf > " + e.Message, LogLevel.Error);
return;
}
// smcLog.WriteLog("Downloaded File : " + Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"), LogLevel.Info);
}
//
// And combine them into a single change log
//
if (File.Exists(Path.Combine(Path.GetTempPath(), "ChangeLog.rtf")))
File.Delete(Path.Combine(Path.GetTempPath(), "ChangeLog.rtf"));
//smcLog.WriteLog("Processing Change Log...", LogLevel.Info);
try
{
// Add each file and save as ChangeLog.rtf
int patchCnt = 1;
AvalonGUIConfig.theRevisions = "Patch: ";
foreach (updateCheck.patches thePatch in updateCheck.patchList)
{
richTextBoxInput.LoadFile(Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"));
richTextBoxInput.SelectAll();
richTextBoxInput.Copy();
richTextBoxOutput.Paste();
System.IO.File.Delete(Path.Combine(Path.GetTempPath(), "ChangeLog-" + thePatch.patchVersion.MinorRevision.ToString() + ".rtf"));
if (patchCnt < updateCheck.patchList.Count)
AvalonGUIConfig.theRevisions = AvalonGUIConfig.theRevisions + thePatch.patchVersion.ToString() + " / ";
else
AvalonGUIConfig.theRevisions = AvalonGUIConfig.theRevisions + thePatch.patchVersion.ToString();
patchCnt++;
}
richTextBoxOutput.SaveFile(Path.Combine(Path.GetTempPath(), "ChangeLog.rtf"));
richTextBoxInput.Dispose();
richTextBoxOutput.Dispose();
}
catch (Exception ex)
{
Log.Error("Exception Reading Change Logs: " + ex.Message + "\\n" + ex.StackTrace);
}
}
示例10: P3AddRtfMsg
/// <summary>
/// ���RTF�ı�
/// </summary>
/// <param name="text"></param>
void P3AddRtfMsg(string rtf)
{
int selStart = this.rtbP3Msg.Text.Length;
this.rtbP3Msg.Select(selStart, 0);
try
{
this.rtbP3Msg.SelectedRtf = rtf;
}
catch //����������ȵط����ͼ�ʱ��Ϣʱ�����Ϊ��RTF��ʽ������
{
RichTextBox box = new RichTextBox();
box.Text = rtf;
this.rtbP3Msg.SelectedRtf = box.Rtf;
box.Dispose();
}
//��������
this.rtbP3Msg.Select(selStart, this.rtbP3Msg.Text.Length);
this.rtbP3Msg.SelectionIndent = 16;
this.rtbP3Msg.Select(this.rtbP3Msg.Text.Length, 0);
this.rtbP3Msg.ScrollToCaret();
}
示例11: BuildNoteDocks
/// <summary>
/// Builds the notedocks.
/// </summary>
void BuildNoteDocks()
{
try {
// step 1: delete any existing notedocks
if (CaptionLabel != null && CaptionLabel.Items != null && CaptionLabel.Items.Count > 0)
for (int i = CaptionLabel.Items.Count-1; i >=0; i--) {
ToolStripItem control = (ToolStripItem)CaptionLabel.Items [i];
if (control.Tag != null) {
if (control.Tag.ToString () == "NoteDock") {
CaptionLabel.Items.Remove ((ToolStripItem)control);
}
}
}
//
// 03/11/2014
//
// Add custom button links (to give user ability to pair development notes with chapters)
//
//string customNoteLinks = "note1*44159e01-b2c6-4b1f-9b68-8d3c85755f14*chapter1;[[wordcount]]*44159e01-b2c6-4b1f-9b68-8d3c85755f14*chapter1";
// quick test just fake it
//foreach (string link in customNoteLinks)
{
// breakdown strings
string[] links = this.Notedocks.Split (new char[1]{';'}, StringSplitOptions.RemoveEmptyEntries);
if (links != null && links.Length > 0) {
foreach (string link_unit in links) {
string[] units = link_unit.Split (new char[1]{'*'}, StringSplitOptions.RemoveEmptyEntries);
// anchor optional
if (units != null && units.Length >= 2) {
ToolStripButton noteLink = new ToolStripButton ();
noteLink.Text = units [0];
// // tag contains GUID plus anchor reference.
// noteLink.Tag = units[1];
//
// // final anchor is optional
// if (units.Length == 3)
// {
// noteLink.Tag = units[1] + "*" + units[2];
// }
noteLink.Tag = "NoteDock";
if (units [0] == "[[wordcount]]") {
noteLink.Text = "<press for word count>";
noteLink.Click += (object sender, EventArgs e) =>
{
if (this.IsPanel) {
int maxwords = 0;
int maxwords2=0; // able to show three numbers. Document 0/2309 (next stage) / 99999 max
Int32.TryParse (units [1], out maxwords);
if (units.Length == 3)
{
Int32.TryParse (units [2], out maxwords2);
}
int words = 0;
//NewMessage.Show ("boo");
// iterate through all notes
foreach (NoteDataInterface note_ in this.ListOfSubnotesAsNotes()) {
//NewMessage.Show (note_.Caption);
if (note_ is NoteDataXML_RichText) {
// fetch word count
//((NoteDataXML_RichText)note_).GetRichTextBox().
if (LayoutDetails.Instance.WordSystemInUse != null)
{
try{
// we fetch data1 because the actual rich text box is NOT loaded
// but I found the word count quite excessive so we load it instead
RichTextBox faker = new RichTextBox();
faker.Rtf = ((NoteDataXML_RichText)note_).Data1;
string ftext = faker.Text;
faker.Dispose ();
words = words + LayoutDetails.Instance.WordSystemInUse.CountWords(ftext);
}
catch(System.Exception)
{
NewMessage.Show (Loc.GetStr("ERROR: Internal Word System Word Counting Error"));
}
}
else
{
NewMessage.Show (Loc.GetStr("Is there a Word system installed for counting words?"));
}
}
}
if (maxwords2 > 0) {
noteLink.Text = String.Format ("{0}/{1}/{2}", words, maxwords, maxwords2);
}
else
//.........这里部分代码省略.........
示例12: LoadSubtitle
/// <summary>
/// The load subtitle.
/// </summary>
/// <param name="subtitle">
/// The subtitle.
/// </param>
/// <param name="lines">
/// The lines.
/// </param>
/// <param name="fileName">
/// The file name.
/// </param>
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
this._errorCount = 0;
StringBuilder 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;
RichTextBox rtBox = new RichTextBox();
try
{
rtBox.Rtf = rtf;
text = rtBox.Text.Replace("\r\n", "\n");
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return;
}
finally
{
rtBox.Dispose();
}
lines = new List<string>();
foreach (string line in text.Split('\n'))
{
lines.Add(line);
}
this._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(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 3)
{
p = new Paragraph(DecodeTimeCode(arr[1]), DecodeTimeCode(arr[2]), string.Empty);
}
}
catch
{
this._errorCount++;
p = null;
}
}
else if (p != null && s.Length > 0)
{
sb.AppendLine(s.Trim());
}
else if (!string.IsNullOrWhiteSpace(s))
{
this._errorCount++;
}
}
if (p != null)
{
p.Text = sb.ToString().Trim();
subtitle.Paragraphs.Add(p);
}
subtitle.Renumber();
}
示例13: ReadingPassageONQuestion
//.........这里部分代码省略.........
box.SelectionStart = num5 - str3.Length;
box.SelectionLength = str4.Length;
box.Cut();
box.SelectedRtf = "";
num4 = box.Text.IndexOf(str3);
num5 = box.Text.IndexOf(str4);
}
str3 = "[" + i.ToString() + "]";
str4 = "[/" + i.ToString() + "]";
num4 = box.Text.IndexOf(str3);
num5 = box.Text.IndexOf(str4);
if (num4 >= 0)
{
box.SelectionStart = num4;
box.SelectionLength = str3.Length;
box.Cut();
box.SelectedRtf = "";
}
if (num5 >= 0)
{
box.SelectionStart = num5 - str3.Length;
box.SelectionLength = str4.Length;
box.Cut();
box.SelectedRtf = "";
}
str3 = "{" + i.ToString() + "}";
str4 = "{/" + i.ToString() + "}";
num4 = box.Text.IndexOf(str3);
num5 = box.Text.IndexOf(str4);
while ((num4 >= 0) || (num5 >= 0))
{
if (num4 >= 0)
{
box.SelectionStart = num4;
box.SelectionLength = str3.Length;
box.Cut();
box.SelectedRtf = "";
}
if (num5 >= 0)
{
box.SelectionStart = num5 - str3.Length;
box.SelectionLength = str4.Length;
box.Cut();
box.SelectedRtf = "";
}
num4 = box.Text.IndexOf(str3);
num5 = box.Text.IndexOf(str4);
}
}
else
{
string str5 = "<" + i.ToString() + ">◆</" + i.ToString() + ">";
int num6 = box.Text.IndexOf(str5);
while (num6 >= 0)
{
box.SelectionStart = num6;
box.SelectionLength = str5.Length;
box.Cut();
box.SelectedRtf = "";
num6 = box.Text.IndexOf(str5);
}
str5 = "{" + i.ToString() + "}█{/" + i.ToString() + "}";
for (num6 = box.Text.IndexOf(str5); num6 >= 0; num6 = box.Text.IndexOf(str5))
{
box.SelectionStart = num6;
box.SelectionLength = str5.Length;
box.Cut();
box.SelectedRtf = "";
}
str3 = "[" + i.ToString() + "]";
str4 = "[/" + i.ToString() + "]";
num4 = box.Text.IndexOf(str3);
num5 = box.Text.IndexOf(str4);
if (num4 >= 0)
{
box.SelectionStart = num4;
box.SelectionLength = str3.Length;
box.Cut();
box.SelectedRtf = "";
}
if (num5 >= 0)
{
box.SelectionStart = num5 - str3.Length;
box.SelectionLength = str4.Length;
box.Cut();
box.SelectedRtf = "";
}
if (num5 > num4)
{
box.SelectionStart = num4 - 1;
box.SelectionLength = ((num5 - num4) - str3.Length) + 2;
string selectedText = box.SelectedText;
box.SelectedText = selectedText;
}
}
}
string rtf = box.Rtf;
box.Dispose();
return rtf;
}
示例14: htmEdit1_OnNewDocument
private void htmEdit1_OnNewDocument(object sender, EventArgs e)
{
if (winTextBox1.Modified == false)
{
//新建立的文件名自动重命名
RichTextBox tmpRichTextBox1 = new RichTextBox();
tmpRichTextBox1.Text = htmEdit1.webBrowser1.Document.Body.InnerText;
//移动空行
string s = "";
for (int i = 0; i < tmpRichTextBox1.Lines.Length; i++)
{
if (tmpRichTextBox1.Lines[i].Trim() != "\r\n")
s += tmpRichTextBox1.Lines[i] + "\r\n";
}
tmpRichTextBox1.Text = tmpRichTextBox1.Text.Trim();
WinTextBox tmpWinTextBox1 = new WinTextBox();
tmpWinTextBox1.Text = tmpRichTextBox1.Lines[0];
string filename = Path.GetDirectoryName(FullFileName) + "\\" + tmpWinTextBox1.Text + ".htm";
filename = FileCore.NewName(filename);
if (!File.Exists(filename))
{
string name1 = Path.GetFileNameWithoutExtension(filename);
if (name1.Length <= winTextBox1.MaxLength)
{
winTextBox1.Text = name1;
winTextBox1_LostFocus(sender, e);
}
}
tmpRichTextBox1.Dispose();
tmpWinTextBox1.Dispose();
}
}
示例15: OnRecievedData
public void OnRecievedData(IAsyncResult ar)
{
Socket sock = (Socket)ar.AsyncState;
if (!uiRichTextBoxHistory.InvokeRequired)
{
try
{
int nBytesRec = sock.EndReceive(ar);
if (nBytesRec > 0)
{
//string sRecieved = Encoding.Unicode.GetString(buffer, 0, nBytesRec);
if (buffer == null)
buffer = new byte[nBytesRec];
MemoryStream msgStream = new MemoryStream();
ClientCommand msgCommand = new ClientCommand();
msgStream.Write(buffer, 0, nBytesRec);
BinaryFormatter deserializer = new BinaryFormatter();
msgStream.Position = 0;
msgCommand = (ClientCommand)deserializer.Deserialize(msgStream);
// OnAddMessage(sRecieved);
// View Messages here
if (msgCommand.MessageType == ClientCommand.msgType.JoinRoom || msgCommand.MessageType == ClientCommand.msgType.LeaveRoom)
{
LoadMembers();
}
else if (msgCommand.Sender != CurrentUser.Client.Name)
{
RichTextBox temp = new RichTextBox();
temp.Text = msgCommand.Sender + " says : \n\r" + msgCommand.Message;
temp.Select(0, temp.Text.IndexOf(" says :") + 7);
temp.SelectionFont = new System.Drawing.Font(temp.SelectionFont.FontFamily, temp.Font.Size, FontStyle.Bold);
foreach (var item in CurrentUser.Emotions)
{
int _index;
if ((_index = temp.Find(item.Key)) > -1)
{
temp.Select(_index, item.Key.Length);
InsertImage(new Bitmap(this.Parent.Parent.GetType(), item.Value), temp);
}
}
uiRichTextBoxHistory.SelectedRtf = temp.Rtf;
temp.Dispose();
}
SetupRecieveCallback(sock);
}
else
{
sock.Shutdown(SocketShutdown.Both);
sock.Close();
}
}
catch (Exception) { }
}
else
{
HandleOnRecievedDataCallBack b = new HandleOnRecievedDataCallBack(OnRecievedData);
this.Invoke(b, new object[] { ar });
}
}