public void Write(ConsoleCharacter consoleCharacter) { buffer.Pen = consoleCharacter; buffer.DrawPoint(CursorLeft, CursorTop); if (CursorLeft == BufferWidth - 1) { CursorLeft = 0; CursorTop++; } else { CursorLeft++; } }
protected override void OnPaint(ConsoleBitmap context) { for (var x = 0; x < Width && x < Bitmap.Width; x++) { for (var y = 0; y < Height & Y < Bitmap.Height; y++) { var c = Bitmap.GetPixel(x, y).Value; if (c.HasValue) { context.Pen = c.Value; context.DrawPoint(x, y); } } } }
public void TestPlaybackEndToEnd() { var app = new CliTestHarness(this.TestContext, 80, 30); app.InvokeNextCycle(async() => { int w = 10, h = 1; var temp = Path.GetTempFileName(); using (var stream = File.OpenWrite(temp)) { var writer = new ConsoleBitmapVideoWriter(s => stream.Write(Encoding.Default.GetBytes(s))); var bitmap = new ConsoleBitmap(w, h); for (var i = 0; i < bitmap.Width; i++) { bitmap.Fill(new ConsoleCharacter(' ')); bitmap.DrawPoint(new ConsoleCharacter(' ', backgroundColor: ConsoleColor.Red), i, 0); writer.WriteFrame(bitmap, true, TimeSpan.FromSeconds(.1 * i)); } writer.Finish(); } var player = app.LayoutRoot.Add(new ConsoleBitmapPlayer()).Fill(); Assert.IsFalse(player.Width == 0); Assert.IsFalse(player.Height == 0); player.Load(File.OpenRead(temp)); var playStarted = false; player.SubscribeForLifetime(nameof(player.State), () => { if (player.State == PlayerState.Playing) { playStarted = true; } else if (player.State == PlayerState.Stopped && playStarted) { app.Stop(); } }, app); await Task.Delay(100); await app.SendKey(new ConsoleKeyInfo('p', ConsoleKey.P, false, false, false)); }); app.Start().Wait(); Thread.Sleep(100); app.AssertThisTestMatchesLKGFirstAndLastFrame(); }
protected override void OnPaint(ConsoleBitmap context) { context.Pen = new PowerArgs.ConsoleCharacter('*', ConsoleColor.Red); context.DrawPoint(0, 0); }
protected override void OnPaint(ConsoleBitmap context) => context.DrawPoint((Element as AimLineSegment).Pen.Value, 0, 0);
protected override void OnPaint(ConsoleBitmap context) { context.Pen = new PowerArgs.ConsoleCharacter('#', ConsoleColor.DarkYellow, ConsoleColor.Black); context.DrawPoint(0, 0); }