Class CadMTextEditor
- Namespace
- OpenCAD2D
- Assembly
- OpenCAD2D.Core.dll
The words of an MTEXT being edited in place, as AutoCAD's text editor holds them: letters of a look each, paragraphs, a caret and a selection, and what the Text Editor tab does to them, each written back by Contents in AutoCAD's codes (CadMTextContent). It knows no window: the editor on the canvas and a test call it the same way.
public sealed class CadMTextEditor
- Inheritance
-
CadMTextEditor
- Inherited Members
Remarks
Places are counted in letters from the start, a paragraph break one, a symbol or a stack one. A look set with nothing
selected is the look of the letters typed next, as in AutoCAD; with letters selected it is theirs. "AB CD" with CD
selected and made bold, in an MTEXT 2.5 high of a style in Arial, writes AB {\fArial|b1|i0|c0|p34;CD}. Bold and
italic need a TrueType font: on letters of an SHX font they do nothing (CanBold). Each change can be
taken back by Undo() while the editor is open; closing it is one undo step of the drawing.
Constructors
- CadMTextEditor(string, double, CadMTextFrame, double, string, bool, char, IReadOnlyList<string>)
Opens the words of an MTEXT in a style of letters of another width for editing in its box: a width in times of the style's (
{\W1.2x;ABC}) is read as times that width, 0.96 in a style of 0.8, as AutoCAD 2021 draws it, and written back as that width (\W0.9600;).
- CadMTextEditor(string, double, CadMTextFrame, string, bool, char)
Opens the words of an MTEXT for editing in its box: the width, height and columns the ruler and Column Settings change.
- CadMTextEditor(string, double, string, bool, char)
Opens the words of an MTEXT for editing.
Properties
- Alignment
Gets the alignment of the paragraph the caret is in: l, c, r, j or d.
- Anchor
Gets the other end of the selection; the caret where nothing is selected.
- AutoCaps
Gets or sets AutoCAPS: while on, letters typed, pasted or imported go in as capitals. Letters already there are not changed (Change Case does that); the setting is not an undo step.
- CanBold
Gets whether bold and italic can be given to the look shown: its font, or the style's, is a TrueType font.
- CanRedo
Gets whether a change taken back can be made again.
- CanUndo
Gets whether a change can be taken back.
- Content
Gets the words as paragraphs of runs, for drawing them.
- Contents
Gets the words with their codes, as AutoCAD writes them.
- CurrentFormat
Gets how the caret's paragraph is set, or the first selected one's, as the ruler shows it.
- CurrentLook
Gets the look the ribbon shows: of the letters typed next where nothing is selected, else of the first selected.
- DefaultAlignment
Gets how a paragraph with no alignment code is aligned.
- Frame
Gets the MTEXT's box as the ruler and Column Settings have it now.
- HasFields
Gets whether any place holds a field.
- Height
Gets the MTEXT's height, of which a run's height is written as a factor.
- IsChanging
Gets whether a ruler drag is going on (BeginChange()): its changes are one undo step when it ends.
- IsMatching
Gets whether Match Text Formatting waits for letters to give a look to: BeginMatch() was called and neither ApplyMatch() nor CancelMatch() has ended it.
- IsModified
Gets whether the words differ from what they were when the editor opened.
- Length
Gets the number of places: letters, symbols and paragraph breaks.
- Original
Gets the words as they were when the editor opened.
- OriginalFrame
Gets the MTEXT's box as it was when the editor opened.
- ParagraphCount
Gets how many paragraphs the words make, at least one.
- SelectedParagraphs
Gets the first and the last paragraph the selection, or the caret, is in.
- SelectedText
Gets the selected words as shown.
- SelectionLength
Gets how many places are selected.
- SelectionStart
Gets where the selection starts.
- StyleFont
Gets the font of the MTEXT's style.
- StyleIsShx
Gets whether the style's font is an SHX file.
- StyleWidth
Gets the width factor of the MTEXT's style, of which a width in times (
\W1.2x;) is read; 1 for none given.
- Text
Gets the words as shown, a line feed for each paragraph break, a symbol as its letter (° for
%%d).
Methods
- ApplyMatch()
Gives the look BeginMatch() took to the selected letters, all of it (the font, bold, italic, underline, overline, strikethrough, colour, height, slant, tracking and width), one undo step, and ends Match Text Formatting. Nothing is done where no letters are selected, and the brush waits.
- Backspace()
Backspace: the selection taken out, or the place before the caret.
- BeginChange()
Starts a drag of the ruler: what changes until EndChange(bool) is shown at once but makes one undo step at the end, or none where the drag is put back.
- BeginMatch()
Starts Match Text Formatting, the brush of the Formatting panel: takes the look of the selected letters, or of the letters typed next where none are selected, for ApplyMatch() to give to the letters selected next.
- CancelMatch()
Ends Match Text Formatting with nothing given.
- ChangeCase(bool)
Changes the selected letters to capitals or to small letters, as AutoCAD's Change Case.
- ClearFormatting()
Clears the codes of the selected letters (Clear formatting), as AutoCAD's Remove Character Formatting.
- ConvertFieldToText(int)
Makes the field a place holds words, as Convert Field To Text does: the words it showed, each letter a place of the look the field had, written as they are and no longer as a code.
- Delete()
Delete: the selection taken out, or the place after the caret.
- EndChange(bool)
Ends a drag of the ruler: its changes kept as one undo step (the release), or put back (Esc).
- FieldCodeAt(int)
Gets the code of the field a place holds, in its markers; null where the place holds none.
- FindNext(string, CadMTextFindOptions)
Finds the next match of words after the selection, or the caret, the search going round to the start, and selects it: Find and Replace's Find Next. A symbol or a stack counts as one place, which no words match.
- FindNext(string, bool)
Finds words after the caret, the search going round to the start, and selects them.
- FormatOf(int)
Gets how a paragraph is set: its own codes over those of the paragraphs before it, as AutoCAD carries them on. In an MTEXT 2.5 high,
\pxt4;A\PBhas a tab stop at 10 in both paragraphs.
- InsertColumnBreak()
Puts a column break at the caret (Alt+Enter), over the selection: the words after it start the next column.
- InsertContent(CadMTextContent)
Puts the words of a file at the caret, over the selection, in the looks they come with: Import Text. The paragraphs and runs are those CadMTextImport reads from a text or an RTF file; a run with no look of its own takes the look of the letters typed there. One undo step.
- InsertField(string, string)
Inserts a field as AutoCAD's Insert Field does: one place, shown as the words the field came to and written as its code in markers (
%<\AcVar Date \f "dd/MM/yyyy">%), in the look of the letters typed there.
- InsertSymbol(string, string)
Inserts a symbol as AutoCAD's Symbol menu writes it: shown as its letter, written as its code (
%%d,\U+2248).
- LookAt(int)
Gets the look of a place: of its letter, the look the letters typed there take for a break.
- MoveTo(int, bool)
Moves the caret, the selection grown from its other end where
extend, as Shift does.
- NumberingOf(int)
Gets the label a paragraph opens with, as SetNumbering(CadMTextNumbering) writes them: in
1.\tPlate\Pb.\tBeam\PColumnthe first is Number, the second LetterLower and the third Off.
- OwnAlignmentOf(int)
Gets the alignment a paragraph carries of its own: l, c, r, j or d; nought where it follows the MTEXT's attachment.
- ParagraphOf(int)
The paragraph a place is in, counted from nought.
- Redo()
Makes the last change taken back again.
- RenumberList(bool)
Starts or continues the numbering of the list the first selected paragraph is in, as the Start and Continue items of Bullets and Numbering do, one undo step: Start numbers that paragraph 1 (or a, A) and the paragraphs of the same list after it from there, so that with the caret in Beam,
1.\tPlate\P2.\tBeam\P3.\tColumnbecomes1.\tPlate\P1.\tBeam\P2.\tColumn; Continue numbers it on from the paragraph before, which puts the second back. A list is the run of paragraphs with the same kind of label. Nothing is done, and false answered, for a paragraph with no number or letter label (none, or a bullet), or for Continue where the paragraph before has not the same kind of label.
- Replace(string, string, CadMTextFindOptions)
Find and Replace's Replace: where the selection is a match of the words it is replaced, in the look of its first letter and as one undo step, and the next match is selected; else the next match is selected, as Find Next does, and nothing is replaced.
- ReplaceAll(string, string, CadMTextFindOptions)
Replaces every match of words with others, each in the look of the letter it starts at, as one undo step: Find and Replace's Replace All. The text put in is not searched again, so that replacing "a" with "aa" ends.
- ReplaceAll(string, string, bool)
Replaces every match of words with others, each in the look of the letter it starts at, as one change; Find and Replace's Replace All.
- ReplaceField(int, string, string)
Gives the field a place holds another code and words, as Edit Field does; its look kept.
- ReplaceText(int, int, string)
Puts words in the place of some places, in the look of the first of them, as one undo step, the caret after the words: a suggestion of the spell check picked from the menu. AutoCAPS does not change them.
- Select(int, int)
Selects places.
- SelectAll()
Selects every place, as Ctrl+A.
- SetAlignment(char)
Aligns the paragraphs the selection or the caret is in: l, c, r, j or d.
- SetBold(bool)
Makes the letters bold or not (Ctrl+B); nothing on letters of an SHX font.
- SetColorIndex(int?)
Gives the letters a colour of the index: 256 ByLayer, 0 ByBlock; null for the MTEXT's own.
- SetFont(string, bool)
Gives the letters a font: a TrueType family keeping bold and italic, or an SHX file; null for the style's.
- SetFormat(Func<CadMTextParagraphFormat, CadMTextParagraphFormat>)
Changes how the selected paragraphs, or the caret's, are set: their indents, tab stops and spacing, one undo step. Each is written as AutoCAD writes it, what differs from the paragraph before, and the paragraph after them is written back to how it was: a tab stop at 10 set on the first of "A", "B" in an MTEXT 2.5 high writes
\pxt4;A\P\ptz;B.
- SetFrame(CadMTextFrame)
Changes the MTEXT's box: its width, defined height or columns, one undo step.
- SetHeight(double)
Gives the letters a height in drawing units; the MTEXT's own height or less than nought is none of their own.
- SetItalic(bool)
Makes the letters italic or not (Ctrl+I); nothing on letters of an SHX font.
- SetNumbering(CadMTextNumbering)
Labels the selected paragraphs, or the caret's, as a list, as AutoCAD 2021's Bullets and Numbering does, one undo step: each opens with its label and a tab, the paragraphs hanging 3 heights in with a tab stop there, and a label one had is replaced. In an MTEXT 2.5 high, "Plate", "Beam" numbered is written
\pxi-3,l3,t3;1.\tPlate\P2.\tBeamand bulleted\pxi-3,l3,t3;{\fSymbol|b0|i0|c2|p18;·\t}Plate\P{\fSymbol|b0|i0|c2|p18;·\t}Beam, as AutoCAD's TextEditor writes them (probed). Off takes the labels, the indent and the stop away.
- SetOblique(double)
Slants the letters by degrees; nought is none of their own.
- SetOverline(bool)
Overlines the letters or not.
- SetStrikethrough(bool)
Strikes the letters through or not.
- SetTracking(double)
Spaces the letters by a factor of their usual spacing; 1 is none of their own.
- SetUnderline(bool)
Underlines the letters or not (Ctrl+U).
- SetWidthFactor(double)
Widens or narrows the letters by a factor; 1 is none of their own.
- TextAt(int)
Gets the letters a place shows: a line feed for a paragraph break.
- Type(string)
Types letters over the selection, each line feed a new paragraph, in the look of the letters typed there.
- Undo()
Takes the last change back.
Events
- Changed
Raised when the words, the looks, the caret or the selection change.