Exemplo n.º 1
0
        private void PrintSegment(TextSegment segment)
        {
            if (!Hidden)
            {
                Console.ForegroundColor = segment.ForegroundColor;
                Console.BackgroundColor = segment.BackgroundColor;
                Console.SetCursorPosition(Left + CursorLeft, Top + CursorTop);
                Console.Write(segment.Text);
            }

            CursorLeft += segment.Text.Length;

            if (CursorLeft >= Width)
            {
                CursorLeft = 0;
                CursorTop++;

                if (CursorTop >= Height)
                    ShiftLine();
            }
        }
Exemplo n.º 2
0
 private void AppendSegment(TextSegment segment)
 {
     lock (Container)
     lock (this)
     {
         PrintSegment(segment);
         _buffer[CursorTop].Add(segment);
     }
 }
Exemplo n.º 3
0
        private void PrintSegment(TextSegment segment, ref int cursorLeft, ref int cursorTop)
        {
            if (!Hidden)
            {
                Console.ForegroundColor = segment.ForegroundColor;
                Console.BackgroundColor = segment.BackgroundColor;
                Console.SetCursorPosition(Left + cursorLeft, Top + cursorTop);
                Console.Write(segment.Text);
            }

            cursorLeft += segment.Text.Length;

            if (cursorLeft >= Width)
            {
                cursorLeft = 0;
                cursorTop++;
            }
        }
Exemplo n.º 4
0
        public void Write(string text)
        {
            lock (this)
            {
                int segmentLength = Width - CursorLeft;
                TextSegment segment;

                lock (Container)
                {
                    while (segmentLength < text.Length)
                    {
                        segment = new TextSegment
                            {
                                ForegroundColor = ForegroundColor,
                                BackgroundColor = BackgroundColor,
                                Text = text.Substring(0, segmentLength)
                            };
                        AppendSegment(segment);

                        text = text.Substring(segmentLength);
                        segmentLength = Width;
                    }
                    segment = new TextSegment
                        { ForegroundColor = ForegroundColor, BackgroundColor = BackgroundColor, Text = text };
                    AppendSegment(segment);
                }
                Container.PositionCursor();
            }
        }