static void Main(string[] args) { var parts = new[] { new FramePart("Bottom", new FlushCornerCuttingStrategy()), new FramePart("Left Post", new AngledCornerCuttingStrategy()), new FramePart("Top", new AngledCornerCuttingStrategy()), new FramePart("Right Post", new AngledCornerCuttingStrategy()), }; // join neighbouring parts, and last one to first (%) for (int i = 0; i < parts.Length; i++) { FramePart.Join(parts[i], parts[(i + 1) % parts.Length]); } // Send parts to cutting machine var machine = new CuttingMachine(); foreach (var part in parts) { machine.ProcessPart(part); } }
public void DrawFrame( ConsoleColor fg = ConsoleColor.White, ConsoleColor bg = ConsoleColor.Black, FramePart topLeft = FramePart.CornerTopLeft, FramePart topRight = FramePart.CornerTopRight, FramePart bottomRight = FramePart.CornerBottomRight, FramePart bottomLeft = FramePart.CornerBottomLeft, FramePart top = FramePart.Horizontal, FramePart bottom = FramePart.Horizontal, FramePart left = FramePart.Vertical, FramePart right = FramePart.Vertical, FramePart fill = FramePart.Empty) { int x = 0; int y = 0; int width = this.width; int height = this.height; width -= 1; height -= 1; if (topLeft != FramePart.None) { Set((char)topLeft, x, y, fg, bg); } if (topRight != FramePart.None) { Set((char)topRight, x + width, y, fg, bg); } if (bottomRight != FramePart.None) { Set((char)bottomRight, x + width, y + height, fg, bg); } if (bottomLeft != FramePart.None) { Set((char)bottomLeft, x, y + height, fg, bg); } if (left != FramePart.None && right != FramePart.None) { for (var yy = y + 1; yy < y + height; yy++) { Set((char)left, x, yy, fg, bg); Set((char)right, x + width, yy, fg, bg); } } else if (left == FramePart.None) { for (var yy = y + 1; yy < y + height; yy++) { Set((char)right, x + width, yy, fg, bg); } } else if (right == FramePart.None) { for (var yy = y + 1; yy < y + height; yy++) { Set((char)left, x, yy, fg, bg); } } if (top != FramePart.None && bottom != FramePart.None) { for (var xx = x + 1; xx < x + width; xx++) { Set((char)top, xx, y, fg, bg); Set((char)bottom, xx, y + height, fg, bg); } } else if (top == FramePart.None) { for (var xx = x + 1; xx < x + width; xx++) { Set((char)bottom, xx, y + height, fg, bg); } } else if (bottom == FramePart.None) { for (var xx = x + 1; xx < x + width; xx++) { Set((char)top, xx, y, fg, bg); } } if (fill != FramePart.None) { for (var yy = y + 1; yy < y + height; yy++) { for (var xx = x + 1; xx < x + width; xx++) { Set((char)fill, xx, yy, fg, bg); } } } }