Exemple #1
0
 protected override void OnPaint(ConsoleBitmap context)
 {
     context.Pen = new ConsoleCharacter(' ', backgroundColor: BorderElement.BackgroundColor);
     context.FillRectUnsafe(0, 0, Width, Height);
     context.Pen = new ConsoleCharacter(' ', backgroundColor: BorderElement.BorderColor);
     context.DrawLine(0, 0, 0, Height);
     context.DrawLine(1, 0, 1, Height);
     context.DrawLine(Width - 1, 0, Width - 1, Height);
     context.DrawLine(Width - 2, 0, Width - 2, Height);
     context.DrawLine(0, 0, Width, 0);
     context.DrawLine(0, Height - 1, Width, Height - 1);
 }
Exemple #2
0
        public void DrawLines()
        {
            var bitmap  = new ConsoleBitmap(80, 30);
            var centerX = bitmap.Width / 2;
            var centerY = bitmap.Height / 2;

            var app = new CliTestHarness(TestContext, bitmap.Width, bitmap.Height, true);

            app.QueueAction(async() =>
            {
                app.LayoutRoot.Add(new BitmapControl()
                {
                    Bitmap = bitmap
                }).Fill();
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Gray);
                bitmap.DrawLine(centerX, centerY, 0, centerY / 2);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Red);
                bitmap.DrawLine(centerX, centerY, 0, 0);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Yellow);
                bitmap.DrawLine(centerX, centerY, centerX / 2, 0);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Green);
                bitmap.DrawLine(centerX, centerY, centerX, 0);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Magenta);
                bitmap.DrawLine(centerX, centerY, (int)(bitmap.Width * .75), 0);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Cyan);
                bitmap.DrawLine(centerX, centerY, bitmap.Width - 1, 0);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Gray);
                bitmap.DrawLine(centerX, centerY, bitmap.Width - 1, centerY / 2);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.White);
                bitmap.DrawLine(centerX, centerY, 0, bitmap.Height / 2);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Blue);
                bitmap.DrawLine(centerX, centerY, bitmap.Width - 1, bitmap.Height / 2);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Gray);
                bitmap.DrawLine(centerX, centerY, 0, (int)(bitmap.Height * .75));
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Red);
                bitmap.DrawLine(centerX, centerY, 0, bitmap.Height - 1);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Yellow);
                bitmap.DrawLine(centerX, centerY, centerX / 2, bitmap.Height - 1);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Green);
                bitmap.DrawLine(centerX, centerY, centerX, bitmap.Height - 1);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Magenta);
                bitmap.DrawLine(centerX, centerY, (int)(bitmap.Width * .75), bitmap.Height - 1);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Cyan);
                bitmap.DrawLine(centerX, centerY, bitmap.Width - 1, bitmap.Height - 1);
                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();

                bitmap.Pen = new ConsoleCharacter('X', ConsoleColor.Gray);
                bitmap.DrawLine(centerX, centerY, bitmap.Width - 1, (int)(bitmap.Height * .75));

                await app.Paint().AsAwaitable();
                app.RecordKeyFrame();
                app.Stop();
            });

            app.Start().Wait();
            app.AssertThisTestMatchesLKG();
        }
Exemple #3
0
        public void DrawLinesReverse()
        {
            var bitmap  = new ConsoleBitmap(80, 30);
            var centerX = bitmap.Width / 2;
            var centerY = bitmap.Height / 2;

            var app = new CliTestHarness(TestContext, bitmap.Width, bitmap.Height, true);

            app.InvokeNextCycle(async() =>
            {
                app.LayoutRoot.Add(new BitmapControl()
                {
                    Bitmap = bitmap
                }).Fill();
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Gray), 0, centerY / 2, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Red), 0, 0, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Yellow), centerX / 2, 0, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Green), centerX, centerY, centerX, 0);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Magenta), (int)(bitmap.Width * .75), 0, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Cyan), bitmap.Width - 1, 0, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Gray), bitmap.Width - 1, centerY / 2, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.White), 0, bitmap.Height / 2, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Blue), bitmap.Width - 1, bitmap.Height / 2, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Gray), 0, (int)(bitmap.Height * .75), centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Red), 0, bitmap.Height - 1, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Yellow), centerX / 2, bitmap.Height - 1, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Green), centerX, bitmap.Height - 1, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Magenta), (int)(bitmap.Width * .75), bitmap.Height - 1, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Cyan), bitmap.Width - 1, bitmap.Height - 1, centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();

                bitmap.DrawLine(new ConsoleCharacter('X', ConsoleColor.Gray), bitmap.Width - 1, (int)(bitmap.Height * .75), centerX, centerY);
                await app.RequestPaintAsync();
                app.RecordKeyFrame();
                app.Stop();
            });

            app.Start().Wait();
            app.AssertThisTestMatchesLKG();
        }