Esempio n. 1
0
        private static async Task Main(string[] args)
        {
            Logger logger = LogManager.GetLogger("Launch");

            var parser = new CommandLineBuilder(LaunchCommand.GetCommand())
                         .UseHost((args) => CreateHostBuilder(args))
                         .UseDefaults()
                         .UseMiddleware(async(context, next) =>
            {
                await next(context);
            })
                         .UseExceptionHandler((ex, context) =>
            {
                var stackTrace = Configuration.GetValue <bool>("ShowStackTraceOnError")
                        ? ex.StackTrace
                        : "Error details hidden. Enable 'ShowStackTraceOnError' to see more...";

                logger.Error(ex, $"The global exception handler caught an exception: {ex.Message}{Environment.NewLine}{stackTrace}");
                logger.Info($"Press any key to close...");
                Console.ReadKey();
            })
                         .Build();

            // display some startup info

            Console.WriteAscii("Launch", Color.FromArgb(204, 102, 0));
            Console.Write($"Version: ");
            parser.Parse("--version").Invoke();

            // parse the arguments
            await parser.InvokeAsync(args);
        }
Esempio n. 2
0
        protected void ReadAndDispatchConsoleKeys()
        {
            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo key = Console.ReadKey(true);
                switch (key.Key)
                {
                case ConsoleKey.Enter:
                    this.InputManager.SendInputBufferAsCommand();
                    break;

                case ConsoleKey.Backspace:
                    this.InputManager.RemoveLastCharOfInputBuffer();
                    break;

                case ConsoleKey.Escape:
                    L.Information("Stopping");
                    this.Destroy();
                    break;

                default:
                    this.InputManager.AddCharToInputBuffer(key.KeyChar);
                    break;
                }
            }
        }
Esempio n. 3
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);
 }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public static void SelectAlg()
        {
            Console.Clear();
            Console.WriteLine(figlet.ToAscii("Knewin Test"), ColorTranslator.FromHtml("#8AFFEF"));
            Console.WriteLine("Selecione um algoritmo: ");
            Console.WriteLine("1 - Buscador de Números Repetidos", Color.Yellow);
            Console.WriteLine("2 - Verificador de Palíndromos", Color.Yellow);
            Console.WriteLine("0 - Sair", Color.Gray);
            var choice = Console.ReadKey().KeyChar;

            Console.WriteLine();

            if (choice == '1')
            {
                searchFirstRepeatedIndex.Begin();
            }

            if (choice == '2')
            {
                confirmPalindrome.Begin();
            }

            if (choice != '0')
            {
                System.Console.WriteLine("Selecione um dos dois algoritmos!");
                SelectAlg();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// when writing password to console interface, hides characters
        /// </summary>
        /// <returns></returns>
        static public SecureString darker()
        {
            SecureString   securePwd = new SecureString();
            ConsoleKeyInfo key;

            do
            {
                key = Console.ReadKey(true);
                // Backspace Should Not Work
                if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
                {
                    securePwd.AppendChar(key.KeyChar);
                    Console.Write("*");
                }
                else
                {
                    if (key.Key == ConsoleKey.Backspace && securePwd.Length > 0)
                    {
                        securePwd = new NetworkCredential("", securePwd.ToString().Substring(0, (securePwd.Length - 1))).SecurePassword;
                        Console.Write("\b \b");
                    }
                    else if (key.Key == ConsoleKey.Enter)
                    {
                        break;
                    }
                }
            } while (true);
            return(securePwd);
        }
Esempio n. 7
0
    public static void Main()
    {
        try
        {
            db = new Database("127.0.0.1", "johndog", "root", "");
            StartServer();
            // use local m/c IP address, and
            // use the same in the client

            /* Initializes the Listener */


            /* Start Listeneting at the specified port */

            JohnDog.SayNoNewLine("Connection Manager", "The server is running at port 8000.");
            JohnDog.Say("Connection Manager", "The local IP address is: " +
                        server.LocalEndpoint);
            JohnDog.Say("Connection Manger", "Waiting for a connection...");
        }
        catch (Exception e)
        {
            Console.WriteLine("Error: " + e.StackTrace);
            Console.ReadKey();
        }
    }
Esempio n. 8
0
        static void exit(int ecode = 0)
        {
            Console.WriteLine(" ");
            Console.Write("press any key to continue...");
            Console.ReadKey(true);

            Environment.Exit(ecode);
        }
Esempio n. 9
0
        public void VolgendeStap()
        {
            StyleSheet styleSheet = new StyleSheet(Color.White);

            styleSheet.AddStyle("Je kan de volgende richting uit:", Color.MediumSlateBlue);
            styleSheet.AddStyle("Je kunt interacteren", Color.Red);
            Console.WriteLineStyled(_kaart.GetCurrentPosition().ToString(), styleSheet);
            var interactieKey = Console.ReadKey().Key;

            Console.WriteLine("═══════════════════════════════════════════════════");
            Console.WriteLine();
            VerwerkInput(interactieKey, VolgendeStap);
        }
Esempio n. 10
0
        private static void Main(string[] args)
        {
            var xml        = SimulationCases.LoadXmlAsync(SimulationCases.Case01).Result;
            var simulation = new RentalContractSimulationFromXml(xml);
            var simulator  = new Simulator(simulation);

            SimulatorPrinter.PrintInfo("blablabla balbla");

            simulator.Start();

            Console.WriteLine("---- END ----");
            Console.ReadKey();
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            Console.ReadKey();

            // ShowSimplePercentage();
            // ShowSpinner();
            // MultiLineAnimation();
            // ColorfulText();
            // ColorfulAnimation();
            AsciiText();

            Console.ReadKey();
        }
Esempio n. 12
0
        public void deleteCustomer()
        {
            System.Console.WriteLine();
            Console.Write(" ENTER THE ID TO DELETE : ");

            System.Console.WriteLine();
            System.Console.WriteLine();

            var table = new ConsoleTable(" ID ", " C U S T O M E R  N A M E ", " T O T A L  P U R C H A S E ", " D I S C O U N T ", " T O T A L  D U E ", " C A S H  P A Y M E N T ", " C H A N G E ");



            foreach (var cust in db.getCUstomerList())
            {
                table.AddRow(cust.ID, cust.CustName, cust.totalPurch, cust.disc, cust.totalDue, cust.cpay, cust.change);
            }

            table.Write();
            Console.WriteLine();

            Console.CursorTop  = 1;
            Console.CursorLeft = 30;
            int id = int.Parse(Console.ReadLine());


            Message.TitleBox(" Are you sure you want to delete [Y]es/[N]o ", 5, 50, ConsoleColor.Red, ConsoleColor.White);

            ConsoleKey sel = Console.ReadKey().Key;

            if (sel.Equals(ConsoleKey.Y))
            {
                db.deleteCustomer(id);
                Message.TitleBox(" Do you want to delete another ? [Y]es/[N]o ", 5, 50, ConsoleColor.White, ConsoleColor.Black);
                ConsoleKey key = Console.ReadKey().Key;

                if (key.Equals(ConsoleKey.Y))
                {
                    Console.Clear();
                    deleteCustomer();
                }
                else
                {
                }
            }
            else
            {
                Intermidiate();
            }
        }
Esempio n. 13
0
        private static void NextCmd(ProcessInstance process)
        {
            SimulatorPrinter.PrintInfo("T: transaction view. <other> continue");
            //Console.Write("T: transaction view. <other> continue", Color.LawnGreen);
            var key = Console.ReadKey(true);

            if (key.Key == ConsoleKey.T)
            {
                PrintTransactions(process);
            }
            else
            {
                Console.WriteLine("\n -#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#- \n", Color.MediumSeaGreen);
            }
        }
Esempio n. 14
0
        public void Entertainement()
        {
            Console.Clear();
            Console.BackgroundColor = Color.SteelBlue;
            Console.Clear();

            Message.TitleBox(" E N T E R T A I N M E N T ", 3, 40, ConsoleColor.Red, ConsoleColor.White);
            Message.BoxColor = Color.White;

            Message.CreateBox("", 16, 30, "");



            Console.CursorTop = 7;
            Message.menuBox(3, 32, " [A]. S N A K E ", ConsoleColor.Blue, ConsoleColor.White, 1);
            Message.menuBox(3, 32, " [B]. C O L O R  G A M E ", ConsoleColor.Blue, ConsoleColor.White, 1);

            Console.WriteLine();
            Console.WriteLine();
            Message.menuBox(1, 32, " E N T E R  L E T T E R ", ConsoleColor.Red, ConsoleColor.White);
            Message.menuBox(1, 32, " O F  Y O U R  C H O I C E ", ConsoleColor.Red, ConsoleColor.White);
            Message.menuBox(1, 32, " [BACK SPACE] M E N U ", ConsoleColor.Red, ConsoleColor.White);
            select = Console.ReadKey().Key;
            if (select.Equals(ConsoleKey.A))
            {
                Snake snake = new Snake(USERNAME);
                snake.Initialize();
            }
            else if (select.Equals(ConsoleKey.B))
            {
                Console.BackgroundColor = Color.Black;
                Console.Clear();
                ColorGame cg = new ColorGame();
                cg.gameStart();
            }
            else if (select.Equals(ConsoleKey.Backspace))
            {
                SystemMenu();
            }
            else
            {
                Message.TitleBox("Invalid Choice Try Again", 5, 40, ConsoleColor.Red, ConsoleColor.White);
                Console.ReadKey();
                Entertainement();
            }

            Console.ReadKey(true);
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            Console.WriteAscii("USNQueryEngine", Color.FromArgb(240, 200, 200));
            Stopwatch watch = new Stopwatch();

            watch.Start();

            entries = USNEngine.GetAllFilesAndDirectories();

            watch.Stop();

            Console.WriteLine("{0} files, {1} seconds", entries.Count(), watch.Elapsed.TotalSeconds);
            string filter = "UsnOperation.dll".ToUpper();

            Formatter[] fruits = new Formatter[]
            {
                new Formatter($"{filter}", Color.LawnGreen),
            };
            Console.WriteLineFormatted("Start to Serch [{0}]", Color.Gray, fruits);
            Console.WriteLine();

            watch.Restart();
            var result = entries
                         .Where(f => f.FileName.ToUpper().Contains(filter))
                         .OrderBy(f => f.FileName)
                         .ToList();

            watch.Stop();

            Console.WriteLine("{0} files in {1} seconds", result.Count(), watch.Elapsed.TotalSeconds);
            if (result.Count() > 0)
            {
                var table = new ConsoleTable("FileName", "Path");
                foreach (var item in result)
                {
                    if (item is FileAndDirectoryEntry)
                    {
                        table.AddRow(item.FileName, item.Path);
                    }
                }
                table.Write();
                Console.WriteLine();
            }


            Console.WriteLine("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Esempio n. 16
0
        public void deleteStudentGrade()
        {
            System.Console.WriteLine();
            Console.Write(" ENTER THE ID TO DELETE : ");

            System.Console.WriteLine();
            System.Console.WriteLine();
            var table = new ConsoleTable("ID", "S T U D E N T  N A M E", "S U B J E C T", "P R E L I M", "M I D T E R M ", "F I N A L S", " A V E R A G E", "R E M A R K S");

            foreach (var stgrades in db.getStudentGradeList())
            {
                table.AddRow(stgrades.id, stgrades.sname, stgrades.subj, stgrades.prelim, stgrades.midterm, stgrades.finals, stgrades.ave, stgrades.remarks);
            }


            table.Write();
            Console.CursorTop  = 1;
            Console.CursorLeft = 30;
            int id = int.Parse(Console.ReadLine());


            Message.TitleBox(" Are you sure you want to delete [Y]es/[N]o ", 5, 50, ConsoleColor.Red, ConsoleColor.White);

            ConsoleKey sel = Console.ReadKey().Key;

            if (sel.Equals(ConsoleKey.Y))
            {
                db.deleteStudent(id);
                Message.TitleBox(" Do you want to delete another ? [Y]es/[N]o ", 5, 50, ConsoleColor.White, ConsoleColor.Black);
                ConsoleKey key = Console.ReadKey().Key;

                if (key.Equals(ConsoleKey.Y))
                {
                    Console.Clear();
                    deleteStudentGrade();
                }
                else
                {
                }
            }
            else
            {
                Intermidiate();
            }
        }
Esempio n. 17
0
        private static string ReadLineOrEsc()
        {
            string retString = "";

            int curIndex = 0;

            do
            {
                ConsoleKeyInfo readKeyResult = Console.ReadKey(true);

                // handle Esc
                if (readKeyResult.Key == ConsoleKey.Escape)
                {
                    Console.WriteLine();
                    return(null);
                }

                // handle Enter
                if (readKeyResult.Key == ConsoleKey.Enter)
                {
                    Console.WriteLine();
                    return(retString);
                }

                // handle backspace
                if (readKeyResult.Key == ConsoleKey.Backspace)
                {
                    if (curIndex > 0)
                    {
                        retString = retString.Remove(retString.Length - 1);
                        Console.Write(readKeyResult.KeyChar);
                        Console.Write(' ');
                        Console.Write(readKeyResult.KeyChar);
                        curIndex--;
                    }
                }
                else
                // handle all other keypresses
                {
                    retString += readKeyResult.KeyChar;
                    Console.Write(readKeyResult.KeyChar);
                    curIndex++;
                }
            }while (true);
        }
Esempio n. 18
0
        private void Afsluitmenu()
        {
            Console.WriteLine("Weet je zeker dat je wilt afsluiten? (Y/N)");
            var input = Console.ReadKey().Key;

            if (input == ConsoleKey.Y)
            {
                Environment.Exit(0);
            }
            else if (input == ConsoleKey.N)
            {
                Console.WriteLine("Afsluiten geannuleerd.");
            }
            else
            {
                Console.WriteLine("Kies \"Y\" of \"N\".");
                Afsluitmenu();
            }
        }
Esempio n. 19
0
        public static void Main(string[] args)
        {
            // Starting point of the program

            Console.SetWindowPosition(0, 0);
            Console.WindowHeight = Console.LargestWindowHeight;
            Console.WindowWidth  = Console.LargestWindowWidth;

            //Thread that play sound
            ThreadStart sounds = new ThreadStart(Sounds.playFireFlies);
            Thread      sound  = new Thread(sounds);

            sound.Start();


            // Thread that play animation
            ThreadStart Animation = new ThreadStart(Animations.zetaAnimation);
            Thread      animation = new Thread(Animation);

            animation.Start();


            ConsoleKey stop = Console.ReadKey().Key;

            if (!stop.Equals(ConsoleKey.Escape))
            {
                animation.Abort();
                Console.ReplaceAllColorsWithDefaults();
                Console.BackgroundColor = Color.Black;
                Console.ForegroundColor = Color.White;
                Console.Clear();
                Animations.SpaceShipLoading();
                Sounds.Stop();

                // Calling the User interface of the system
                UserInterface ui   = new UserInterface();
                ThreadStart   main = new ThreadStart(ui.Initialize);
                Thread        Main = new Thread(main);

                Main.Start();
            }
        }
Esempio n. 20
0
        private void Init()
        {
            time  = new Stopwatch();
            style = new StyleSheet(System.Drawing.Color.LightGray);
            Thread listenerThread = new Thread(StartListener);

            while (true)
            {
                try
                {
                    listenerThread.Start();
                    listenerThread.Join();
                    Console.ReadKey();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
Esempio n. 21
0
        static async Task Main(string[] args)
        {
            var cancelletation = new CancellationTokenSource();
            var eventHub       = EventHubClient.CreateFromConnectionString(
                "{INSERT CONNECTION STRING HERE}");

            _service = ServiceClient.CreateFromConnectionString(
                "{INSERT CONNECTION STRING HERE}");


            Console.WriteLine(new Figlet(FigletFont.Load("doh.flf")).ToAscii("ORCHESTRATOR"));
            Console.WriteLine("Press Enter to finish...");

            if (Console.ReadKey(true).Key == ConsoleKey.Enter)
            {
                Console.WriteLine("Finishing...");
                cancelletation.Cancel();
                cancelletation.Dispose();
                await Task.Delay(1000, CancellationToken.None);

                Console.WriteLine("Finished...");
            }
        }
        /// <summary>
        /// Kicks off the pane switching loop.
        /// </summary>
        private static void RunSwitcher()
        {
            // Start the console resizer
            ConsoleResizer.ResizeWanted = true;
            ConsoleResizer.CheckForResize();

            // Write config info.
            WriteConfigInfo(PaneSizes, Sender);

            // Wait for user to hit enter to begin.
            // Check for next input key here.
            while (true)
            {
                // If no new key wait.
                if (!Console.KeyAvailable)
                {
                    continue;
                }
                var NextKey = Console.ReadKey(true);

                if (NextKey.Key == ConsoleKey.Enter)
                {
                    break;
                }
                if (NextKey.Key == ConsoleKey.R)
                {
                    // Check for R again to confirm.
                    var ResetKey = Console.ReadKey(true);
                    if (ResetKey.Key != ConsoleKey.R)
                    {
                        continue;
                    }

                    // Reset the pane keys if wanted.
                    PaneSizes = new PaneSizeValues(true);
                    WriteConfigInfo(PaneSizes, Sender);
                }
                if (NextKey.Key == ConsoleKey.P)
                {
                    // Draw new boxes and update the UI
                    HotKeys.ProcessPaneKey();
                    PaneSizes = new PaneSizeValues();
                    WriteConfigInfo(PaneSizes, Sender);
                }
            }

            // Clear the console.
            Console.Clear();

            // Store last move so we dont repeat
            int LastMoveIndex = -1;

            // Loop only while we have not key pressed and we can read a key.
            while (!(Console.KeyAvailable && (Console.ReadKey(true).Key == ConsoleKey.Escape)))
            {
                // Wait the delay time and get mouse location
                Thread.Sleep(DelayTime);
                var XAndYPos = new MouseCords();

                // Check invalid Y pos value.
                if (XAndYPos.PosY < 0)
                {
                    // Make sure we wanna do this.
                    if (ConfigurationManager.AppSettings.Get("ForcePositiveY") != "TRUE")
                    {
                        continue;
                    }

                    // Change the view if needed.
                    if (LastMoveIndex != -1)
                    {
                        PrintCurrentPane(-1, null);
                        Sender.SwitchView(-1);
                    }

                    // Move on the loop.
                    continue;
                }

                // Find the X Pane item range.
                if (PaneSizes.PaneSizesList.Count == 0)
                {
                    throw new Exception("FAILED TO FIND ANY PANE SETTINGS ITEMS WHEN CHANGING VIEWS!");
                }
                for (int PaneIndex = 0; PaneIndex < PaneSizes.PaneSizesList.Count; PaneIndex++)
                {
                    // Get the top and bottom range items.
                    int MinRange = PaneSizes.PaneSizesList[PaneIndex].Item1;
                    int MaxRange = PaneSizes.PaneSizesList[PaneIndex].Item2;

                    // Check if we're in range and need to move.
                    // RANGE IS SETUP AS MIN AND COUNT. NOT MIN AND MAX!!
                    if (!Enumerable.Range(MinRange, MaxRange - MinRange).Contains(XAndYPos.PosX))
                    {
                        continue;
                    }
                    if (PaneIndex == LastMoveIndex)
                    {
                        break;
                    }

                    // Store the index of the pane we are on and print that info out.
                    Sender.SwitchView(PaneIndex + 1);
                    PrintCurrentPane(PaneIndex, XAndYPos);
                    LastMoveIndex = PaneIndex;

                    // Move on
                    break;
                }
            }

            // Stop resizer, move back to home and clear out.
            ConsoleResizer.ResizeWanted = false;
            Sender.SwitchView(-1);
            PrintCurrentPane(-1, null);
            Console.Clear();
        }
Esempio n. 23
0
 /// <summary>
 /// Aguarda o usuário pressionar qualquer tecla.
 /// </summary>
 static public void WaitKey()
 {
     Console.ReadKey();
 }
Esempio n. 24
0
 static void End()
 {
     Console.WriteLine("\n" + Repeat(' ', 8) + "Press enter to exit", Color.SpringGreen);
     Console.ReadKey();
 }
Esempio n. 25
0
        public void Intermidiate()
        {
            Console.Clear();
            Console.BackgroundColor = Color.SteelBlue;
            Console.Clear();

            Message.TitleBox(" I N T E R M E D I A T E ", 3, 40, ConsoleColor.Red, ConsoleColor.White);
            Message.CreateBox("", 20, 36, "");

            Console.CursorTop = 7;
            Message.menuBox(3, 38, " [A]. STRING MANIPULATION ", ConsoleColor.Blue, ConsoleColor.White, 1);
            Message.menuBox(3, 38, " [B]. GRADE COMPUTATION ", ConsoleColor.Blue, ConsoleColor.White, 1);
            Message.menuBox(3, 38, " [C]. SALES TRANSACTION ", ConsoleColor.Blue, ConsoleColor.White, 1);


            Console.WriteLine();
            Console.WriteLine();

            Message.menuBox(1, 38, " E N T E R  L E T T E R ", ConsoleColor.Red, ConsoleColor.White);
            Message.menuBox(1, 38, " O F  Y O U R  C H O I C E ", ConsoleColor.Red, ConsoleColor.White);
            Message.menuBox(1, 38, " [BACK SPACE] M E N U ", ConsoleColor.Red, ConsoleColor.White);

            select = Console.ReadKey().Key;



            Console.WriteLine();


            if (select.Equals(ConsoleKey.A))
            {
                Console.BackgroundColor = Color.Blue;
                Console.Clear();

                string fname, mname, lname, lblf, lblm, lbll, result;


                Message.TitleBox(" STRING MANIPULATION ", 3, 25, ConsoleColor.Red, ConsoleColor.White);
                Message.CreateBox("", 10, 70, ". . . .");



                lblf = "Enter Firstname : ";
                TextCenter("", -15, -7);
                Console.Write(lblf, Color.Black);
                fname = Console.ReadLine();


                lblm = "Enter Middlename : ";
                TextCenter("", -15);
                Console.Write(lblm, Color.Black);
                mname = Console.ReadLine();

                lbll = "Enter Lastname : ";
                TextCenter("", -15);
                Console.Write(lbll, Color.Black);
                lname = Console.ReadLine();



                result = "Hi ! " + act.strManipulation(fname, mname, lname);



                Message.Show(result, "Press any key to continue....");
            }
            else if (select.Equals(ConsoleKey.B))
            {
                Console.BackgroundColor = Color.SteelBlue;
                Console.Clear();
                Message.TitleBox(" GRADE COMPUTATION", 3, 20, ConsoleColor.Red, ConsoleColor.White);
                Message.CreateBox("", 16, 30, "");
                Console.CursorTop = 7;
                Message.menuBox(3, 32, " [A]. INSERT STUDENT GRADE ", ConsoleColor.Blue, ConsoleColor.White, 1);
                Message.menuBox(3, 32, " [B]. DELETE STUDENT GRADE ", ConsoleColor.Blue, ConsoleColor.White, 1);

                Console.WriteLine();
                Console.WriteLine();
                Message.menuBox(1, 32, " E N T E R  L E T T E R ", ConsoleColor.Red, ConsoleColor.White);
                Message.menuBox(1, 32, " O F  Y O U R  C H O I C E ", ConsoleColor.Red, ConsoleColor.White);
                Message.menuBox(1, 32, " [BACK SPACE] M E N U ", ConsoleColor.Red, ConsoleColor.White);

                ConsoleKey sel = Console.ReadKey().Key;

                if (sel.Equals(ConsoleKey.A))
                {
                    Console.Clear();
                    insertStudent();
                }
                else if (sel.Equals(ConsoleKey.B))
                {
                    Console.Clear();
                    deleteStudentGrade();
                }
                else if (sel.Equals(ConsoleKey.Backspace))
                {
                    SystemMenu();
                }
            }
            else if (select.Equals(ConsoleKey.C))
            {
                Console.BackgroundColor = Color.SteelBlue;
                Console.Clear();


                Message.TitleBox(" SALES TRANSACTION ", 3, 23, ConsoleColor.Red, ConsoleColor.White);
                Message.CreateBox("", 16, 30, "");
                Console.CursorTop = 7;
                Message.menuBox(3, 32, " [A]. INSERT CUSTOMER ", ConsoleColor.Blue, ConsoleColor.White, 1);
                Message.menuBox(3, 32, " [B]. DELETE CUSTOMER ", ConsoleColor.Blue, ConsoleColor.White, 1);


                Console.WriteLine();
                Console.WriteLine();
                Message.menuBox(1, 32, " E N T E R  L E T T E R ", ConsoleColor.Red, ConsoleColor.White);
                Message.menuBox(1, 32, " O F  Y O U R  C H O I C E ", ConsoleColor.Red, ConsoleColor.White);
                Message.menuBox(1, 32, " [BACK SPACE] M E N U ", ConsoleColor.Red, ConsoleColor.White);



                ConsoleKey sel = Console.ReadKey().Key;

                if (sel.Equals(ConsoleKey.A))
                {
                    Console.Clear();
                    insertCustomer();
                }
                else if (sel.Equals(ConsoleKey.B))
                {
                    Console.Clear();
                    deleteCustomer();
                }
                else if (sel.Equals(ConsoleKey.Backspace))
                {
                    SystemMenu();
                }
            }
            else if (select.Equals(ConsoleKey.Backspace))
            {
                SystemMenu();
            }
            else
            {
                Message.TitleBox("Invalid Choice Try Again", 5, 40, ConsoleColor.Red, ConsoleColor.White);
                Console.ReadKey();
                Intermidiate();
            }

            Console.ReadKey();
        }
Esempio n. 26
0
        static public bool InitiateCombat(Characters hero, Characters enemy)
        {
            string message;
            bool   exit = false;

            while (enemy.Alive() & hero.Alive() & !exit)
            {
                Thread.Sleep(1000);
                string      choiceMessage = "Chose what to do:\n   {0} for attack\n   {1} to attempt to dodge attacks\n   {2} for heal\n   {3} to attempt to flee";
                Formatter[] choiceString  = new Formatter[]
                {
                    new Formatter("A", Color.IndianRed),
                    new Formatter("D", Color.Yellow),
                    new Formatter("H", Color.MediumPurple),
                    new Formatter("F", Color.CadetBlue)
                };
                //Hero turn
                bool validInput = true;
                do
                {
                    Console.WriteLineFormatted(choiceMessage, Color.DarkGray, choiceString);
                    var input = Console.ReadKey(true);
                    Console.WriteLine("\n");
                    Thread.Sleep(1000);

                    validInput = true;

                    switch (input.Key)
                    {
                    case ConsoleKey.A:
                        Fight(hero, enemy);
                        break;

                    case ConsoleKey.D:
                        hero.GetDodgeCharges(enemy);
                        break;

                    case ConsoleKey.H:
                        hero.Heal();
                        break;

                    case ConsoleKey.F:
                        if (hero.AttemptFlee(enemy))
                        {
                            exit = true;
                        }
                        break;

                    default:
                        Console.WriteLine("Invalid input!\n", Color.OrangeRed);
                        validInput = false;
                        break;
                    }
                } while (!validInput);


                if (exit)
                {
                    break;
                }

                //Enemy turn
                Thread.Sleep(1000);
                if (enemy.Alive())
                {
                    Fight(enemy, hero);
                }

                message = "\n{0} has {1}; {2} has {3}.\n";
                Formatter[] characterString = new Formatter[]
                {
                    new Formatter(hero.Name, Color.CadetBlue),
                    new Formatter(hero.GetHealth() + "HP", Color.CadetBlue),
                    new Formatter(enemy.Name, Color.OrangeRed),
                    new Formatter(enemy.GetHealth() + "HP", Color.OrangeRed)
                };
                Console.WriteLineFormatted(message, Color.DarkGray, characterString);
            }

            return(enemy.Alive());
        }
Esempio n. 27
0
        public void Credits()
        {
            Console.BackgroundColor = Color.Blue;
            Console.Clear();

            Message.TitleBox(" C R E D I T S ", 3, 20, ConsoleColor.Red, ConsoleColor.White);

            Message.BoxColor = Color.White;

            Message.CreateBox("", 15, 50, "");

            string text, name, section, prof, lblProf, library, libname1, libname2;

            text     = "Developed and Designed by";
            name     = "John Nehry C. Dedoro";
            section  = "BSIT 1 - 1A";
            prof     = "M R.  A L K I N G  S U N G A";
            lblProf  = " P R O F F E S O R ";
            library  = "C# Custom Library Used :";
            libname1 = "Colorful.Console by Tomakitaa";
            libname2 = "ConsoleTables by Khalidabuhakmeh";


            Console.SetCursorPosition(((Console.WindowWidth - text.Length) / 2), Console.CursorTop - 13);
            for (int i = 0; i < text.Length; i++)
            {
                Console.Write(text[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.SetCursorPosition(((Console.WindowWidth - name.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < name.Length; i++)
            {
                Console.Write(name[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.SetCursorPosition(((Console.WindowWidth - section.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < section.Length; i++)
            {
                Console.Write(section[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.WriteLine();
            Console.SetCursorPosition(((Console.WindowWidth - prof.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < prof.Length; i++)
            {
                Console.Write(prof[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.SetCursorPosition(((Console.WindowWidth - lblProf.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < lblProf.Length; i++)
            {
                Console.Write(lblProf[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.SetCursorPosition(((Console.WindowWidth - library.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < library.Length; i++)
            {
                Console.Write(library[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.SetCursorPosition(((Console.WindowWidth - libname1.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < libname1.Length; i++)
            {
                Console.Write(libname1[i], Color.Black);
                Thread.Sleep(50);
            }
            Console.SetCursorPosition(((Console.WindowWidth - libname2.Length) / 2), Console.CursorTop + 1);
            for (int i = 0; i < libname2.Length; i++)
            {
                Console.Write(libname2[i], Color.Black);
                Thread.Sleep(50);
            }
            System.Console.WriteLine();
            System.Console.WriteLine();

            Message.menuBox(1, 20, " T H A N K  Y O U ", ConsoleColor.Blue, ConsoleColor.White);


            pressAnyKey();
            Console.ReadKey();
        }
Esempio n. 28
0
        //public void key_pressed()
        //{
        //    while (true)
        //    {
        //           if (buf.Count < 4)
        //            {
        //            lock (buf)
        //            {
        //                buf.Add(Console.ReadKey(true));

        //            }
        //            }
        //    }
        //}
        public void key_handler()
        {
            // could it be: press a key after we just pass the test;
            while (true)
            {
                Thread.Sleep(1);
                //if(buf.Count<3)
                //    buf.Add(Console.ReadKey(true));
                // check if it is valid key
                //if (key_waiting) continue;
                key = ConsoleB.ReadKey(true);
                snake_head cur_dir = snake_dir;

                // if the key enter is valid
                try
                {
                    cur_dir = key_map[key.Key];
                }
                catch (KeyNotFoundException)
                {
                    continue;
                }


                // this piece change the speed of the snack
                if ((key.Modifiers & ConsoleModifiers.Shift) != 0)
                {
                    speed = 100;
                }
                else
                {
                    // if the key was not pressed
                    speed = normal_speed;
                }


                // if it's not a logical key
                if (cur_dir == snake_dir || cur_dir - snake_dir == -1 || cur_dir - snake_dir == 1)
                {
                    continue;
                }
                //key_waiting = true;
                snake_dir = cur_dir;
                Thread.Sleep(speed);
                //++press;


                //switch (key.Key)
                //{
                //    case ConsoleKey.UpArrow:
                //        snake_dir = snake_head.UP;
                //        ++press;
                //        key_waiting = true;
                //        break;
                //    case ConsoleKey.DownArrow:
                //        snake_dir = snake_head.DOWN;
                //        ++press;
                //        key_waiting = true;
                //        break;
                //    case ConsoleKey.LeftArrow:
                //        snake_dir = snake_head.LEFT;
                //        ++press;
                //        key_waiting = true;
                //        break;
                //    case ConsoleKey.RightArrow:
                //        ++press;
                //        snake_dir = snake_head.RIGHT;
                //        key_waiting = true;
                //        break;
                //}
            }
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            Console.Title = "Losowanie na pytanko - WĘGIEL STUDIO";

            uint twojnumer   = 0;
            uint stillalives = 0;
            uint zgony       = 0;

            Console.WriteLine("Podaj swój piękny numerek z dziennika", Color.Crimson);
            twojnumer = uint.Parse(Console.ReadLine());

            Console.WriteLine("Podaj liczby które będą uwzględnione do potężnych obliczeń,", Color.Crimson);

            string czynnikiwstringuuu = Console.ReadLine();

            uint[] czynniki = new uint[czynnikiwstringuuu.Split(' ').Length];

            Console.WriteLine("");
            Console.WriteLine("Daj mi chwilę albo dwie", Color.Peru);
            Console.WriteLine("");

            for (int i = 0; i < czynnikiwstringuuu.Split(' ').Length; i++)
            {
                string[] liczs = czynnikiwstringuuu.Split(' ');
                czynniki[i] = uint.Parse(liczs[i]);
            }

            for (int i = 0; i < czynniki.Length; i++)
            {
                if (czynniki[i] == twojnumer)
                {
                    Console.WriteLine("Zgon totalny (twoj numer jest jednym z zakresu :c F) " + czynniki[i].ToString() + "==" + twojnumer.ToString(), Color.Red);
                    zgony += 100;
                }
                for (int s = 0; s < czynniki.Length; s++)
                {
                    if (czynniki[s] + czynniki[i] == twojnumer)
                    {
                        Console.WriteLine("Zgon bo: " + czynniki[s].ToString() + "+" + czynniki[i].ToString(), Color.Crimson);
                        zgony++;
                    }
                    else
                    {
                        stillalives++;
                    }

                    if (czynniki[s] > czynniki[i])
                    {
                        if (czynniki[s] - czynniki[i] == twojnumer)
                        {
                            Console.WriteLine("Zgon bo: " + czynniki[s].ToString() + "-" + czynniki[i].ToString(), Color.Crimson);
                            zgony++;
                        }
                        else
                        {
                            stillalives++;
                        }
                    }
                }
            }

            int r = 0, g = 0, b = 0;

            Console.WriteLine("");
            double ijak = (zgony / stillalives);

            if (ijak > 0.60)
            {
                r = 255;
                g = 15;
            }

            if (ijak > 0.5 && ijak < 0.60)
            {
                r = 255;
                g = 165;
            }

            if (ijak < 0.5)
            {
                g = 255;
            }

            Console.WriteLine("zgony: " + zgony + " | zycia: " + stillalives + " (wiecej = gorzej) stosunek: " + (float)zgony / stillalives + "% że to będziesz ty", Color.FromArgb(r, g, b));
            Console.ReadKey();
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            Console.Title = "Phoenix Protector Strings Decryptor by illuZion";
            Console.WriteAscii("Phoenix Protector", Color.Red);
            Console.WriteAscii("Strings Decryptor", Color.Orange);
            Console.WriteLine("v1.0 by illuZion ", Color.Blue);

            var targetFilePath = string.Empty;

            if (args.Length < 1)
            {
                while (targetFilePath == string.Empty || !File.Exists(targetFilePath))
                {
                    Console.Write("Path of the file: ");
                    targetFilePath = Path.GetFullPath(Console.ReadLine().Replace("\"", string.Empty));
                }
            }
            else
            {
                targetFilePath = Path.GetFullPath(args[0]);
            }

            ModuleDefMD module = null;

            try
            {
                module = ModuleDefMD.Load(targetFilePath);
            }
            catch (Exception ex)
            {
                throw new BadImageFormatException("Module couldn't have been loaded.", ex);
            }
            if (module == null)
            {
                throw new BadImageFormatException("Module couldn't have been loaded.");
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            int decryptedCount = StringsDecryptor.DecryptStrings(module);

            stopwatch.Stop();
            Console.WriteLine($"\n[+] Decrypted {decryptedCount} strings ! Elapsed time: {stopwatch.Elapsed.TotalSeconds}", Color.Green);
            Console.WriteLine("[$] Saving the file...", Color.Aqua);

            string outputFilePath = $"{Path.GetDirectoryName(targetFilePath)}\\{Path.GetFileNameWithoutExtension(targetFilePath)}-decrypted{Path.GetExtension(targetFilePath)}";
            ModuleWriterOptionsBase moduleWriterOptionsBase = module.IsILOnly
                ? new ModuleWriterOptions(module)
                : (ModuleWriterOptionsBase) new NativeModuleWriterOptions(module, true);

            moduleWriterOptionsBase.MetadataOptions.Flags |= MetadataFlags.PreserveAll;
            // Prevents dnlib from throwing non-important errors.
            moduleWriterOptionsBase.Logger         = DummyLogger.NoThrowInstance;
            moduleWriterOptionsBase.MetadataLogger = DummyLogger.NoThrowInstance;

            // Saves the output (unpacked) module.
            if (moduleWriterOptionsBase is NativeModuleWriterOptions nativeModuleWriterOptions)
            {
                module.NativeWrite(outputFilePath, nativeModuleWriterOptions);
            }
            else
            {
                module.Write(outputFilePath, moduleWriterOptionsBase as ModuleWriterOptions);
            }

            Console.WriteLine($"[+] File saved at {outputFilePath}", Color.Green);

            Console.ReadKey();
            Environment.Exit(0);
        }