コード例 #1
0
        //Muestra una Barra de Carga en pantalla
        public static void BarraCarga(int tiempo_s = 2)
        {
            Console.Clear();  //Limpiando la consola

            tiempo_s *= 1000; //Conviertiendo segundos a milisegundos
            int cantidad = tiempo_s / 100;
            int x        = 50;

            for (int i = 0; i <= 100; i++)
            {
                Locate.PrintCenter("Loading " + i + " %.", ConsoleColor.Blue, row: 19);

                if (i % 5 == 0)
                {
                    Locate.PrintTextColor(x++, 20, "█", ConsoleColor.Green);
                }

                Thread.Sleep(cantidad);
            }
            Thread.Sleep(500);
        }
コード例 #2
0
        //Dibuja un Cuadrado en Pantalla con colores
        public static void Cuadrado(int psx = 2, int psy = 2, int width = 120, int height = 40, ConsoleColor foreground = ConsoleColor.White, ConsoleColor background = ConsoleColor.Black)
        {
            int max = 1;

            height -= 4;
            width  -= 4;

            Console.SetCursorPosition(psx, psy);

            for (int alto = 0; alto < height; alto++)
            {
                for (int ancho = 0; ancho < width; ancho++)
                {
                    if (alto == 0)
                    {
                        if (ancho == 0)
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "╔", foreground, background);
                        }
                        else if (ancho == width - max)
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "╗", foreground, background);
                        }
                        else
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "═", foreground, background);
                        }
                    }
                    else if (alto == height - max)
                    {
                        if (ancho == 0)
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "╚", foreground, background);
                        }
                        else if (ancho == width - max)
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "╝", foreground, background);
                        }
                        else
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "═", foreground, background);
                        }
                    }
                    else
                    {
                        if (ancho == 0)
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "║", foreground, background);
                        }
                        else if (ancho == width - max)
                        {
                            Locate.PrintTextColor(psx + ancho, psy + alto, "║", foreground, background);
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
        }
コード例 #3
0
        //Dibuja un Cuadrado en Pantalla
        public static void Cuadrado(int psx = 2, int psy = 2, int width = 120, int height = 40)
        {
            int max = 1;

            height -= 4;
            width  -= 4;

            Console.SetCursorPosition(psx, psy);

            for (int alto = 0; alto < height; alto++)
            {
                for (int ancho = 0; ancho < width; ancho++)
                {
                    if (alto == 0)
                    {
                        if (ancho == 0)
                        {
                            Locate.Print(psx + ancho, psy + alto, "╔");
                        }
                        else if (ancho == width - max)
                        {
                            Locate.Print(psx + ancho, psy + alto, "╗");
                        }
                        else
                        {
                            Locate.Print(psx + ancho, psy + alto, "═");
                        }
                    }
                    else if (alto == height - max)
                    {
                        if (ancho == 0)
                        {
                            Locate.Print(psx + ancho, psy + alto, "╚");
                        }
                        else if (ancho == width - max)
                        {
                            Locate.Print(psx + ancho, psy + alto, "╝");
                        }
                        else
                        {
                            Locate.Print(psx + ancho, psy + alto, "═");
                        }
                    }
                    else
                    {
                        if (ancho == 0)
                        {
                            Locate.Print(psx + ancho, psy + alto, "║");
                        }
                        else if (ancho == width - max)
                        {
                            Locate.Print(psx + ancho, psy + alto, "║");
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
            }
        }
コード例 #4
0
        //Menú mostrado al usuario el cual, retorna un objeto del tipo
        //enumerado SelectOption que será validado en la clase Init.cs
        public static SelectOption Menu()
        {
            Console.Clear();
            y = 20;

            Interfaz.Cuadrado(4, 3, 116, 38, ConsoleColor.DarkCyan);
            Interfaz.Cuadrado(2, 2, 120, 40, ConsoleColor.DarkCyan);

            Locate.PrintCenter(" THE  ADVENTURE  OF  THE", ConsoleColor.Green, row: 6);
            Locate.PrintCenter("LITTLE SQUARE", ConsoleColor.Green, row: 8);

            Locate.PrintTextColor(55, 20, "1.", ConsoleColor.Red);
            Locate.PrintTextColor(55, 22, "2.", ConsoleColor.Red);
            Locate.PrintTextColor(55, 24, "3.", ConsoleColor.Red);
            Locate.PrintTextColor(55, 26, "4.", ConsoleColor.Red);

            Locate.PrintTextColor(57, 20, " Jugar", ConsoleColor.Blue);
            Locate.PrintTextColor(57, 22, " Personalizar", ConsoleColor.Blue);
            Locate.PrintTextColor(57, 24, " Ayuda", ConsoleColor.Blue);
            Locate.PrintTextColor(57, 26, " Salir", ConsoleColor.Blue);

            Locate.Print(52, 20, "-->");

            Interfaz.Cuadrado(49, 10, 28, 12, ConsoleColor.DarkCyan);
            Relleno();

            while (true)
            {
                keyinfo = Console.ReadKey(true);

                if (keyinfo.Key == ConsoleKey.DownArrow)
                {
                    option++;
                    option = ((int)option > 4) ? SelectOption.Salir : option;
                    Console.SetCursorPosition(52, y);
                    Console.Write("   ");
                    y += 2;
                    if (y > 26)
                    {
                        y      = 20;
                        option = SelectOption.Jugar;
                    }
                    Console.SetCursorPosition(52, y);
                    Console.Write("-->");
                    Console.SetCursorPosition(51, y);
                }
                else if (keyinfo.Key == ConsoleKey.UpArrow)
                {
                    option--;
                    option = ((int)option < 1) ? SelectOption.Jugar : option;
                    Console.SetCursorPosition(52, y);
                    Console.Write("   ");
                    y -= 2;
                    if (y < 20)
                    {
                        y      = 26;
                        option = SelectOption.Salir;
                    }

                    Console.SetCursorPosition(52, y);
                    Console.Write("-->");
                    Console.SetCursorPosition(51, y);
                }
                else if (keyinfo.Key == ConsoleKey.Enter)
                {
                    return(option);
                }
                else
                {
                    Console.SetCursorPosition(52, y);
                    Console.Write("   ");
                    y = 20;
                    Console.SetCursorPosition(52, y);
                    Console.Write("-->");
                    Console.SetCursorPosition(51, y);
                }
            }
        }