示例#1
0
 public static ZCharAttribute[] GetCharAttributes(int x, int y, int count)
 {
     var attrs = new ZCharAttribute[count];
     var countRead = 0;
     WinCon.ReadConsoleOutputAttribute(hConsoleOutput, attrs, count, new CoordInternal(x, y), ref countRead);
     return attrs;
 }
示例#2
0
 public static ZCharAttribute GetCharAttributes(int x, int y)
 {
     var attrs = new ZCharAttribute[1];
     var countRead = 0;
     WinCon.ReadConsoleOutputAttribute(hConsoleOutput, attrs, 1, new CoordInternal(x, y), ref countRead);
     return attrs[0];
 }
示例#3
0
        public static void FillRectCharAttribute(int left, int top, int right, int bottom, ZCharAttribute attribute)
        {
            var result = 0;
            var width  = right  - left + 1;
            var height = bottom - top  + 1;

            for (var i = 0; i < height; i++)
            {
                var coord = new CoordInternal(left, top+i);
                WinCon.FillConsoleOutputAttribute(hConsoleOutput, attribute, width, coord, ref result);
            }
        }
示例#4
0
 public static void FillRectCharAttribute(Rect rect, ZCharAttribute attribute)
 {
     FillRectCharAttribute(rect.Left, rect.Top, rect.Right, rect.Bottom, attribute);
 }
示例#5
0
 public static void FillCharAttribute(int x, int y, ZCharAttribute attribute, int count = 1)
 {
     var result = 0;
     var coord = new CoordInternal(x, y);
     WinCon.FillConsoleOutputAttribute(hConsoleOutput, attribute, count, coord, ref result);
 }
示例#6
0
 public static void Print(int x, int y, char text, ZCharAttribute colors)
 {
     ZColors.SetBackColor(colors.BackColor);
     Print(x, y, text, colors.ForeColor);
 }
示例#7
0
 public static void Print(int x, int y, float value, ZCharAttribute colors)
 {
     ZColors.SetBackColor(colors.BackColor);
     Print(x, y, value, colors.ForeColor);
 }
示例#8
0
 public static extern bool FillConsoleOutputAttribute(
     IntPtr hConsoleOutput,
     ZCharAttribute wAttribute,
     int nLength,
     CoordInternal dwWriteCoord,
     ref int lpNumberOfAttrsWritten);
示例#9
0
 public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, ZCharAttribute attr);
示例#10
0
        private static void putFrameIntoBuffer(Node[,] buffer, Rect dimensions, FrameBorders borders, ZCharAttribute? borderColors, ZCharAttribute? fillColors)
        {
            currentBuffer = buffer;

            fillColors = fillColors ?? new ZCharAttribute();
            var node = new Node{ Colors = fillColors.Value, NodeEnumItem = NodeEnum.None };
            for (var i = dimensions.Top+1; i < dimensions.Bottom; i++)
                for (var j = dimensions.Left+1; j < dimensions.Right; j++)
                    buffer[i, j] = node;

            applyBorders(    SidesEnum.Down | SidesEnum.Right, dimensions.Left,  dimensions.Top, borders.LeftBorder,  borders.TopBorder, borderColors);
            for (var i = dimensions.Left + 1; i < dimensions.Right; i++)
                applyBorders(SidesEnum.Left | SidesEnum.Right, i,                dimensions.Top, borders.LeftBorder,  borders.TopBorder, borderColors);
            applyBorders(    SidesEnum.Down | SidesEnum.Left,  dimensions.Right, dimensions.Top, borders.RightBorder, borders.TopBorder, borderColors);

            for (var i = dimensions.Top + 1; i < dimensions.Bottom; i++)
            {
                applyBorders(SidesEnum.Up | SidesEnum.Down, dimensions.Left,  i, borders.LeftBorder,  borders.TopBorder, borderColors);
                applyBorders(SidesEnum.Up | SidesEnum.Down, dimensions.Right, i, borders.RightBorder, borders.TopBorder, borderColors);
            }

            applyBorders(    SidesEnum.Up   | SidesEnum.Right, dimensions.Left,  dimensions.Bottom, borders.LeftBorder,  borders.BottomBorder, borderColors);
            for (var i = dimensions.Left + 1; i < dimensions.Right; i++)
                applyBorders(SidesEnum.Left | SidesEnum.Right, i,                dimensions.Bottom, borders.LeftBorder,  borders.BottomBorder, borderColors);
            applyBorders(    SidesEnum.Up   | SidesEnum.Left,  dimensions.Right, dimensions.Bottom, borders.RightBorder, borders.BottomBorder, borderColors);
        }
示例#11
0
        private static void applyBorders(SidesEnum sides, int xPos, int yPos, FrameType verticalBorder, FrameType horizontalBorder, ZCharAttribute? colors)
        {
            var currentResult = currentBuffer[yPos, xPos];
            var currentNode = currentResult.NodeEnumItem;

            var resultLeft	= Math.Max((int)(currentNode & (NodeEnum.LeftSingle  | NodeEnum.LeftDouble)),  (int)(sides & SidesEnum.Left)  * (int)horizontalBorder);
            var resultRight = Math.Max((int)(currentNode & (NodeEnum.RightSingle | NodeEnum.RightDouble)), (int)(sides & SidesEnum.Right) * (int)horizontalBorder);
            var resultUp    = Math.Max((int)(currentNode & (NodeEnum.UpSingle    | NodeEnum.UpDouble)),    (int)(sides & SidesEnum.Up)    * (int)verticalBorder);
            var resultDown	= Math.Max((int)(currentNode & (NodeEnum.DownSingle  | NodeEnum.DownDouble)),  (int)(sides & SidesEnum.Down)  * (int)verticalBorder);

            currentResult.NodeEnumItem = (NodeEnum)(resultLeft | resultRight | resultUp | resultDown);
            currentResult.Colors = colors.HasValue ? colors.Value : currentResult.Colors;
            currentBuffer[yPos, xPos] = currentResult;
        }
示例#12
0
        public static void HighlightCell(int left, int top, int right, int bottom, Color foreColor, Color backColor)
        {
            var attribute = new ZCharAttribute(foreColor, backColor);
            ZOutput.FillCharAttribute(left, top, attribute, right-left+1);

            for (var i = 1; i < bottom-top; i++)
            {
                ZOutput.FillCharAttribute(left,  top + i, attribute);
                ZOutput.FillCharAttribute(right, top + i, attribute);
            }
            ZOutput.FillCharAttribute(left, bottom, attribute, right-left+1);
        }