Esempio n. 1
0
 public static void ClearBuffer(string bufferName)
 {
     CheckBuffer(bufferName);
     var buffer = buffers[bufferName];
     buffer = new ZCharInfo[buffer.GetLength(0), buffer.GetLength(1)];
     SaveBuffer(bufferName, buffer);
 }
Esempio n. 2
0
 public static void PrintToBuffer(string bufferName, int x, int y, string text, Color foreColor, Color backColor = Color.Black)
 {
     CheckBuffer(bufferName);
     for (var i = 0; i < text.Length; i++)
     {
         buffers[bufferName][y,x+i] = new ZCharInfo(text[i], new ZCharAttribute(foreColor, backColor));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Fills a rectangle with specified coords with specified char.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="fillChar"></param>
        /// <param name="foreColor"></param>
        /// <param name="backColor"></param>
        public static void FillRect(int x, int y, int width, int height, char fillChar, Color foreColor = Color.Gray, Color backColor = Color.Black)
        {
            var newBuffer = new ZCharInfo[height,width];
            var charInfo = new ZCharInfo(Tools.Get_Ascii_Byte(fillChar), new ZCharAttribute(foreColor, backColor));

            for (var i = 0; i < height; i++)
                for (var j = 0; j < width; j++)
                    newBuffer[i,j] = charInfo;

            ZBuffer.SaveBuffer("FillRectBuffer", newBuffer);
            ZBuffer.WriteBuffer("FillRectBuffer", x, y);
        }
Esempio n. 4
0
        public static ZCharInfo[,] BackupBuffer(string bufferName)
        {
            CheckBuffer(bufferName);

            var buffer = buffers[bufferName];
            var sizeX = buffer.GetLength(1);
            var sizeY = buffer.GetLength(0);

            var resultBuffer = new ZCharInfo[sizeY,sizeX];
            for (var i = 0; i < sizeY; i++)
                for (var j = 0; j < sizeX; j++)
                    resultBuffer[i, j] = buffer[i, j];

            return resultBuffer;
        }
Esempio n. 5
0
 public static void PrintToBuffer(string bufferName, int x, int y, char charToWrite, Color foreColor, Color backColor = Color.Black)
 {
     CheckBuffer(bufferName);
     buffers[bufferName][y,x] = new ZCharInfo(charToWrite, new ZCharAttribute(foreColor, backColor));
 }
Esempio n. 6
0
 public static void CreateBuffer(string bufferName, int width, int height)
 {
     var newBuffer = new ZCharInfo[height,width];
     SaveBuffer(bufferName, newBuffer);
 }
Esempio n. 7
0
 public static void SaveBuffer(string bufferName, ZCharInfo[,] buffer)
 {
     if (buffers.ContainsKey(bufferName))
     {
         buffers[bufferName] = buffer;
     }
     else
     {
         buffers.Add(bufferName, buffer);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Reads a rectangular block of character and attribute information from the screen buffer into the passed array.
        /// </summary>
        /// <param name="bufferName">Name of the buffer to read to.</param>
        /// <param name="bufferX">The column position in the array where the first character is to be placed.</param>
        /// <param name="bufferY">The row position in the array where the first character is to be placed.</param>
        /// <param name="left">Column position of the top-left corner of the screen buffer area from which characters are to be read.</param>
        /// <param name="top">Row position of the top-left corner of the screen buffer area from which characters are to be read.</param>
        /// <param name="right">Column position of the bottom-right corner of the screen buffer area from which characters are to be read.</param>
        /// <param name="bottom">Row position of the bottom-right corner of the screen buffer area from which characters are to be read.</param>
        public static void ReadBuffer(string bufferName, int bufferX, int bufferY, int left, int top, int right, int bottom)
        {
            var buffer = new ZCharInfo[bottom-top+1,right-left+1];
            var bufferSize = new CoordInternal(buffer.GetLength(1), buffer.GetLength(0));
            var bufferPos  = new CoordInternal(bufferX, bufferY);
            var readRegion = new RectInternal(left, top, right, bottom);
            WinCon.ReadConsoleOutput(ZOutput.hConsoleOutput, buffer, bufferSize, bufferPos, readRegion);

            if (buffers.ContainsKey(bufferName))
            {
                buffers[bufferName] = buffer;
            }
            else
            {
                buffers.Add(bufferName, buffer);
            }
        }
Esempio n. 9
0
 public static void ShowCursor()
 {
     _charUnderCursor = GetCharInfo(_cursorPosition.X, _cursorPosition.Y);
     ZOutput.Print(_cursorPosition.X, _cursorPosition.Y, _currentCursor.UnicodeChar, _currentCursor.ForeColor, _currentCursor.BackColor);
 }
Esempio n. 10
0
 public static void SetCursorChar(char cursorChar, Color foreColor, Color backColor)
 {
     _currentCursor = new ZCharInfo(cursorChar, new ZCharAttribute(foreColor, backColor));
 }
Esempio n. 11
0
 public static ZCharInfo GetCharInfo(int x, int y)
 {
     var charInfo = new ZCharInfo(GetChar(x, y), GetCharAttributes(x, y));
     return charInfo;
 }
Esempio n. 12
0
        public static void DrawTable(int x, int y, Table.Table table)
        {
            table._validate();

            var width  = table.Dimensions.Width;
            var height = table.Dimensions.Height;
            var buffer = new Node[height, width];
            putFrameIntoBuffer(buffer, new Rect(0, 0, width-1 , height-1), table.Borders, table.BorderColors, table.FillColors);

            foreach (var cell in table.Cells)
            {
                putFrameIntoBuffer(buffer, cell.Dimensions, cell.Borders, cell.BorderColors, cell.FillColors);
            }

            var newBuffer = new ZCharInfo[height,width];

            for (var i = 0; i < height; i++)
            {
                for (var j = 0; j < width; j++)
                {
                    var charInfo = buffer[i, j];

                    newBuffer[i,j] = new ZCharInfo(
                        Tools.Get_Ascii_Byte(frameChars[charInfo.NodeEnumItem]),
                        new ZCharAttribute(charInfo.Colors.ForeColor, charInfo.Colors.BackColor));
                }
            }

            ZBuffer.SaveBuffer("TableBuffer", newBuffer);
            ZBuffer.WriteBuffer("TableBuffer", x, y);
        }