Esempio n. 1
0
        private static void printMenu(int x, int y, List <string> logo, ref napis[] napisy, int points)
        {
            try
            {
                Console.SetWindowSize(x, y);
            }
            catch (Exception)
            {
                Console.SetWindowSize(150, 100);
                x = 100;
                y = 50;
            }
            Console.ForegroundColor = ConsoleColor.Magenta;

            int    ox            = x / 2;
            int    oy            = y / 2;
            int    logoWidth     = logo[0].Length;
            int    logoHeight    = logo.Count;
            string pointsString  = "";
            string gameendString = "";

            for (int i = 0; i < logoWidth / 2 - 5; ++i)
            {
                pointsString  += " ";
                gameendString += " ";
            }
            gameendString       += "gra skończona";
            pointsString        += "punkty: " + points.ToString();
            logo[logo.Count - 1] = pointsString;
            logo[logo.Count - 2] = gameendString;
            try
            {
                for (int i = 0; i < logo.Count; i++)
                {
                    Cursor.WriteString(ox - logoWidth / 2, oy - 10 + i, logo[i]);
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
                throw ex;
            }

            ConsoleHelper.SetCurrentFont("Consolas", 24);


            napisy[0] = new napis(ox - 6, oy + 3, "Wróć do menu");

            Cursor.WriteString(ox - 6, oy + 3, "Wróć do menu");
        }
Esempio n. 2
0
        public static int getMenu(int points, int poziom = 1)
        {
            object mutex = new object();//mutex

            Console.CursorVisible = false;
            List <string> logo = new List <string>();

            using (StreamReader str = new StreamReader("logo.txt"))
            {
                string line = "";

                while ((line = str.ReadLine()) != null)
                {
                    logo.Add(line);
                }
                str.Close();
            }
            logo.Add(" ");
            logo.Add(" ");
            int y = 36, x = 100;

            napis[] napisy = new napis[4];
            printMenu(x, y, logo, ref napisy, points);
            ConsoleKey key;
            int        id = 0;
            CancellationTokenSource cancel = new CancellationTokenSource();

            Thread mainmenu = new Thread(() => UpdateConsoleMenuSize(ref x, ref y, ref mutex, ref logo, ref napisy, ref id, cancel, points));//zmieniaanie asynchronicznie szerokosci okna

            mainmenu.Start();

            do
            {
                Console.ForegroundColor = ConsoleColor.Yellow;

                Cursor.WriteString(napisy[id].x - 2, napisy[id].y, "->");
                Cursor.WriteString(napisy[id].x + napisy[id].text.Length, napisy[id].y, "<-");
                key = Console.ReadKey(true).Key;
            } while (key != ConsoleKey.Enter);

            cancel.Cancel();
            return(1);
        }