Sunday, July 31, 2011

WinForm HTML Editor Control - Adding HTML editing to your WinForm app is drag and drop away...

Carl's Blog - WinForms HTML Editor

"A few years ago I wrote a WinForms HTML Editor. As I have been working in WinForms again it seemed appropriate to post the code up to a new location:

http://code.msdn.microsoft.com/WinForms-HTML-Editor-01dbce1a

The purpose of the Html Editor is to provide Html Editing capabilities within a WinForms control; satisfying the requirements of input for rich text layouts and simple portal type information. Examples of the former are case where the Rich Text control would normally be utilized; documentation, complex descriptions where text formatting is required, correspondences, bulletins, etc. Examples of the latter case are such items as dashboards; news clips, announcements, company references, etc. These are defined by cases where complex layouts are required that may include images and links.

The control emulates the operations that are available within a Rich Text control, but have information persisted and restored using an Html BODY element.

...

untitled"

MSDN Code Gallery - WinForms HTML Editor

"...

High level design goals are:

  1. Provides robust WYSIWYG editing capabilities whose contents are persisted in HTML format.
  2. Is easily reusable in other projects.
  3. Provides methods for saving HTML files to and loading files from disk (with the appropriate security demands).

The basic operations of the control are thus defined as:

Standard Text Editing

  1. Support basic formatting commands such as Bold, Italic, Underline, Strikeout, Font Name, Font Size, Font Color, Justification (Left, Right, and Center), Bullets and Number Lists. Dialogs should be presented to the user for modifying Font and Color attributes.
  2. Provide for standard Cut, Copy, Paste, Undo, Redo, Select All, and commands.
  3. ...

Body Properties

  1. Have the ability to simply set the text of the document body, the inner text of an Html Document; a browsable designer property.
  2. Allow for the assignment of the complete Body element (Body outer Html), preserving and body properties. Also allow for the
    assignment of the Body contents, Body inner Html.
  3. ...

External Behavior

  1. Allow a reference to a stylesheet to be applied to the document at runtime. The purpose is to allow the definition of a corporate wide stylesheet that all documents should reference for standardizing fonts, colors, etc.
  2. Allow a reference to a script source file to be applied to the document at runtime. The purpose is to allow the use of a corporate script file that can be used for handling links requiring programmatic redirection.
  3. ...

HTML Editor Non Goals

The Html Editor is not designed to provide similar functionality to Html Editor Products. For complex layout requiring Styles, Absolute Positing, Frames, Multi-Media, etc, these products should be utilized.

Operations that the control does not support are thus defined as:

  1. Support is only included for a single Font selection and not Font Families.
  2. Support for 2D-Position, Absolute Position, and Live Resize is not included.
  3. Multiple Selections of items is not supported and all operations are based on a single selected control.
  4. Simple Font properties are used rather than style attributes. The inclusion of style attributes brings around complexity regarding the use of Span tags.
  5. There was the option to have the control be Tab driven; supporting Design, Edit Html, and Preview. This would then have made the control look more like a fully-functional Html editor rather than a replacement to the Rich Text Box.

Here is a complete set of documentation: Html Editor Application.pdf

..."

This control (for which you get the source also) has a 30 page doc... Shiney!

image

Here's a snap of the source, control and sample app, in VS;

image

No comments: