public void DrawTitle(Graphics g, List<byte> data) { _currentData = data; _drawKind = DrawKind.Title; g.Clear(SystemColors.Control); Brush brush = new SolidBrush(Color.Gray); int x = _XOffset; int y = 0; int scale = Scale; int pos = 0; int length = data.Count; while (pos < length) { byte b1 = data[pos]; ++pos; y += scale; if (b1 == 11) { g.FillRectangle(brush, x, y, scale, scale); } if (b1 == 200) { y = 0; x += scale; } } }
public void DrawPlayer(Graphics g, List <byte> data) { _currentData = data; _drawKind = DrawKind.Player; g.Clear(SystemColors.Control); Brush brush = new SolidBrush(Color.Gray); int x = _XOffset; int y = 0; int scale = Scale; int pos = 0; int length = data.Count; while (pos < length) { byte b1 = data[pos]; ++pos; y += scale; if (b1 == 15) { g.FillRectangle(brush, x, y, scale, scale); } if (b1 == 200) { y = 0; x += scale; } } }
/// <summary> /// Draws a rectangle in the console window. /// </summary> /// <param name="width">The width of the rectangle.</param> /// <param name="height">The right of the rectangle.</param> /// <param name="xLocation">The left side position.</param> /// <param name="yLocation">The top position.</param> /// <param name="drawKind">Where to draw the rectangle and where to leave the cursor when finished.</param> /// <param name="color">The color to use. null=uses current color Default: null</param> /// <param name="useDoubleLines">Enables double line boarders. Default: false</param> public static void Rectangle( int width, int height, int xLocation = 0, int yLocation = 0, DrawKind drawKind = DrawKind.FromTop, ConsoleColor?color = null, bool useDoubleLines = false) { // Save original cursor location int savedCursorTop = Console.CursorTop; int savedCursorLeft = Console.CursorLeft; if (drawKind == DrawKind.BelowCursor || drawKind == DrawKind.BelowCursorButKeepCursorLocation) { yLocation += Console.CursorTop; } // Save and then set cursor color ConsoleColor savedColor = Console.ForegroundColor; if (color.HasValue) { Console.ForegroundColor = color.Value; } char tl, tt, tr, mm, bl, br; if (useDoubleLines) { tl = '╔'; tt = '═'; tr = '╗'; mm = '║'; bl = '╚'; br = '╝'; } else { tl = '┌'; tt = '─'; tr = '┐'; mm = '│'; bl = '└'; br = '┘'; } SafeDraw(xLocation, yLocation, tl); for (int x = xLocation + 1; x < xLocation + width; x++) { SafeDraw(x, yLocation, tt); } SafeDraw(xLocation + width, yLocation, tr); for (int y = yLocation + height; y > yLocation; y--) { SafeDraw(xLocation, y, mm); SafeDraw(xLocation + width, y, mm); } SafeDraw(xLocation, yLocation + height + 1, bl); for (int x = xLocation + 1; x < xLocation + width; x++) { SafeDraw(x, yLocation + height + 1, tt); } SafeDraw(xLocation + width, yLocation + height + 1, br); // Restore cursor if (drawKind != DrawKind.BelowCursor) { Console.SetCursorPosition(savedCursorLeft, savedCursorTop); } if (color.HasValue) { Console.ForegroundColor = savedColor; } }