Table of Contents

Class CadToolPalettes

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

The tool palettes of the window: the palettes in the order of their tabs, the one shown, and the tools cut or copied that Paste puts back. The set is kept in one JSON file beside the settings (DefaultPath, written by Save(string), read by Load(string)); one palette, or all of them, can be written to a file of their own (Export(string, IEnumerable<CadToolPalette>)) and read from one (Import(string)) in the same format, which the guide of the presenter describes member by member. A set with no file starts as CreateStarter() makes it.

public sealed class CadToolPalettes
Inheritance
CadToolPalettes
Inherited Members

Fields

Format

The format a file of tool palettes has.

NewPaletteName

The name of the palette a new one is given where it is not named.

Version

The version this writes; a file of a later version is read as far as it is understood.

Properties

Active

Gets the palette shown; null where the set has none.

ActiveIndex

Gets or sets the place in Palettes of the palette shown; kept inside the list, 0 with none.

Clipboard

Gets the tools cut or copied, which Paste(CadToolPalette, int) puts into a palette.

DefaultPath

Gets the file the palettes are kept in: %AppData%\OpenCAD2D\ToolPalettes.json, beside the settings.

IsModified

Gets whether the set changed since it was made, read or last saved.

Palettes

Gets the palettes, in the order of their tabs.

Methods

Add(CadToolPalette)

Puts a palette after the last, its name made unique, and shows it.

Add(string)

Makes an empty palette after the last, its name made unique, and shows it.

AddBlocks(string, string, IEnumerable<string>)

Makes a palette of a drawing's blocks: one palette named for the drawing, a block tool for each name, taking the drawing as its source, as DesignCenter's Create Tool Palette does.

Copy(IEnumerable<CadTool>)

Puts copies of tools on the clipboard, as Copy of a tool's menu does.

CreateStarter()

Makes the set a window starts with where it has no file: Draw and Modify of command tools (LINE, PLINE, CIRCLE ... MOVE, COPY, TRIM ...), Annotation (text, dimensions, leaders, tables), Hatches (the ANSI patterns the presenter has, solid and gradient fills and some materials), Architectural Hatches (the AR- patterns, drawn at their size in millimetres) and ISO Hatches (ISO02W100 to ISO15W100). All are the presenter's own: its patterns and its icons.

Cut(CadToolPalette, IEnumerable<CadTool>)

Puts the tools on the clipboard and takes them out of the palette, as Cut does.

Export(string, IEnumerable<CadToolPalette>)

Writes palettes to a file of their own, in the format of the set, for Import(string) to read on another machine.

Import(string)

Reads a file Export(string, IEnumerable<CadToolPalette>) (or Save(string)) wrote and adds its palettes after the last, their names made unique.

Load(string)

Reads the set from its file, never throwing: no file gives CreateStarter(); a file that does not read gives it too, said in the log once.

Move(CadToolPalette, int)

Moves a palette to another place among the tabs; the palette shown stays the one shown.

Paste(CadToolPalette, int)

Puts copies of the tools on the clipboard into a palette, at a place of its list; the clipboard stays full, so they can be pasted again.

Remove(CadToolPalette)

Takes a palette out; the palette shown stays the one shown where it is another, else the one next to it is.

Rename(CadToolPalette, string)

Renames a palette; a name another palette has gets (2) and on after it.

Save(string)

Writes the set to a JSON file, the folder made where it is missing, as ToJson() gives it; the set is no longer modified.

ToJson()

Gives the set as the JSON text Save(string) writes: two spaces of indent and LF line ends.

Touch()

Tells the set it changed, as the window does after it changes a tool or a palette in place.

TryParse(string, out CadToolPalettes, out string)

Reads a set from JSON text, as ToJson() wrote it; a value that is not valid falls back to its default with a Warn naming it.

UniqueName(string, CadToolPalette)

Gives a palette name that no palette of the set has, letters of either case the same: the name wanted, else with (2), (3) and on after it.