private static void DrawGameBoard(ShowEventArg args, Graphics consoleGraphics, int size) { int horizIndention = 30; int vertIndention = 50; for (int i = 0; i < args.Board.GetLength(1); i++) { for (int j = 0; j < args.Board.GetLength(0); j++) { try { if (args.Board[j, i] != null) { consoleGraphics.FillEllipse(GetColor(args.Board[j, i].Col), new Rectangle( j * size + horizIndention, i * size + vertIndention, size, size)); } else { consoleGraphics.FillEllipse(Brushes.CornflowerBlue, new Rectangle(j * size + horizIndention, i * size + vertIndention, size, size)); } } catch (System.Runtime.InteropServices.ExternalException e) { //Console.WriteLine(e); } } } }
private void Updating(object sender, ShowEventArg arg) { Level.Text = (arg.Level + 1).ToString(); Score.Text = arg.Score.ToString(); BurnedLine.Text = arg.BurnedLine.ToString(); ShowGameBoard(arg); ShowNextFigure(arg); }
private void Update(object sender, ShowEventArg arg) { if (arg != null) { LevelLine.Text = (arg.Level + 1).ToString(); ScoreLine.Text = arg.BurnedLine.ToString(); ScoreText.Text = arg.Score.ToString(); DrawGameBoard(arg); DrawNextFigure(arg); } }
private void ShowNextFigure(ShowEventArg arg) { for (byte i = 0; i < arg.NextFigure.GetLength(1); i++) { for (byte j = 0; j < arg.NextFigure.GetLength(0); j++) { if (arg.NextFigure[j, i] != null) { Brush colorN = View.GetColor(arg.NextFigure[j, i].Col); _graphicNextFigure.FillEllipse(colorN, new Rectangle(j * SizePoint, i * SizePoint, SizePoint, SizePoint)); } else { _graphicNextFigure.FillEllipse(new SolidBrush(Color.FromArgb(182, 192, 235)), new Rectangle(j * SizePoint, i * SizePoint, SizePoint, SizePoint)); } } } }
private void DrawGameBoard(ShowEventArg arg) { if (arg.Board == null) { return; } gameBoard.Children.Clear(); for (byte i = 0; i < _height; i++) { for (byte j = 0; j < _width; j++) { if (arg.Board[j, i] != null) { SolidColorBrush color = View.GetColor(arg.Board[j, i].Col); gameBoard.Children.Add(View.CreateRectangle(color, j, i)); } } } }
private void DrawNextFigure(ShowEventArg arg) { if (arg.NextFigure == null) { return; } NextFigureBoard.Children.Clear(); for (byte i = 0; i < arg.NextFigure.GetLength(1); i++) { for (byte j = 0; j < arg.NextFigure.GetLength(0); j++) { if (arg.NextFigure[j, i] != null) { SolidColorBrush color = View.GetColor(arg.NextFigure[j, i].Col); NextFigureBoard.Children.Add(View.CreateRectangle(color, j, i)); } } } }
private void ShowGameBoard(ShowEventArg arg) { int boardWidth = arg.Board.GetLength(0); int boardHight = arg.Board.GetLength(1); for (byte i = 0; i < boardHight; i++) { for (byte j = 0; j < boardWidth; j++) { if (arg.Board[j, i] != null) { _graphicGameBoard.FillEllipse(View.GetColor(arg.Board[j, i].Col), new Rectangle(j * SizePoint, i * SizePoint, SizePoint, SizePoint)); } else { _graphicGameBoard.FillEllipse(new SolidBrush(Color.FromArgb(182, 192, 235)), new Rectangle(j * SizePoint, i * SizePoint, SizePoint, SizePoint)); } } } }
public static void Draw(object sender, ShowEventArg args) { _hWnd = GetConsoleWindow(); if (_hWnd != IntPtr.Zero) { _hDc = GetDC(_hWnd); if (_hDc != IntPtr.Zero) { int size = 25; Graphics consoleGraphics = Graphics.FromHdc(_hDc); DrawGameData(args, consoleGraphics); DrawGameBoard(args, consoleGraphics, size); DrawNextFigure(args, consoleGraphics, size); //font.Dispose(); //whitePen.Dispose(); //redPen.Dispose(); } //ReleaseDC(_hWnd, _hDc); //DeleteDC(_hDc); } }
private static void DrawGameData(ShowEventArg args, Graphics consoleGraphics) { int horizIndention = 315; int vertIndention = 200; try { var font = new Font("verdana", 13); consoleGraphics.FillRectangle(Brushes.RoyalBlue, new Rectangle(300, 190, 160, 160)); consoleGraphics.DrawString($"Level: {args.Level + 1}", font, Brushes.White, horizIndention, 200); consoleGraphics.DrawString($"Line: {args.BurnedLine}", font, Brushes.White, horizIndention, 40 + vertIndention); consoleGraphics.DrawString($"Score: {args.Score}", font, Brushes.White, horizIndention, 80 + vertIndention); } catch (System.Runtime.InteropServices.ExternalException e) { //Console.WriteLine(e); //throw; } }
private static void Update(object obj, ShowEventArg arg) { Drawing.Draw(obj, arg); }