Method ApplySetting
- Namespace
- OpenCAD2D
- Assembly
- OpenCAD2D.Core.dll
ApplySetting(string, string, Func<string>, Action, Action<CadDocument, bool>, bool)
Changes a setting kept in the drawing, one undo step, as AutoCAD 2021 records GRID, SNAP, SETVAR and a snap or grid
variable typed alone: the step puts the setting back by what replay writes, keeps no copy of the
drawing, and undoing or redoing it reads the drawing again no more than a zoom does. Inside a command's group
(BeginGroup(string)) the change joins the command's step instead. A change that leaves
read giving the text it gave before makes no step.
public CadEditResult ApplySetting(string name, string property, Func<string> read, Action change, Action<CadDocument, bool> replay, bool joinsPrevious)
Parameters
namestringThe name of the step: a command's name, as GRID, or "SETVAR".
propertystringThe name of the setting as the records show it: GRIDMODE, SNAPUNIT.
readFunc<string>Gives the setting as text, before the change and after it; the step records the two.
changeActionWrites the new value into the drawing.
replayAction<CadDocument, bool>Puts the setting forward, called with true, or back, called with false, in the drawing the document shows at that time (an undo of another step reads the drawing again, so what it writes into is found afresh).
joinsPreviousboolWhether the step is taken back and put again with the step before it.
Returns
- CadEditResult
What came of it: done, with no record where the setting did not change.
Remarks
AutoCAD's U takes F7, F9 and F8 pressed at the prompt back with the command before them, one U for both under the
name of that command, and as a step of their own where no command came before: pass
joinsPrevious true for such a change. The step then carries the name of the step before it, and
Undo() takes both back, Redo() puts both again.
The drawing is kept whole before the first step of the list, as for any edit, so change is run
after that. The steps after a step undone are forgotten, as after any edit.
Exceptions
- ArgumentNullException
Thrown when the name, the property,
read,changeorreplayis null.