Example #1
0
 public void WriteAtLastLine(string text, horizontal_aligment text_position_horizontal)
 {
     UpdateLastLine();
     last_line--;
     this.text_buffer.Enqueue(text);
     this.horizontal_text_position_buffer.Enqueue(text_position_horizontal);
     ScreenUpdate();
 }
Example #2
0
        // --------------------------------- TEXT FUNCTIONS: ------------------------------------
        //These functions are used to simplify text output in console aplication

        /// <summary>
        /// Internal function that is responsible of printing line of text with aligment.
        /// </summary>
        /// <param name="text">Text to write to the console.</param>
        /// <param name="horizontal_pos">Horizontal aligment.</param>
        /// <param name="vertical_pos">Vertical aligment.</param>
        /// <param name="line_count">Number of lines to print.</param>
        /// <param name="line_number">Number of printed line.</param>
        private void WriteAtLine(string text, horizontal_aligment horizontal_pos, vertical_aligment vertical_pos, int line_count, int line_number)
        {
            int x_pos = 0;
            int y_pos = 0;

            //Check if line number or text lngth aren't bigger than maximum height and width of console.
            if (this.last_line > this.screen_height || text.Length > this.screen_width)
            {
                //TO DO
            }

            switch (vertical_pos)
            {
            case vertical_aligment.up:
                y_pos     = this.last_line;
                last_line = y_pos + 1;
                break;

            case vertical_aligment.center:
                y_pos = ((((this.screen_height / 2) - (line_count / 2) + line_number) + last_line / 2) - 1);

                Debug.WriteLine("Line number: " + line_number);
                Debug.WriteLine("Line count: " + line_count);
                if (line_number.Equals(line_count - 1))
                {
                    this.last_line = (((this.screen_height / 2) - (line_count / 2) + line_number + 1) + last_line / 2);
                    Debug.WriteLine("Last line: " + this.last_line);
                }
                break;

            case vertical_aligment.down:
                y_pos     = (this.screen_height - (line_count + 1)) + line_number;
                last_line = this.screen_height - 1;
                break;
            }

            switch (horizontal_pos)
            {
            case horizontal_aligment.left:
                x_pos = 0;
                break;

            case horizontal_aligment.center:
                x_pos = ((this.screen_width / 2) - (text.Length / 2));
                break;

            case horizontal_aligment.right:
                x_pos = this.screen_width - (text.Length + 1);
                break;
            }

            // TO DO: Update 'last position'

            Console.SetCursorPosition(x_pos, y_pos);
            Console.WriteLine(text);
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <param name="text_position_horizontal"></param>
 /// <param name="text_position_vertical"></param>
 public void WriteLine(string text, horizontal_aligment text_position_horizontal, vertical_aligment text_position_vertical)
 {
     UpdateLastLine();
     if (ScreenNeedUpdate(text_position_vertical) == true)
     {
         ScreenUpdate();
     }
     this.text_buffer.Enqueue(text);
     this.horizontal_text_position_buffer.Enqueue(text_position_horizontal);
     this.last_text_position = text_position_vertical;
 }