Exemplo n.º 1
0
 private void printNumberNegRed(int number, int bufferY, int bufferX, bool rightAligned,
                                ConsoleColor defaultForeColor)
 {
     int deltaX = rightAligned ? -1 : 1;
     ConsoleColor foreColor = number < 0
                                  ? ConsoleColor.Red
                                  : defaultForeColor;
     number = Math.Abs(number);
     _printBuffer[bufferY, bufferX] =
         new ConsolePixel
             {
                 ForeColor = foreColor,
                 Char = (char) ((number%10) + '0')
             };
     if (number >= 10)
     {
         _printBuffer[bufferY, bufferX + deltaX] =
             new ConsolePixel
                 {
                     ForeColor = foreColor,
                     Char = (char) ((number/10) + '0')
                 };
     }
 }
Exemplo n.º 2
0
 private void PrintNumber(int number, int bufferY, int bufferX, bool rightAligned, ConsoleColor foreColor)
 {
     bool negative = number < 0;
     number = Math.Abs(number);
     char numChar = (number != 0) ? (char) ((number%10) + '0') : 'X';
     _printBuffer[bufferY, bufferX] = new ConsolePixel(numChar)
                                          {
                                              ForeColor = foreColor
                                          };
     if (number >= 10 || negative)
     {
         int deltaX = rightAligned ? -1 : 1;
         char c = negative ? '-' : (char) ((number/10) + '0');
         _printBuffer[bufferY, bufferX + deltaX] = new ConsolePixel(c)
                                                       {
                                                           ForeColor = foreColor
                                                       };
     }
 }