MoveBufferArea() public static méthode

public static MoveBufferArea ( int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop ) : void
sourceLeft int
sourceTop int
sourceWidth int
sourceHeight int
targetLeft int
targetTop int
Résultat void
Exemple #1
0
 public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, ConsoleColor sourceForeColor, ConsoleColor sourceBackColor)
 {
     Console.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop, sourceChar, sourceForeColor, sourceBackColor);
 }
Exemple #2
0
        /// <summary>
        /// Sends the choices to the player, prompting the player to choose an option, with the pointer on the specified position, and coloring each option according to the color in the position in the color collection
        /// </summary>
        /// <param name="Header">The title being display in the top of the menu</param>
        /// <param name="options">The collection of options for the player to select from</param>
        /// <param name="colors">The collection of colors to paint the options</param>
        /// <param name="cursorStartPosition">The position of where the pointer should start</param>
        /// <returns>Returns the selected string choice</returns>
        public static string SendChoices(string Header, List <string> options, List <ConsoleColor> colors, int cursorStartPosition)
        {
            if (ChangeAudio != null)
            {
                ChangeAudio.Position = 0;
                changeAudioPlayer    = new SoundPlayer(ChangeAudio);
            }
            if (SelectAudio != null)
            {
                SelectAudio.Position = 0;
                selectAudioPlayer    = new SoundPlayer(SelectAudio);
            }
            Console.WriteLine();

            int topCurPosition, leftCurPosition;

            topCurPosition  = Console.CursorTop;
            leftCurPosition = Console.CursorLeft + 1;

            int startPosition = 40 - (Header.Length / 2);

            Console.SetCursorPosition(startPosition, Console.CursorTop);
            Console.Write(Header);
            Console.WriteLine();
            bool cursorState = Console.CursorVisible;

            Console.CursorVisible = false;
            for (int i = 0; i < options.Count; i++)
            {
                string toWrite = "      " + options[i] + "\n";

                ConsoleColor currentColor = Console.ForegroundColor;
                if (colors != null)
                {
                    Console.ForegroundColor = colors[i];
                }
                Console.Write(toWrite);
                if (colors != null)
                {
                    Console.ForegroundColor = currentColor;
                }
            }

            int Location = 1 + cursorStartPosition;

            Console.SetCursorPosition(leftCurPosition, topCurPosition + Location);

            Console.Write("--→");

            ConsoleKey keyPress = Console.ReadKey(true).Key;

            while (keyPress != ConsoleKey.Enter)
            {
                if (keyPress == ConsoleKey.DownArrow && Location < options.Count)
                {
                    Console.MoveBufferArea(leftCurPosition, Location + topCurPosition, 3, 1, leftCurPosition, Location + topCurPosition + 1);
                    Location++;
                    if (ChangeAudio != null)
                    {
                        changeAudioPlayer.Play();
                    }
                }
                else if (keyPress == ConsoleKey.UpArrow && Location > 1)
                {
                    Console.MoveBufferArea(leftCurPosition, Location + topCurPosition, 3, 1, leftCurPosition, Location + topCurPosition - 1);
                    Location--;
                    if (ChangeAudio != null)
                    {
                        changeAudioPlayer.Play();
                    }
                }

                keyPress = Console.ReadKey(true).Key;
            }

            if (SelectAudio != null)
            {
                selectAudioPlayer.Play();
            }

            Console.Clear();
            Console.CursorVisible = cursorState;
            return(options[Location - 1]);
        }
Exemple #3
0
 public static void MoveBufferArea(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop)
 {
     Console.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop);
 }