Beispiel #1
0
        public override void Render(StyledCharacter[] buffer, Style style)
        {
            // Find the bottom row character index
            a++;
            var bottomRowCharIndex = buffer.Length - Console.WindowWidth;

            // Set background to accent
            for (int i = 0; i < Console.WindowWidth; i++)
            {
                if (i + bottomRowCharIndex < buffer.Length)
                {
                    buffer[i + bottomRowCharIndex] = new StyledCharacter(' ', new Style(style.AccentForeground, style.AccentBackground));
                }
            }

            var astring = a.ToString();
            // Write status
            var statusString = $"{Status} | {astring}";

            for (int i = 0; i < statusString.Length; i++)
            {
                if (i + bottomRowCharIndex < buffer.Length)
                {
                    buffer[i + bottomRowCharIndex].Character = statusString[i];
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Render a character in local coordinates
        /// </summary>
        /// <param name="buffer">The buffer to render to</param>
        /// <param name="colourBuffer">The colour buffer to render to</param>
        /// <param name="character">The character to render</param>
        /// <param name="foreground">The foreground to draw with</param>
        /// <param name="background">The background to draw with</param>
        /// <param name="positionX">Local position of the character on X axis</param>
        /// <param name="positionY">Local position of the character Y axis</param>
        protected void RenderLocalCharacter(StyledCharacter[] buffer, StyledCharacter character, int positionX, int positionY)
        {
            // Offset by component position
            var screenPositionX = positionX + PositionX;
            var screenPositionY = positionY + PositionY;

            // Try to draw the component
            var bufferPosition = GetBufferPosition(screenPositionX, screenPositionY);

            // Is the character in bounds?
            if (bufferPosition < buffer.Length)
            {
                buffer[bufferPosition] = character;
            }
        }
Beispiel #3
0
        public override void Render(StyledCharacter[] buffer, Style style)
        {
            if (this.StyleOverride != null)
            {
                style = StyleOverride.Value;
            }

            byte[] v        = System.Text.Encoding.UTF8.GetBytes(Text);
            var    nanoText = Console.OutputEncoding.GetChars(v);

            var pos = (PositionX + PositionY * Console.BufferWidth) * 2;

            for (int i = 0; i < nanoText.Length; i++)
            {
                buffer[(pos / 2) + i] = new StyledCharacter(nanoText[i], style);
            }
        }
Beispiel #4
0
        public virtual async Task <object> RunAsync()
        {
            //await Task.Run(() =>
            //{
            var drawCount = 0;

            // Init screen
            Console.BufferWidth   = Console.WindowWidth;
            Console.BufferHeight  = Console.WindowHeight;
            Console.CursorVisible = false;
            buffer = new StyledCharacter[Console.WindowWidth * (Console.WindowHeight)];


            Console.BackgroundColor = walletOptions.Style.AccentBackground;
            Console.Clear();

            while (true)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                // Run the logic for the page
                await RunPageLogic();

                // Update the draw buffer to the size of the console
                buffer = new StyledCharacter[Console.WindowWidth * (Console.WindowHeight)];
                // Initialize buffer
                for (int j = 0; j < buffer.Length; j++)
                {
                    buffer[j] = new StyledCharacter(' ', walletOptions.Style.Foreground, walletOptions.Style.Background);
                }

                RenderComponents();

                DrawBuffer();

                Thread.Sleep(10);
                drawCount++;
            }
            //});

            return(null);
        }