Ejemplo n.º 1
0
        private void WriteToScreen()
        {
            int leftIndentation      = this.indentationManager.LeftIndentation;
            int rightIndentation     = this.indentationManager.RightIndentation;
            int firstLineIndentation = this.indentationManager.FirstLineIndentation;
            int num4 = (this.textColumns - rightIndentation) - leftIndentation;

            if (num4 <= 0)
            {
                this.stringBuffer = new StringBuilder();
            }
            int num5 = (firstLineIndentation > 0) ? firstLineIndentation : -firstLineIndentation;

            if (num5 >= num4)
            {
                firstLineIndentation = 0;
            }
            int firstLineLen      = (this.textColumns - rightIndentation) - leftIndentation;
            int followingLinesLen = firstLineLen;

            if (firstLineIndentation >= 0)
            {
                firstLineLen -= firstLineIndentation;
            }
            else
            {
                followingLinesLen += firstLineIndentation;
            }
            StringCollection strings = StringManipulationHelper.GenerateLines(this.lo.DisplayCells, this.stringBuffer.ToString(), firstLineLen, followingLinesLen);
            int count = leftIndentation;
            int num9  = leftIndentation;

            if (firstLineIndentation >= 0)
            {
                count += firstLineIndentation;
            }
            else
            {
                num9 -= firstLineIndentation;
            }
            bool flag = true;

            foreach (string str in strings)
            {
                if (flag)
                {
                    flag = false;
                    this.lo.WriteLine(StringManipulationHelper.PadLeft(str, count));
                }
                else
                {
                    this.lo.WriteLine(StringManipulationHelper.PadLeft(str, num9));
                }
            }
            this.stringBuffer = new StringBuilder();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Write to the output interface.
        /// </summary>
        private void WriteToScreen()
        {
            int leftIndentation      = _indentationManager.LeftIndentation;
            int rightIndentation     = _indentationManager.RightIndentation;
            int firstLineIndentation = _indentationManager.FirstLineIndentation;

            // VALIDITY CHECKS:

            // check the useful ("active") width
            int usefulWidth = _textColumns - rightIndentation - leftIndentation;

            if (usefulWidth <= 0)
            {
                // fatal error, there is nothing to write to the device
                // just clear the buffer and return
                _stringBuffer = new StringBuilder();
            }

            // check indentation or hanging is not larger than the active width
            int indentationAbsoluteValue = (firstLineIndentation > 0) ? firstLineIndentation : -firstLineIndentation;

            if (indentationAbsoluteValue >= usefulWidth)
            {
                // valu too big, we reset it to zero
                firstLineIndentation = 0;
            }

            // compute the first line indentation or hanging
            int firstLineWidth      = _textColumns - rightIndentation - leftIndentation;
            int followingLinesWidth = firstLineWidth;

            if (firstLineIndentation >= 0)
            {
                // the first line has an indentation
                firstLineWidth -= firstLineIndentation;
            }
            else
            {
                // the first line is hanging
                followingLinesWidth += firstLineIndentation;
            }

            // error checking on invalid values

            // generate the lines using the computed widths
            StringCollection sc = StringManipulationHelper.GenerateLines(_lo.DisplayCells, _stringBuffer.ToString(),
                                                                         firstLineWidth, followingLinesWidth);

            // compute padding
            int firstLinePadding      = leftIndentation;
            int followingLinesPadding = leftIndentation;

            if (firstLineIndentation >= 0)
            {
                // the first line has an indentation
                firstLinePadding += firstLineIndentation;
            }
            else
            {
                // the first line is hanging
                followingLinesPadding -= firstLineIndentation;
            }

            // now write the lines on the screen
            bool firstLine = true;

            foreach (string s in sc)
            {
                if (firstLine)
                {
                    firstLine = false;
                    _lo.WriteLine(StringManipulationHelper.PadLeft(s, firstLinePadding));
                }
                else
                {
                    _lo.WriteLine(StringManipulationHelper.PadLeft(s, followingLinesPadding));
                }
            }

            _stringBuffer = new StringBuilder();
        }