private HeaderValue CreateValue(int valueWidth, string title, Func <Point, HeaderValue> createHeader) { var consolePositionBefore = BetterConsole.Position; var totalWidth = valueWidth + title.Length + 1; if (CurrentHeaderPointer.X + totalWidth > BetterConsole.Width) { ForceNewLine(); } Console.ForegroundColor = ConsoleManager.Skin.FramesColor; BetterConsole.WriteAt("|", CurrentHeaderPointer.X, CurrentHeaderPointer.Y); BetterConsole.WriteAt("|", CurrentHeaderPointer.X + totalWidth, CurrentHeaderPointer.Y); Console.ForegroundColor = ConsoleManager.Skin.HeaderLabelColor; BetterConsole.WriteAt(title, CurrentHeaderPointer.X + 1, CurrentHeaderPointer.Y); var p = new Point(CurrentHeaderPointer.X + title.Length, CurrentHeaderPointer.Y); var headerValue = createHeader(p); CurrentHeaderPointer = new Point(CurrentHeaderPointer.X + totalWidth, CurrentHeaderPointer.Y); BetterConsole.Position = consolePositionBefore; Console.ResetColor(); return(headerValue); }
public void Update() { var p = BetterConsole.Position; Console.ForegroundColor = ConsoleManager.Skin.HeaderValueColor; if (HexMap != null) { for (int y = 0; y < Viewport.Height; y++) { var drawRow = ReverseY ? Viewport.Height - y - 1 : y; //BetterConsole.WriteAt(new string(' ', Viewport.Width), Viewport.X, drawRow + Viewport.Y); if (HexMap.YInBound(y + Offset.Y)) { var oddLine = y % 2 == 0; if (GetTileColor == null) { var line = ""; for (int x = 0; x < Viewport.Width / 2; x++) { if (HexMap.XInBound(x + Offset.X)) { line += _getTilePreview(HexMap[x + Offset.X, y + Offset.Y]); } else { line += EmptyChar; } } BetterConsole.WriteAt(line, Viewport.X, drawRow + Viewport.Y); } else { var oddOffset = -(y % 2); for (int col = 0; col < Viewport.Width / 2; col++) { if (HexMap.XInBound(col + Offset.X)) { var tile = HexMap[col + Offset.X, y + Offset.Y]; Console.ForegroundColor = GetTileColor(tile); BetterConsole.WriteAt(_getTilePreview(tile), 1 + oddOffset + col * 2 + Viewport.X, drawRow + Viewport.Y); } else { BetterConsole.WriteAt(EmptyChar, 1 + oddOffset + col * 2 + Viewport.X, drawRow + Viewport.Y); } } } } else { BetterConsole.WriteAt("", Viewport.X, drawRow + Viewport.Y); } } } Console.ResetColor(); BetterConsole.Position = p; }
public void Update() { var p = BetterConsole.Position; Console.ForegroundColor = ConsoleManager.Skin.HeaderValueColor; if (Grid != null) { for (int y = 0; y < GridPreviewHeight; y++) { if (Grid.YInBound(y + Offset.Y)) { if (GetTileColor == null) { var line = ""; for (int x = 0; x < GridPreviewWidth; x++) { if (Grid.XInBound(x + Offset.X)) { line += _getTilePreview(Grid[x + Offset.X, y + Offset.Y]); } else { line += EmptyChar; } } BetterConsole.WriteAt(line, Viewport.X, y + Viewport.Y); } else { for (int x = 0; x < GridPreviewWidth; x++) { if (Grid.XInBound(x + Offset.X)) { var tile = Grid[x + Offset.X, y + Offset.Y]; Console.ForegroundColor = GetTileColor(tile); BetterConsole.WriteAt(_getTilePreview(tile), x + Viewport.X, y + Viewport.Y); } else { BetterConsole.WriteAt(EmptyChar, x + Viewport.X, y + Viewport.Y); } } } } else { BetterConsole.WriteAt("", Viewport.X, y + Viewport.Y); } } } Console.ResetColor(); BetterConsole.Position = p; }
private void DrawPlane() { System.Console.ForegroundColor = ConsoleColor.Gray; string row = new String('O', 128); for (var y = 0; y < 4; y++) { BetterConsole.WriteAt(row, PlaneOffset.X, PlaneOffset.Y + y); } for (var y = 4; y < 8; y++) { BetterConsole.WriteAt(row, PlaneOffset.X, PlaneOffset.Y + y + 2); } }
public void SetTitle(int day, string title, int part) { Console.ForegroundColor = ConsoleManager.Skin.FramesColor; var line = new String('═', BetterConsole.Width - 2); var titleText = $" Day {day}: {title} - Part {part}".PadRight(BetterConsole.Width - 2); Console.ForegroundColor = ConsoleManager.Skin.FramesColor; BetterConsole.WriteAtLine($"╔{line}╗", 0); BetterConsole.WriteAtLine("║", 1); BetterConsole.WriteAt("║", BetterConsole.Width - 1, 1); BetterConsole.WriteAtLine($"╚{line}╝", 2); Console.ForegroundColor = ConsoleManager.Skin.DayTitleColor; BetterConsole.WriteAt(titleText, 1, 1); Console.ResetColor(); }
protected void WriteValue(string value) { var width = TotalWidth; var p = BetterConsole.Position; if (value.Length < width) { value = value.PadRight(width); } else if (value.Length > width) { value = value.ToString().Substring(0, width); } Console.ForegroundColor = ConsoleManager.Skin.HeaderValueColor; BetterConsole.WriteAt(value, Position.X, Position.Y); Console.ResetColor(); BetterConsole.Position = p; }
private Plane GetPlane(string input) { var seats = new List <Point>(); var plane = new Plane(seats); var index = 0; var tickets = input.Split("\n"); foreach (var item in tickets) { if (_progress != null) { _progress.SetValue(++index / (float)tickets.Count()); } var seat = ParseSeat(item); plane.TakenSeats[seat.X, seat.Y] = true; var rowFirst = plane.FirstSeat[seat.Y]; var rowLast = plane.LastSeat[seat.Y]; var displayY = seat.Y; if (seat.Y >= 4) { displayY += 2; } var wasFirstOrLast = false; if (rowFirst > seat.X) { wasFirstOrLast = true; if (rowFirst <= 128 && rowLast != rowFirst) { SetColorForCol(seat.Y); BetterConsole.WriteAt('X', PlaneOffset.X + rowFirst, PlaneOffset.Y + displayY); } plane.FirstSeat[seat.Y] = seat.X; System.Console.ForegroundColor = ConsoleColor.Red; BetterConsole.WriteAt('X', PlaneOffset.X + seat.X, PlaneOffset.Y + displayY); } if (rowLast < seat.X) { wasFirstOrLast = true; if (rowLast >= 0 && rowLast != rowFirst) { SetColorForCol(seat.Y); BetterConsole.WriteAt('X', PlaneOffset.X + rowLast, PlaneOffset.Y + displayY); } plane.LastSeat[seat.Y] = seat.X; System.Console.ForegroundColor = ConsoleColor.Red; BetterConsole.WriteAt('X', PlaneOffset.X + seat.X, PlaneOffset.Y + displayY); } if (!wasFirstOrLast) { SetColorForCol(seat.Y); BetterConsole.WriteAt('X', PlaneOffset.X + seat.X, PlaneOffset.Y + displayY); } seats.Add(seat); } return(plane); }
public static void WriteAt(char c, int x, int y) => BetterConsole.WriteAt(c, x, y);