C#-rtf Text Editor

Source: Internet
Author: User

1 ". RTF "What is it?"

Rich Text Format (RTF) is a text and graphics document format that is convenient for different devices and systems to view.
RTF uses the American National Standards Association (ANSI), PC-8, Macintosh (Mac Apple), or IBM's PC character settings to control the display form and print form.
RTF documents created under different operating systems can be transferred to and viewed from one another across multiple operating systems and applications.
Currently, as MS-DOS, Microsoft Windows, OS/2, Macintosh Apple systems, special translation software handles documents between applications.

RTF is the abbreviation for rich Text format, which means multiple text formats. This is a DOC format (Word document) file that has good compatibility and can be opened and edited using WordPad in Windows accessories. When you open a rich Text format file using WordPad, you will see the contents of the file, and if you want to view the source code for the RTF file, simply open it using Notepad. This means that you can use Notepad to edit Rich text format files just like you would edit an HTML file.
As a standard document for Microsoft, the early outside world needs $ dozens of to pay Microsoft to buy a thin RTF standard file. However, with the increasing use of rich-text format standards, and the growing popularity of RTF formats, Microsoft has published standard documents online for developers to download.
The RTF format is a file format that is recognized by many software. For example, Word, WPS Office, Excel, and so on can open rich Text format files.

For ordinary users, the RTF format is a good file format conversion tool for the transfer of formatted text documents between different applications.
Universal compatibility should be the biggest advantage of RTF, but it also has its drawbacks, such as the file is generally relatively large (perhaps because embedded in a variety of applications compatible with the control symbol bar), Word and other application software-specific format may not be properly saved, etc.

2. The code is as follows:

Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.text;using system.windows.forms;using system.io;using FCG. Windows.forms;namespace rtf{public partial class Rtf:form {public RTF () {initializecom        Ponent ();        }///<summary>//Get the Rtfeditor instance used in the document editing area. </summary> internal Rtfeditor Rtfeditor {get {return Rtfedi            Tor }} void Rtfeditor_filenamechanged (object sender, EventArgs e) {string FileName = path.ge            Tfilename (Rtfeditor.filefullname);            if (filename = = "") FileName = "Yys-rtf editor"; This.        Text = FileName; } protected override void OnLoad (EventArgs e) {base.                        OnLoad (e);            String[] args =environment.getcommandlineargs (); if (args. Length < 2)//aRg[0]=exepath, arg[1] = filename {//file_func_newfile ();                } else {string filename =args[1]; if (filename. Trim ().            ToLower ()! = "-test") rtfeditor.loadfile (filename);            } rtfeditor.filenamechanged + = new EventHandler (rtfeditor_filenamechanged);        Rtfeditor_filenamechanged (this, null); }///<summary>///Before closing the program, determine if the text needs to be saved///</summary> private void app_closing (for  Mclosingeventargs e) {if (rtfeditor.modified) {//document modified DialogResult result = MessageBox.Show ("The file contents have changed, do you want to save the file?"                "," hint ", Messageboxbuttons.yesnocancel, MessageBoxIcon.Information); Switch (Result) {case Dialogresult.yes://"Save", then the action to save the file is executed//if there is no Select the file name you want to save, then the Save dialog box appears, and the user selects the file name to save and then saves the text if (Savefiledialog.filename = ="") {if (Savefiledialog.showdialog (this). Toplevelcontrol) = = DialogResult.OK) {rtfeditor.savefile (Savefi                            Ledialog.filename, Richtextboxstreamtype.plaintext); }} else {//If you have selected a file to save                        Name, save the text to the file in Rtfeditor.savefile (Savefiledialog.filename, Richtextboxstreamtype.plaintext);                    } break;                    Case dialogresult.no://does not save the break;                        default://Cancel Operation E.cancel = true;                Break  }}}///<summary> Event Handling-window closed///</summary>//<param Name= "E" ></param> protected override void Onformclosing (FormClosingEventArgs e)        {base.            Onformclosing (e); if (!this.        Modal) app_closing (e); }    }}

3.:


C#-rtf Text Editor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.