|
@@ -11,10 +11,10 @@ namespace Terminal.Gui.Graphs {
|
|
|
/// </summary>
|
|
|
public class LineCanvas {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
private List<StraightLine> lines = new List<StraightLine> ();
|
|
|
|
|
|
- Dictionary<IntersectionRuneType, IntersectionRuneResolver> runeResolvers = new Dictionary<IntersectionRuneType, IntersectionRuneResolver> {
|
|
|
+ Dictionary<IntersectionRuneType, IntersectionRuneResolver> runeResolvers = new Dictionary<IntersectionRuneType, IntersectionRuneResolver> {
|
|
|
{IntersectionRuneType.ULCorner,new ULIntersectionRuneResolver()},
|
|
|
{IntersectionRuneType.URCorner,new URIntersectionRuneResolver()},
|
|
|
{IntersectionRuneType.LLCorner,new LLIntersectionRuneResolver()},
|
|
@@ -100,15 +100,14 @@ namespace Terminal.Gui.Graphs {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private abstract class IntersectionRuneResolver
|
|
|
- {
|
|
|
+ private abstract class IntersectionRuneResolver {
|
|
|
readonly Rune round;
|
|
|
readonly Rune doubleH;
|
|
|
readonly Rune doubleV;
|
|
|
readonly Rune doubleBoth;
|
|
|
readonly Rune normal;
|
|
|
|
|
|
- public IntersectionRuneResolver(Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune normal)
|
|
|
+ public IntersectionRuneResolver (Rune round, Rune doubleH, Rune doubleV, Rune doubleBoth, Rune normal)
|
|
|
{
|
|
|
this.round = round;
|
|
|
this.doubleH = doubleH;
|
|
@@ -121,17 +120,15 @@ namespace Terminal.Gui.Graphs {
|
|
|
{
|
|
|
var useRounded = intersects.Any (i => i.Line.Style == BorderStyle.Rounded && i.Line.Length != 0);
|
|
|
|
|
|
- bool doubleHorizontal = intersects.Any(l=>l.Line.Orientation == Orientation.Horizontal && l.Line.Style == BorderStyle.Double);
|
|
|
- bool doubleVertical = intersects.Any(l=>l.Line.Orientation == Orientation.Vertical && l.Line.Style == BorderStyle.Double);
|
|
|
+ bool doubleHorizontal = intersects.Any (l => l.Line.Orientation == Orientation.Horizontal && l.Line.Style == BorderStyle.Double);
|
|
|
+ bool doubleVertical = intersects.Any (l => l.Line.Orientation == Orientation.Vertical && l.Line.Style == BorderStyle.Double);
|
|
|
|
|
|
|
|
|
- if(doubleHorizontal)
|
|
|
- {
|
|
|
- return doubleVertical ? doubleBoth : doubleH;
|
|
|
+ if (doubleHorizontal) {
|
|
|
+ return doubleVertical ? doubleBoth : doubleH;
|
|
|
}
|
|
|
-
|
|
|
- if(doubleVertical)
|
|
|
- {
|
|
|
+
|
|
|
+ if (doubleVertical) {
|
|
|
return doubleV;
|
|
|
}
|
|
|
|
|
@@ -139,75 +136,71 @@ namespace Terminal.Gui.Graphs {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private class ULIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public ULIntersectionRuneResolver() :
|
|
|
- base('╭','╒','╓','╔','┌')
|
|
|
+ private class ULIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public ULIntersectionRuneResolver () :
|
|
|
+ base ('╭', '╒', '╓', '╔', '┌')
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- private class URIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
+ private class URIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
|
|
|
- public URIntersectionRuneResolver() :
|
|
|
- base('╮','╕','╖','╗','┐')
|
|
|
+ public URIntersectionRuneResolver () :
|
|
|
+ base ('╮', '╕', '╖', '╗', '┐')
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- private class LLIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
+ private class LLIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
|
|
|
- public LLIntersectionRuneResolver() :
|
|
|
- base('╰','╘','╙','╚','└')
|
|
|
+ public LLIntersectionRuneResolver () :
|
|
|
+ base ('╰', '╘', '╙', '╚', '└')
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- private class LRIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public LRIntersectionRuneResolver() :
|
|
|
- base('╯','╛','╜','╝','┘')
|
|
|
+ private class LRIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public LRIntersectionRuneResolver () :
|
|
|
+ base ('╯', '╛', '╜', '╝', '┘')
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public TopTeeIntersectionRuneResolver():
|
|
|
- base('┬','╤','╥','╦','┬'){
|
|
|
-
|
|
|
- }
|
|
|
+ private class TopTeeIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public TopTeeIntersectionRuneResolver () :
|
|
|
+ base ('┬', '╤', '╥', '╦', '┬')
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public LeftTeeIntersectionRuneResolver():
|
|
|
- base('├','╞','╟','╠','├'){
|
|
|
-
|
|
|
- }
|
|
|
+ private class LeftTeeIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public LeftTeeIntersectionRuneResolver () :
|
|
|
+ base ('├', '╞', '╟', '╠', '├')
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public RightTeeIntersectionRuneResolver():
|
|
|
- base('┤','╡','╢','╣','┤'){
|
|
|
-
|
|
|
- }
|
|
|
+ private class RightTeeIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public RightTeeIntersectionRuneResolver () :
|
|
|
+ base ('┤', '╡', '╢', '╣', '┤')
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public BottomTeeIntersectionRuneResolver():
|
|
|
- base('┴','╧','╨','╩','┴'){
|
|
|
-
|
|
|
- }
|
|
|
+ private class BottomTeeIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public BottomTeeIntersectionRuneResolver () :
|
|
|
+ base ('┴', '╧', '╨', '╩', '┴')
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver
|
|
|
- {
|
|
|
- public CrosshairIntersectionRuneResolver():
|
|
|
- base('┼','╪','╫','╬','┼'){
|
|
|
-
|
|
|
- }
|
|
|
+ private class CrosshairIntersectionRuneResolver : IntersectionRuneResolver {
|
|
|
+ public CrosshairIntersectionRuneResolver () :
|
|
|
+ base ('┼', '╪', '╫', '╬', '┼')
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private Rune? GetRuneForIntersects (ConsoleDriver driver, IntersectionDefinition [] intersects)
|
|
@@ -217,7 +210,7 @@ namespace Terminal.Gui.Graphs {
|
|
|
|
|
|
var runeType = GetRuneTypeForIntersects (intersects);
|
|
|
|
|
|
- if(runeResolvers.ContainsKey (runeType)) {
|
|
|
+ if (runeResolvers.ContainsKey (runeType)) {
|
|
|
return runeResolvers [runeType].GetRuneForIntersects (driver, intersects);
|
|
|
}
|
|
|
|
|
@@ -228,13 +221,13 @@ namespace Terminal.Gui.Graphs {
|
|
|
// TODO: maybe make these resolvers to for simplicity?
|
|
|
// or for dotted lines later on or that kind of thing?
|
|
|
switch (runeType) {
|
|
|
- case IntersectionRuneType.None:
|
|
|
+ case IntersectionRuneType.None:
|
|
|
return null;
|
|
|
- case IntersectionRuneType.Dot:
|
|
|
+ case IntersectionRuneType.Dot:
|
|
|
return (Rune)'.';
|
|
|
- case IntersectionRuneType.HLine:
|
|
|
+ case IntersectionRuneType.HLine:
|
|
|
return useDouble ? driver.HDLine : driver.HLine;
|
|
|
- case IntersectionRuneType.VLine:
|
|
|
+ case IntersectionRuneType.VLine:
|
|
|
return useDouble ? driver.VDLine : driver.VLine;
|
|
|
default: throw new Exception ("Could not find resolver or switch case for " + nameof (runeType) + ":" + runeType);
|
|
|
}
|
|
@@ -243,7 +236,7 @@ namespace Terminal.Gui.Graphs {
|
|
|
|
|
|
private IntersectionRuneType GetRuneTypeForIntersects (IntersectionDefinition [] intersects)
|
|
|
{
|
|
|
- if(intersects.All(i=>i.Line.Length == 0)) {
|
|
|
+ if (intersects.All (i => i.Line.Length == 0)) {
|
|
|
return IntersectionRuneType.Dot;
|
|
|
}
|
|
|
|