예제 #1
0
        public static int PrintSelectText(List <string> array, int s)
        {
            if (s == 999)
            {
                s = 0;
            }
            int SelectIndex = s;

            if (SelectIndex >= array.Count - 1)
            {
                SelectIndex = array.Count - 1;
            }
            else if (SelectIndex <= 0)
            {
                SelectIndex = 0;
            }

            int  line  = Console.CursorTop;
            bool goOut = false;

            foreach (var item in array)
            {
                Console.WriteLine("  {0}", item);
            }
            while (array.Count > 0 && goOut == false)
            {
                Console.SetCursorPosition(0, SelectIndex + line);
                PrintHelper.PrintWriteColor("=>", ConsoleColor.Red);
                Controller.KeyName key = Controller.ReadKeyDown();
                Console.SetCursorPosition(0, SelectIndex + line);
                Console.Write("  ");
                switch (key)
                {
                case Controller.KeyName.UpKey:
                    SelectIndex -= 1;
                    break;

                case Controller.KeyName.DownKey:
                    SelectIndex += 1;
                    break;

                case Controller.KeyName.LeftKey:
                    break;

                case Controller.KeyName.RightKey:
                    //goOut = true;
                    break;

                case Controller.KeyName.EnterKey:
                    goOut = true;
                    break;

                case Controller.KeyName.BackKey:
                    return(999);

                case Controller.KeyName.MenuKey:
                    break;
                }
                if (SelectIndex >= array.Count - 1)
                {
                    SelectIndex = array.Count - 1;
                }
                else if (SelectIndex <= 0)
                {
                    SelectIndex = 0;
                }
            }
            return(SelectIndex);
        }