Ejemplo n.º 1
0
        public static void DrawField()
        {
            Console.SetCursorPosition(Field[0].X, Field[0].Y);
            Console.Write("+" + new string('-', Field[1].X) + "+");
            Console.SetCursorPosition(Field[0].X, Field[0].Y + Field[1].Y + 1);
            Console.Write("+" + new string('-', Field[1].X) + "+");
            Console.SetCursorPosition(0, Field[0].Y + 1);
            for (int line = 0; line < Field[1].Y; ++line)
            {
                Console.WriteLine(new string(' ', Field[0].X) + "|".PadRight(Field[1].X + 1) + "|");
            }
            var fore = Console.ForegroundColor;

            foreach (var apple in Apples)
            {
                Console.SetCursorPosition(apple.X, apple.Y);
                Console.ForegroundColor = Color.Red;
                Console.Write(((apple.X ^ apple.Y) & 0x01) == 1 ? '9' : '6');
            }
            foreach (var cure in Cures)
            {
                Console.SetCursorPosition(cure.X, cure.Y);
                Console.ForegroundColor = Color.Yellow;
                Console.Write("C");
            }
            foreach (var poison in Poisons)
            {
                Console.SetCursorPosition(poison.X, poison.Y);
                Console.ForegroundColor = Color.Magenta;
                Console.Write("P");
            }
            Console.ForegroundColor = fore;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Prints a string to the console using the center print function.
        /// </summary>
        /// <param name="PrintThis"></param>
        public static void CenterConsolePrint(string PrintThis)
        {
            // Printing color styles
            StyleSheet PrintStyleSheet = new StyleSheet(Color.White);

            PrintStyleSheet.AddStyle(@"OBS Switcher Version \d+(.|\s)\d+(.|\s)\d+\s", Color.Lime, match => match.ToString());
            PrintStyleSheet.AddStyle(@"~(\S+\s+)[^~]+~", Color.White, match => match.Replace("~", " ").ToString());
            PrintStyleSheet.AddStyle(@"=(\S+\s+)[^=]+=", Color.Yellow, match => match.Replace("=", " ").ToString());
            PrintStyleSheet.AddStyle(@"OBS HotKeys|Pane Sizes|Other Pane Commands", Color.GreenYellow, match => match.ToString());
            PrintStyleSheet.AddStyle(@"\+|-{2,}|\|", Color.DarkGray, match => match.ToString());
            PrintStyleSheet.AddStyle(@"Full View|Full Output", Color.LightSkyBlue, match => match.ToString());
            PrintStyleSheet.AddStyle(@"Pane \d+", Color.LightSkyBlue, match => match.ToString());
            PrintStyleSheet.AddStyle(@" \+ ", Color.White, match => match.ToString());
            PrintStyleSheet.AddStyle(@"CTL|ALT|SHIFT", Color.Gray, match => match.ToString().Replace("+", String.Empty));
            PrintStyleSheet.AddStyle(@"\+ (\S) ", Color.Aquamarine, match => match.Split('+').LastOrDefault());
            PrintStyleSheet.AddStyle(@"Left Edge", Color.Yellow, match => match.Replace("px", String.Empty));
            PrintStyleSheet.AddStyle(@"\d{4}", Color.Aquamarine, match => match.Replace("px", String.Empty));
            PrintStyleSheet.AddStyle(@"px", Color.White, match => match.ToString());
            PrintStyleSheet.AddStyle(@"\'\S{1}\'", Color.HotPink, match => match.ToString());
            PrintStyleSheet.AddStyle(@"ENTER|ESCAPE", Color.HotPink, match => match.ToString());

            // Print the styled console sheet.
            if (Console.WindowWidth % 2 != 0)
            {
                Console.SetCursorPosition(((Console.WindowWidth - PrintThis.Length) / 2) + 1, Console.CursorTop);
            }
            else
            {
                Console.SetCursorPosition(((Console.WindowWidth - PrintThis.Length) / 2), Console.CursorTop);
            }
            Console.WriteLineStyled(PrintThis, PrintStyleSheet);
        }
Ejemplo n.º 3
0
    public static void ha_youDied()
    {
        var co  = ConsoleColor.Yellow;
        var coo = ConsoleColor.Red;

        //ConsoleB.SetCursorPosition(86, 34);
        //ConsoleB.BackgroundColor = _back;
        //ConsoleB.Write("Press space to restart", Color.Blue);
        while (true)
        {
            ConsoleB.SetCursorPosition(0, 20);
            ConsoleB.BackgroundColor       = _back;
            System.Console.ForegroundColor = co;
            //ConsoleB.Write("haha", co);
            System.Console.Write(@"
                   __ __                                              __
                  / // / ___ _ ___ _          __ __ ___  __ __       / / ___   ___ ___
                 / _  / / _ `// _ `/ _       / // // _ \/ // /      / / / _ \ (_-</ -_)
                /_//_/  \_,_/ \_,_/ ( )      \_, / \___/\_,_/      /_/  \___//___/\__/
                                    |/      /___/
                space to continue
", 0, 20);
            Thread.Sleep(200);
            var buf = co;
            co  = coo;
            coo = buf;
            //}
        }
    }
Ejemplo n.º 4
0
        public static void DrawSnake()
        {
            var head  = Snake[Snake.Count - 1];
            var newXY = Move(head);

            if (Snake.IndexOf(newXY) >= 0)
            {
                if (Snake.IndexOf(newXY) == Snake.Count - 2)
                {
                    Reverse();
                    newXY = Move(head);
                }
                else
                {
                    SubstractLife();
                    return;
                }
            }
            if (newXY.X == Field[0].X || newXY.X == Field[0].X + Field[1].X + 1 ||
                newXY.Y == Field[0].Y || newXY.Y == Field[0].Y + Field[1].Y + 1)
            {
                SubstractLife();
                return;
            }
            if (Cures.Remove(newXY))
            {
                ++Lifes;
                ++RecordInfo.TotalCures;
                ++RecordInfo.TotalLifes;
            }
            if (Poisons.Remove(newXY))
            {
                Console.SetCursorPosition(newXY.X, newXY.Y);
                Console.Write(' ');
                ++RecordInfo.TotalPoisons;
                SubstractLife();
                return;
            }
            var fore = Console.ForegroundColor;

            Console.ForegroundColor = Color.LimeGreen;
            if (!Apples.Remove(newXY))
            {
                Snake.RemoveAt(0);
            }
            else
            {
                ++Score;
                ++RecordInfo.TotalScore;
            }
            foreach (var coord in Snake)
            {
                Console.SetCursorPosition(coord.X, coord.Y);
                Console.Write('#');
            }
            Snake.Add(newXY);
            Console.SetCursorPosition(newXY.X, newXY.Y);
            Console.Write('O');
            Console.ForegroundColor = fore;
        }
Ejemplo n.º 5
0
        } //ErrorMessage
        static void ConsoleDraw(IEnumerable<string> lines, int x, int y) //pulled from https://stackoverflow.com/questions/2725529/how-to-create-ascii-animation-in-windows-console-application-using-c
        {
            if (x > Console.WindowWidth) return;
            if (y > Console.WindowHeight) return;

            var trimLeft = x < 0 ? -x : 0;
            int index = y;

            x = x < 0 ? 0 : x;
            y = y < 0 ? 0 : y;

            var linesToPrint =
                from line in lines
                let currentIndex = index++
                where currentIndex > 0 && currentIndex < Console.WindowHeight
                select new
                {
                    Text = new String(line.Skip(trimLeft).Take(Math.Min(Console.WindowWidth - x, line.Length - trimLeft)).ToArray()),
                    X = x,
                    Y = y++
                };

            Console.Clear();
            foreach (var line in linesToPrint)
            {
                Console.SetCursorPosition(line.X, line.Y);
                Console.Write(line.Text);
            }
        }//ConsoleDraw
Ejemplo n.º 6
0
        public void Start()
        {
            Console.Clear();

            while (!ALineWon())
            {
                for (int i = 0; i < RacingLines.Count; ++i)
                {
                    RacingLines[i].TryToRun();
                }

                Thread.Sleep(20);
            }

            Line winner = GetWinningLine();

            Console.Clear();

            int    consoleHalfWidth = Console.WindowWidth / 2;
            string winningLineMsg   = "The Winning Line is: ";

            Console.SetCursorPosition(consoleHalfWidth - (winningLineMsg.Length / 2), (Console.WindowHeight / 2) - 5);
            Console.WriteLine(winningLineMsg, Color.White);
            Console.SetCursorPosition((Console.WindowWidth / 2) - 4, (Console.WindowHeight / 2) - 3);
            Console.Write(winner.Symbol, winner.LineColors.Colors[0]);
            Console.Write(winner.Symbol, winner.LineColors.Colors[1]);
            Console.Write(winner.Symbol, winner.LineColors.Colors[0]);
            Console.Write(winner.Symbol, winner.LineColors.Colors[1]);
            Console.Write(winner.Symbol, winner.LineColors.Colors[0]);
            Console.Write(winner.Symbol, winner.LineColors.Colors[1]);

            Console.ForegroundColor = Color.White;
            Console.ReadKey();
        }
Ejemplo n.º 7
0
 //  this is my constructor
 public snake()
 {
     // generate the snake body
     snake_body.Add(new int[] { 50, 11 });   // if the colum is even, then the gen should generate even position for food
     snake_body.Insert(1, new int[] { 50, 12 });
     snake_drawHead(snake_body[0], Color.Indigo);
     snake_drawBody(snake_body[1]);
     drawwing.WriteAt(
         "press arrowKey to move the snake", 35, 15, back: _back, fore: Color.FromArgb(120, 1, 225));
     drawwing.WriteAt("press shift while press arrowKey to speed up", 35, 16, back: _back, fore: Color.FromArgb(120, 1, 225));
     drawwing.WriteAt("eat you own tail,hehe", 35, 17, back: _back, fore: Color.FromArgb(120, 1, 225));
     drawwing.WriteAt("NOW, are you ready?(press Enter)", 35, 19, back: _back, fore: Color.FromArgb(120, 1, 225));
     ConsoleB.SetCursorPosition(35, 15);
     feed.body = snake_body;
     while (true)
     {
         drawwing.WriteAt("press Enter", 55, 19, back: _back, fore: Color.PowderBlue);
         drawwing.WriteAt("press Enter", 55, 19, back: _back, fore: Color.Red);
         Thread.Sleep(100);
         drawwing.WriteAt("press Enter", 55, 19, back: _back, fore: Color.PowderBlue);
         if (ConsoleB.ReadKey(true).Key == ConsoleKey.Enter)
         {
             break;
         }
         Thread.Sleep(50);
     }
     drawwing.WriteAt("                                ", 35, 15);
     drawwing.WriteAt("                                            ", 35, 16);
     drawwing.WriteAt("                          ", 35, 17);
     drawwing.WriteAt("                                ", 35, 19);
 }
Ejemplo n.º 8
0
 private static void InitializePlayfield()
 {
     for (int i = 0; i < PField.GetLength(0); i++)
     {
         for (int j = 0; j < PField.GetLength(1); j++)
         {
             PField[i, j] = new Block(false, Color.Black);
         }
     }
     Console.ForegroundColor  = BorderColor;
     PField[0, 0]             = new Block(true, BorderColor);
     PField[PFP.Width + 1, 0] = new Block(true, BorderColor);
     for (int i = 0; i < PFP.Height; i++)
     {
         Console.SetCursorPosition(PFP.X, PFP.Y + i);
         Console.Write(new string(BorderChar, 2) + new string(SpaceChar, PFP.Width * 2) + new string(BorderChar, 2));
         PField[0, i + 1]             = new Block(true, BorderColor);
         PField[PFP.Width + 1, i + 1] = new Block(true, BorderColor);
     }
     Console.SetCursorPosition(PFP.X, PFP.Y + PFP.Height);
     Console.Write(new string(BorderChar, 4 + PFP.Width * 2));
     for (int i = 0; i < PField.GetLength(0); i++)
     {
         PField[i, PFP.Height + 1] = new Block(true, BorderColor);
     }
 }
Ejemplo n.º 9
0
 public static void DrawWelcome()
 {
     Console.BackgroundColor = Color.DarkSlateBlue;
     Console.Clear();
     Console.ForegroundColor = Color.LightYellow;
     Console.SetCursorPosition(0, Console.WindowHeight / 2 - 1);
     Console.Write(Center(StringWelcome, Console.WindowWidth));
 }
Ejemplo n.º 10
0
        public static void RewriteLine(int line, string newtext)
        {
            int currentline = Console.CursorTop;

            Console.SetCursorPosition(0, currentline - line);
            Console.Write(newtext); Console.WriteLine(new string(' ', Console.WindowWidth - newtext.Length));
            Console.SetCursorPosition(0, currentline);
        }
Ejemplo n.º 11
0
        static void t()
        {
            int i  = 0;
            int st = 6;

            Console.Clear();
            Console.WriteAscii(" CPU MONITOR V1.0 ", Color.FromArgb(255, 0, 200));
            Console.SetCursorPosition(0, 5);
            Console.WriteLine("  CPU TEMP", Color.Red);
            while (true)
            {
                Computer myComputer = new Computer();
                myComputer.CPUEnabled = true;
                myComputer.Open();
                List <int> ctemp_value = new List <int>();

                foreach (var hardwareItem in myComputer.Hardware)
                {
                    foreach (var sensor in hardwareItem.Sensors)
                    {
                        if (sensor.Identifier.ToString() == "/intelcpu/0/temperature/0" || sensor.Identifier.ToString() == "/intelcpu/0/temperature/1" || sensor.Identifier.ToString() == "/intelcpu/0/temperature/2" || sensor.Identifier.ToString() == "/intelcpu/0/temperature/3")
                        {
                            string name = sensor.Identifier.ToString();
                            name = name.Replace("/intelcpu/0/temperature/", "CPU ");
                            ctemp_value.Add(Convert.ToInt32(sensor.Value));
                        }
                    }
                }//COLOR
                int r = 255;
                int g = 0;
                int b = 255;

                double avg = ctemp_value.Average();
                //print cpu
                Console.SetCursorPosition(0, st);
                Console.Write("\r  CPU 0 : {0}%   ", ctemp_value[0], Color.FromArgb(r, g, b));
                Console.SetCursorPosition(0, st + 1);
                Console.Write("\r  CPU 1 : {0}%   ", ctemp_value[1], Color.FromArgb(r, g, b));
                Console.SetCursorPosition(0, st + 2);
                Console.Write("\r  CPU 2 : {0}%   ", ctemp_value[2], Color.FromArgb(r, g, b));
                Console.SetCursorPosition(0, st + 3);
                Console.Write("\r  CPU 3 : {0}%   ", ctemp_value[3], Color.FromArgb(r, g, b));
                Console.SetCursorPosition(0, st + 4);
                Console.Write("\r  AVG {0}%   ", avg, Color.FromArgb(r, g, b));
                //SEt DELEY
                i += 1;
                if (i % 2 == 0)
                {
                    s.Write("1");
                }
                else
                {
                    s.Write("2");
                }
                Thread.Sleep(300);
            }
        }
Ejemplo n.º 12
0
        public static void DrawTime()
        {
            var label = Fill($"Elapsed: {TimeToString(GameTime)}", 4);
            var fore  = Console.ForegroundColor;
            var back  = Console.BackgroundColor;

            Console.SetCursorPosition((Console.WindowWidth - label.Length) / 2, 1);
            Console.WriteWithGradient(label, Color.LightSeaGreen, Color.Red, 4);
        }
Ejemplo n.º 13
0
 public static void WriteAt(string s, int x, int y, Color fore, Color back)
 {
     lock (lock_write)
     {
         ConsoleB.ForegroundColor = fore;
         ConsoleB.BackgroundColor = back;
         ConsoleB.SetCursorPosition(x, y);
         ConsoleB.Write(s);
     }
 }
Ejemplo n.º 14
0
        public void TryToRun()
        {
            Console.SetCursorPosition(WindowWidthPos, WindowHeightPos);

            if (Rand.NextDouble() < LineAdvanceRate)
            {
                Console.WriteAlternating(Symbol, LineColors);

                WindowWidthPos++;
            }
        }
Ejemplo n.º 15
0
 public static void WriteAt(string s, int x, int y)
 {
     lock (lock_write)
     {
         ConsoleB.ForegroundColor = Color.White;
         ConsoleB.BackgroundColor = _back;
         ConsoleB.SetCursorPosition(x, y);
         ConsoleB.Write(s);
         //ConsoleB.ForegroundColor = Color.White;
         //ConsoleB.BackgroundColor = Color.DarkCyan;
     }
 }
Ejemplo n.º 16
0
 public static void DrawGameOver()
 {
     Pause   = true;
     CanPlay = false;
     WType   = WindowType.GameOver;
     Console.BackgroundColor = Color.DarkMagenta;
     Console.Clear();
     Console.ForegroundColor = Color.White;
     Console.SetCursorPosition(0, Console.WindowHeight / 2 - 1);
     Console.Write(Center(StringGameOver, Console.WindowWidth));
     Console.Write(Center($"Total score: {Score} | Game time: " + TimeToString(GameTime), Console.WindowWidth));
 }
Ejemplo n.º 17
0
 public static void WriteAt(char s, int x, int y, ColorAlternator alter)
 {
     lock (lock_write)
     {
         //ConsoleB.ForegroundColor = fore;
         //ConsoleB.BackgroundColor = back;
         ConsoleB.BackgroundColor = _back;
         ConsoleB.SetCursorPosition(x, y);
         ConsoleB.WriteAlternating(s, alter);
         //ConsoleB.ForegroundColor = Color.White;
         //ConsoleB.BackgroundColor = Color.White;
     }
 }
Ejemplo n.º 18
0
        public static void DrawStatus()
        {
            var status = $" Lifes: {Lifes} | Score: {Score} ";

            Console.SetCursorPosition(0, 0);
            var fore = Console.ForegroundColor;
            var back = Console.BackgroundColor;

            Console.BackgroundColor = Color.DarkCyan;
            Console.ForegroundColor = Color.White;
            Console.Write(Center(status, Console.WindowWidth, '='));
            Console.ForegroundColor = fore;
            Console.BackgroundColor = back;
        }
Ejemplo n.º 19
0
    public static void death_comic(int score)
    {
        string buf = "     " + "SCORE : " + (score * 10).ToString();

        ConsoleB.BackgroundColor = _back;
        ConsoleB.Clear();
        for (int i = 10; i >= 0; --i)
        {
            ConsoleB.BackgroundColor = _back;
            ConsoleB.SetCursorPosition(0, 14);
            Thread.Sleep(70);
            ConsoleB.WriteAscii(buf.Remove(0, i), color: Color.Black);
        }
    }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            Console.Write("Starting up");
            for (int i = 0; i < 12; i++)
            {
                Sleep(200);
                Console.Write(".");
            }

            for (int i = 0; i < 4; i++)
            {
                Sleep(10);
                Console.Write(".");
            }



            Console.WriteLine("\nDone!");
            Sleep(1000);

            Console.ResetColor();
            Console.BackgroundColor = Color.Black;
            Console.ReplaceColor(Color.Black, Color.FromArgb(0, 30, 0));


            while (true)
            {
                for (int i = 0; i < 3; i++)
                {
                    Sleep(300);
                    Console.Write(".");
                }
                Console.Clear();

                Console.WriteLine("Give me your message that you want to see in color");

                string inp = Console.ReadLine();

                if (inp == "stop")
                {
                    break;
                }

                Console.SetCursorPosition(0, Console.CursorTop - 1);
                RainbowText(inp);
            }

            Console.WriteLine("Until next time!", Color.Red);
        }
Ejemplo n.º 21
0
        public void Message(MessageTypes MessageType)
        {
            if (MessageType == MessageTypes.WelcomeMessage)
            {
                int DA = 195;
                int V  = 176;
                int ID = 145;
                Console.WriteAscii("      Welcome        ", Color.FromArgb(DA, V, ID));
                Console.WriteLine("   ");
                Console.WriteLine("     ");
                string      welcome = "Welcome to the great maze game .... To start Press {0}, to exit Press {1}";
                Formatter[] choices = new Formatter[]
                { new Formatter("1", Color.DarkGoldenrod),
                  new Formatter("ESC", Color.DarkGoldenrod) };
                Console.SetCursorPosition((Console.WindowWidth - welcome.Length) / 2, Console.CursorTop);
                Console.WriteLine("  ");
                Console.WriteLineFormatted(welcome, Color.Khaki, choices);
                return;
            }
            if (MessageType == MessageTypes.InvalidInput)
            {
                Console.WriteLine("please enter valid number ", Color.DarkRed);
                Console.WriteLine("         ");
                return;
            }
            if (MessageType == MessageTypes.Instruction)
            {
                Console.WriteLine("Start using the arrows to play ");
                Console.WriteLine("         ");
                return;
            }
            if (MessageType == MessageTypes.outsideMaze)
            {
                Console.WriteLine(" you are now outside the maze borders , please choose another step", Color.DarkOrange);
            }
            if (MessageType == MessageTypes.NewGame)
            {
                string      welcome = "Have fun and start new game! .... To start Press {0}, to exit Press {1}";
                Formatter[] choices = new Formatter[]
                { new Formatter("1", Color.DarkGoldenrod),
                  new Formatter("ESC", Color.DarkGoldenrod) };
                Console.SetCursorPosition((Console.WindowWidth - welcome.Length) / 2, Console.CursorTop);
                Console.WriteLine("  ");
                Console.WriteLineFormatted(welcome, Color.Khaki, choices);

                return;
            }
        }
Ejemplo n.º 22
0
 private static void DrawBlock(Piece piece, Vector pos, bool space = false)
 {
     Console.ForegroundColor = piece.Color;
     for (int i = 0; i < piece.Matrix.GetLength(0); i++)
     {
         for (int j = 0; j < piece.Matrix.GetLength(1); j++)
         {
             if (piece.Matrix[i, j])
             {
                 Console.SetCursorPosition(pos.X + j * 2 - 1, pos.Y + i - 1);
                 Console.Write(space ? new string(SpaceChar, 2) : new string(PieceChar, 2));
                 PField[j + (pos.X - PFP.X) / 2 - 1, i + pos.Y - PFP.Y] = new Block(!space, piece.Color);
             }
         }
     }
 }
Ejemplo n.º 23
0
        public void GameOver(Play play)
        {
            int DA = 255;
            int V  = 0;
            int ID = 0;

            Console.WriteAscii("       Game Over       ", Color.FromArgb(DA, V, ID));
            Console.WriteLine("   ");
            Console.WriteLine("     ");
            string s = "You lost the game with " + play.Steps + " Steps and " + play.HP + " Hp.";

            Console.SetCursorPosition((Console.WindowWidth - s.Length) / 2, Console.CursorTop);
            Console.WriteLine(s, Color.FromArgb(DA, V, ID));
            RenderMaze(play);
            Console.WriteLine("   ");
            Message(MessageTypes.NewGame);
        }
Ejemplo n.º 24
0
        public void Congratulations(Play play)
        {
            int DA = 34;
            int V  = 139;
            int ID = 34;

            Console.WriteAscii("      Congratulations       ", Color.FromArgb(DA, V, ID));
            Console.WriteLine("   ");
            Console.WriteLine("     ");
            string s = "You Wins the game with Only " + play.Steps + " Steps and " + play.HP + " Hp.";

            Console.SetCursorPosition((Console.WindowWidth - s.Length) / 2, Console.CursorTop);
            Console.WriteLine(s, Color.FromArgb(DA, V, ID));
            RenderMaze(play);
            Console.WriteLine("   ");
            Message(MessageTypes.NewGame);
        }
        /// <summary>
        /// Write directly at a given position of the screen
        /// </summary>
        /// <param name="textBuilder"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="directOutputMode">The mode which indicates when the text should be cleared</param>
        public void WriteAt(ColorTextBuilder textBuilder, int xPos, int yPos, DirectOutputMode directOutputMode)
        {
            var left = Console.CursorLeft;
            var top  = Console.CursorTop;

            Console.SetCursorPosition(xPos, yPos);
            _historyLock.Wait();
            try
            {
                _directOutputEntries.Add(new DirectOutputEntry(textBuilder, xPos, yPos, directOutputMode));
            }
            finally
            {
                _historyLock.Release();
            }
            Console.SetCursorPosition(left, top);
            _hasLogUpdates = true;
        }
        /// <summary>
        /// Write directly at a given position of the screen
        /// </summary>
        /// <param name="text"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="directOutputMode">The mode which indicates when the text should be cleared</param>
        public void WriteAt(string text, int xPos, int yPos, DirectOutputMode directOutputMode, Color?foregroundColor = null, Color?backgroundColor = null)
        {
            var left = Console.CursorLeft;
            var top  = Console.CursorTop;

            Console.SetCursorPosition(xPos, yPos);
            _historyLock.Wait();
            try
            {
                _directOutputEntries.Add(new DirectOutputEntry(text, xPos, yPos, directOutputMode, foregroundColor, backgroundColor));
            }
            finally
            {
                _historyLock.Release();
            }
            Console.SetCursorPosition(left, top);
            _hasLogUpdates = true;
        }
Ejemplo n.º 27
0
 public static void DrawRecords()
 {
     Console.BackgroundColor = Color.DarkSlateBlue;
     Console.Clear();
     if (AllRecords.Count > 0)
     {
         var records = new List <Record>(AllRecords.Reverse());
         for (int i = 0; i < records.Count; ++i)
         {
             DrawRecord(i, records[i]);
         }
     }
     else
     {
         Console.SetCursorPosition(0, Console.WindowHeight / 2);
         Console.Write(Center("Empty list . . .", Console.WindowWidth));
     }
 }
Ejemplo n.º 28
0
        static void ShowSpinner()
        {
            var counter = 0;

            for (int i = 0; i < 50; i++)
            {
                switch (counter % 4)
                {
                case 0: Console.Write("/"); break;

                case 1: Console.Write("-"); break;

                case 2: Console.Write("\\"); break;

                case 3: Console.Write("|"); break;
                }
                Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
                counter++;
                Thread.Sleep(100);
            }
        }
Ejemplo n.º 29
0
        private static void WriteStatus(Status s)
        {
            string    m = "[ {0} ]";
            Formatter f = null;

            switch (s)
            {
            case Status.Ok:
                f = new Formatter("Ok", System.Drawing.Color.Green);
                Console.SetCursorPosition(Console.WindowWidth - 8, Console.CursorTop - 1);
                break;

            case Status.Fail:
                f = new Formatter("Fail", System.Drawing.Color.Red);
                Console.SetCursorPosition(Console.WindowWidth - 10, Console.CursorTop - 1);
                break;

            case Status.Skip:
                f = new Formatter("Skip", System.Drawing.Color.White);
                Console.SetCursorPosition(Console.WindowWidth - 10, Console.CursorTop - 1);
                break;
            }
            Console.WriteLineFormatted(m, f, System.Drawing.Color.Silver);
        }
Ejemplo n.º 30
0
        public static void DrawButton(Button button)
        {
            var area      = button.Area;
            var foreColor = Console.ForegroundColor;
            var backColor = Console.BackgroundColor;

            if (Buttons.IndexOf(button) == ActiveButton)
            {
                Console.BackgroundColor = Color.White;
            }
            else
            {
                Console.BackgroundColor = Color.LightGray;
            }
            Console.ForegroundColor = Color.DarkSlateBlue;
            Console.SetCursorPosition(area[0].X, area[0].Y);
            Console.Write(new string(' ', Button.Width));
            Console.SetCursorPosition(area[0].X, area[0].Y + 1);
            Console.Write(Center(button.Label, Button.Width));
            Console.SetCursorPosition(area[0].X, area[0].Y + 2);
            Console.Write(new string(' ', Button.Width));
            Console.ForegroundColor = foreColor;
            Console.BackgroundColor = backColor;
        }