Exemple #1
0
        public RankingView()
        {
            songsList     = Audio.GetSongList();
            songViewsList = new List <SongView>();

            string h1 = "Im udało się uciec";
            string h2 = "Wybierz piosenke, aby przejsc do rankingu.";

            Elements.Add("H1", new ViewElement(Console.WindowWidth / 2 - h1.Length / 2, 3, h2.Length, 1, new List <string>()
            {
                h1
            }));
            Elements.Add("H2", new ViewElement(5, 5, h2.Length, 1, new List <string>()
            {
                h2
            }));

            Audio.StartServiceTrack("rank");

            int y = 7;

            foreach (Song song in songsList)
            {
                songViewsList.Add(new SongView(10, y, Console.WindowWidth - 20, song));
                y += 5;
            }

            selectedSong = songViewsList[0];
            selectedSong.SetTick();
        }
Exemple #2
0
        private void MoveSelectedUp()
        {
            selectedSong.RemoveTick();
            counter += songViewsList.Count - 1;
            int index = counter % songViewsList.Count;

            selectedSong = songViewsList[index];
            selectedSong.SetTick();
        }
Exemple #3
0
        public void Init()
        {
            Elements.Add("Logo", new ViewElement((Console.WindowWidth / 4) - (logo[0].Length / 2), 1, logo[0].Length, logo.Count, logo));
            Elements["Logo"].ForegroundColor = ConsoleColor.Red;
            List <string> h1 = new List <string>()
            {
                "Witaj " + nickname + "!"
            };
            List <string> h2 = new List <string>()
            {
                "Wybierz melodię."
            };

            Elements.Add("H1", new ViewElement((Console.WindowWidth / 4) - (h1[0].Length / 2), Console.WindowHeight / 2, h1[0].Length, 1, h1));
            Elements.Add("H2", new ViewElement((Console.WindowWidth / 4) - (h2[0].Length / 2), Console.WindowHeight / 2 + 1, h2[0].Length, 1, h2));
            Render();
            foreach (SongView sView in songViewsList)
            {
                sView.Render(false);
            }

            selectedSong.SetTick();

            Audio.StartServiceTrack("selection");

            t = new Thread(delegate()
            {
                do
                {
                    pressedKey = Console.ReadKey(true);
                } while (true);
            });
            t.Start();

            exit = false;
            do
            {
                switch (pressedKey.Key)
                {
                case ConsoleKey.DownArrow:
                    MoveSelectedDown();
                    pressedKey = new ConsoleKeyInfo();
                    break;

                case ConsoleKey.UpArrow:
                    MoveSelectedUp();
                    pressedKey = new ConsoleKeyInfo();
                    break;

                case ConsoleKey.Enter:
                    exit = true;
                    EnterAction();
                    break;

                case ConsoleKey.Escape:
                    exit = true;
                    ExitAction();
                    pressedKey = new ConsoleKeyInfo();
                    break;
                }
            } while (!exit);
        }
Exemple #4
0
 private void MoveSelectedDown()
 {
     selectedSong.RemoveTick();
     selectedSong = songViewsList[++counter % songViewsList.Count];
     selectedSong.SetTick();
 }