Exemplo n.º 1
0
        public RenderLineEngine(int line, int width)
        {
            var c = ScreenSymbol.Create(' ', null, null);

            _theLine = new ScreenSymbol[width];
            for (var x = 0; x < _theLine.Length; x++)
            {
                _theLine[x] = c;
            }
        }
Exemplo n.º 2
0
        public IEnumerable <ScreenSymbol> RenderLine(IUiWindow uiWindow)
        {
            var backgroundColor = uiWindow.BackgroundColor;
            var foregroundColor = uiWindow.ForegroundColor;
            var result          = new List <ScreenSymbol>();

            foreach (var action in _actions)
            {
                switch (action)
                {
                case ChangeBackgroundColorCommand cbc:
                    backgroundColor = cbc.Color;
                    continue;

                case ChangeForegroundColorCommand cfc:
                    foregroundColor = cfc.Color;
                    continue;

                case ResetColorCommand _:
                    backgroundColor = uiWindow.BackgroundColor;
                    foregroundColor = uiWindow.ForegroundColor;
                    break;

                case string str:
                {
                    foreach (var c in str)
                    {
                        result.Add(ScreenSymbol.Create(c, backgroundColor, foregroundColor));
                        if (result.Count >= uiWindow.Width)
                        {
                            return(result);
                        }
                    }

                    break;
                }
                }
            }


            ScreenSymbol sc = null;

            while (result.Count < uiWindow.Width)
            {
                if (sc == null)
                {
                    sc = ScreenSymbol.Create(' ', backgroundColor, foregroundColor);
                }
                result.Add(sc);
            }

            return(result);
        }