Permalink
Browse files

Moved corners out into its own class (with indexer)

  • Loading branch information...
tdwright committed Dec 18, 2017
1 parent 959e28d commit a11d0e3718e714ade8143d5aa1e4f2f5ac62b654
Showing with 67 additions and 50 deletions.
  1. +50 −0 ConTabs/Corners.cs
  2. +17 −50 ConTabs/Styles.cs
View
@@ -0,0 +1,50 @@
namespace ConTabs
{
public class Corners
{
private char[,] cornerChars = new char[3, 3];
/*
* ╔═══╤═════╤═════╤═════╗
* ║ │ 0 │ 1 │ 2 ║
* ╠═══╪═════╪═════╪═════╣
* ║ 0 │ TL │ TNU │ TR ║
* ╟───┼─────┼─────┼─────╢
* ║ 1 │ TNL │ I │ TNR ║
* ╟───┼─────┼─────┼─────╢
* ║ 2 │ BL │ TND │ BR ║
* ╚═══╧═════╧═════╧═════╝
*
*/
public char CornerTopLeft { get { return cornerChars[0, 0]; } set { cornerChars[0, 0] = value; } }
public char CornerTopRight { get { return cornerChars[2, 0]; } set { cornerChars[2, 0] = value; } }
public char CornerBottomLeft { get { return cornerChars[0, 2]; } set { cornerChars[0, 2] = value; } }
public char CornerBottomRight { get { return cornerChars[2, 2]; } set { cornerChars[2, 2] = value; } }
public char Intersection { get { return cornerChars[1, 1]; } set { cornerChars[1, 1] = value; } }
public char TeeNoUp { get { return cornerChars[1, 0]; } set { cornerChars[1, 0] = value; } }
public char TeeNoRight { get { return cornerChars[2, 1]; } set { cornerChars[2, 1] = value; } }
public char TeeNoDown { get { return cornerChars[1, 2]; } set { cornerChars[1, 2] = value; } }
public char TeeNoLeft { get { return cornerChars[0, 1]; } set { cornerChars[0, 1] = value; } }
public char this[int i, int j]
{
get
{
return cornerChars[i, j];
}
}
public void SetAllCorners(char corner)
{
for(int i=0;i<cornerChars.GetLength(0);i++)
{
for(int j =0;j<cornerChars.GetLength(1);j++)
{
cornerChars[i, j] = corner;
}
}
}
}
}
View
@@ -6,72 +6,39 @@ public class Style
public char Wall { get; set; }
public char Floor { get; set; }
public char[,] Corners = new char[3, 3];
/*
* ╔═══╤═════╤═════╤═════╗
* ║ │ 0 │ 1 │ 2 ║
* ╠═══╪═════╪═════╪═════╣
* ║ 0 │ TL │ TNU │ TR ║
* ╟───┼─────┼─────┼─────╢
* ║ 1 │ TNR │ I │ TNL ║
* ╟───┼─────┼─────┼─────╢
* ║ 2 │ BL │ TND │ BR ║
* ╚═══╧═════╧═════╧═════╝
*
*/
public char CornerTopLeft { get { return Corners[0, 0]; } set { Corners[0, 0] = value; } }
public char CornerTopRight { get { return Corners[2, 0]; } set { Corners[2, 0] = value; } }
public char CornerBottomLeft { get { return Corners[0, 2]; } set { Corners[0, 2] = value; } }
public char CornerBottomRight { get { return Corners[2, 2]; } set { Corners[2, 2] = value; } }
public char Intersection { get { return Corners[1, 1]; } set { Corners[1, 1] = value; } }
public char TeeNoUp { get { return Corners[1, 0]; } set { Corners[1, 0] = value; } }
public char TeeNoRight { get { return Corners[0, 1]; } set { Corners[0, 1] = value; } }
public char TeeNoDown { get { return Corners[1, 2]; } set { Corners[1, 2] = value; } }
public char TeeNoLeft { get { return Corners[2, 1]; } set { Corners[2, 1] = value; } }
public Corners Corners { get; set; }
public Style(char wall, char floor, char corners)
{
Wall = wall;
Floor = floor;
CornerTopLeft = corners;
CornerTopRight = corners;
CornerBottomLeft = corners;
CornerBottomRight = corners;
Intersection = corners;
TeeNoUp = corners;
TeeNoRight = corners;
TeeNoDown = corners;
TeeNoLeft = corners;
Corners = new Corners();
Corners.SetAllCorners(corners);
}
public Style(char wall, char floor, char tl, char tr, char bl, char br, char i, char tnu, char tnr, char tnd, char tnl)
public Style(char wall, char floor, Corners corners)
{
Wall = wall;
Floor = floor;
CornerTopLeft = tl;
CornerTopRight = tr;
CornerBottomLeft = bl;
CornerBottomRight = br;
Intersection = i;
TeeNoUp = tnu;
TeeNoRight = tnr;
TeeNoDown = tnd;
TeeNoLeft = tnl;
Corners = corners;
}
public static Style Default => new Style('|', '-', '+');
public static Style Heavy => new Style('#', '=', '#');
public static Style UnicodePipes => new Style('║', '═', '╔', '╗', '╚', '╝', '╬', '╦', '╠', '╩', '╣');
public static Style UnicodePipes => new Style('║', '═', new Corners {
CornerTopLeft = '╔',
CornerTopRight = '╗',
CornerBottomLeft = '╚',
CornerBottomRight = '╝',
Intersection = '╬',
TeeNoUp = '╦',
TeeNoLeft = '╠',
TeeNoDown = '╩',
TeeNoRight = '╣'
});
}
}

0 comments on commit a11d0e3

Please sign in to comment.