Class LineCanvas
Facilitates box drawing and line intersection detection and rendering. Does not support diagonal lines.
public class LineCanvas : IDisposable
- Inheritance
-
LineCanvas
- Implements
- Inherited Members
Constructors
- LineCanvas()
Creates a new instance.
- LineCanvas(IEnumerable<StraightLine>)
Creates a new instance with the given
lines
.
Properties
- Bounds
Gets the rectangle that describes the bounds of the canvas. Location is the coordinates of the line that is the furthest left/top and Size is defined by the line that extends the furthest right/bottom.
- Fill
Optional FillPair which when present overrides the Attribute (colors) of lines in the canvas. This can be used e.g. to apply a global GradientFill across all lines.
- Lines
Gets the lines in the canvas.
Methods
- AddLine(Point, int, Orientation, LineStyle, Attribute?)
Adds a new
length
long line to the canvas starting atstart
.Use positive
length
for the line to extend Right and negative for Left when Orientation is Horizontal.Use positive
length
for the line to extend Down and negative for Up when Orientation is Vertical.
- AddLine(StraightLine)
Adds a new line to the canvas
- Clear()
Clears all lines from the LineCanvas.
- ClearCache()
Clears any cached states from the canvas. Call this method if you make changes to lines that have already been added.
- ClearExclusions()
Clears the exclusion region. After calling this method, GetCellMap() and GetMap() will return all points in the canvas.
- Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- Exclude(Region)
Causes the provided region to be excluded from GetCellMap() and GetMap().
- GetCellMap()
Evaluates the lines that have been added to the canvas and returns a map containing the glyphs and their locations. The glyphs are the characters that should be rendered so that all lines connect up with the appropriate intersection symbols.
- GetMap()
Evaluates the lines that have been added to the canvas and returns a map containing the glyphs and their locations. The glyphs are the characters that should be rendered so that all lines connect up with the appropriate intersection symbols.
- GetMap(Rectangle)
Evaluates the lines that have been added to the canvas and returns a map containing the glyphs and their locations. The glyphs are the characters that should be rendered so that all lines connect up with the appropriate intersection symbols.
- Merge(LineCanvas)
Merges one line canvas into this one.
- RemoveLastLine()
Removes the last line added to the canvas
- ToString()
Returns the contents of the line canvas rendered to a string. The string will include all columns and rows, even if Bounds has negative coordinates. For example, if the canvas contains a single line that starts at (-1,-1) with a length of 2, the rendered string will have a length of 2.