Exemplo n.º 1
0
 internal void GenerateHeader(string[] values, LineOutput lo)
 {
     if (!this.disabled && !this.hideHeader)
     {
         this.GenerateRow(values, lo, true, null, lo.DisplayCells);
         string[] strArray = new string[values.Length];
         for (int i = 0; i < this.si.columnInfo.Length; i++)
         {
             if (this.si.columnInfo[i].width <= 0)
             {
                 strArray[i] = "";
             }
             else
             {
                 int width = this.si.columnInfo[i].width;
                 if (!string.IsNullOrEmpty(values[i]))
                 {
                     int num3 = lo.DisplayCells.Length(values[i]);
                     if (num3 < width)
                     {
                         width = num3;
                     }
                 }
                 strArray[i] = new string('-', width);
             }
         }
         this.GenerateRow(strArray, lo, false, null, lo.DisplayCells);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// internal helper to split a line that is too long to fit and pad it to the left
        /// with a given string
        /// </summary>
        /// <param name="prependString">string to add to the left.</param>
        /// <param name="line">line to print.</param>
        /// <param name="lo">LineOuput to write to.</param>
        private void WriteSingleLineHelper(string prependString, string line, LineOutput lo)
        {
            if (line == null)
            {
                line = string.Empty;
            }

            // compute the width of the field for the value string (in screen cells)
            int fieldCellCount = _columnWidth - _propertyLabelsDisplayLength;

            // split the lines
            StringCollection sc = StringManipulationHelper.GenerateLines(lo.DisplayCells, line, fieldCellCount, fieldCellCount);

            // padding to use in the lines after the first
            string padding = StringUtil.Padding(_propertyLabelsDisplayLength);

            // display the string collection
            for (int k = 0; k < sc.Count; k++)
            {
                if (k == 0)
                {
                    lo.WriteLine(prependString + sc[k]);
                }
                else
                {
                    lo.WriteLine(padding + sc[k]);
                }
            }
        }
Exemplo n.º 3
0
        private void WriteProperty(int k, string propertyValue, LineOutput lo)
        {
            if (propertyValue == null)
            {
                propertyValue = "";
            }
            string[] strArray = StringManipulationHelper.SplitLines(propertyValue);
            string   str      = null;

            for (int i = 0; i < strArray.Length; i++)
            {
                string prependString = null;
                if (i == 0)
                {
                    prependString = this.propertyLabels[k];
                }
                else
                {
                    if (str == null)
                    {
                        str = prependString = new string(' ', this.propertyLabelsDisplayLength);
                    }
                    prependString = str;
                }
                this.WriteSingleLineHelper(prependString, strArray[i], lo);
            }
        }
Exemplo n.º 4
0
 internal void GenerateHeader(string[] values, LineOutput lo)
 {
     if (!this.disabled && !this.hideHeader)
     {
         this.GenerateRow(values, lo, true, null, lo.DisplayCells);
         string[] strArray = new string[values.Length];
         for (int i = 0; i < this.si.columnInfo.Length; i++)
         {
             if (this.si.columnInfo[i].width <= 0)
             {
                 strArray[i] = "";
             }
             else
             {
                 int width = this.si.columnInfo[i].width;
                 if (!string.IsNullOrEmpty(values[i]))
                 {
                     int num3 = lo.DisplayCells.Length(values[i]);
                     if (num3 < width)
                     {
                         width = num3;
                     }
                 }
                 strArray[i] = new string('-', width);
             }
         }
         this.GenerateRow(strArray, lo, false, null, lo.DisplayCells);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// helper, writing a single property to the screen.
        /// It wraps the value of the property if it is tool long to fit
        /// </summary>
        /// <param name="k">index of property to write.</param>
        /// <param name="propertyValue">string value of the property to write.</param>
        /// <param name="lo">LineOutput interface to write to.</param>
        private void WriteProperty(int k, string propertyValue, LineOutput lo)
        {
            if (propertyValue == null)
            {
                propertyValue = string.Empty;
            }

            // make sure we honor embedded newlines
            string[] lines = StringManipulationHelper.SplitLines(propertyValue);

            // padding to use in the lines after the first
            string padding = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string prependString = null;

                if (i == 0)
                {
                    prependString = _propertyLabels[k];
                }
                else
                {
                    if (padding == null)
                    {
                        padding = StringUtil.Padding(_propertyLabelsDisplayLength);
                    }

                    prependString = padding;
                }

                WriteSingleLineHelper(prependString, lines[i], lo);
            }
        }
Exemplo n.º 6
0
        internal int GenerateHeader(string[] values, LineOutput lo)
        {
            if (_disabled || _hideHeader)
            {
                return(0);
            }
            else if (_header != null)
            {
                foreach (string line in _header)
                {
                    if (ExperimentalFeature.IsEnabled("PSAnsiRendering"))
                    {
                        lo.WriteLine(PSStyle.Instance.Formatting.TableHeader + line + PSStyle.Instance.Reset);
                    }
                    else
                    {
                        lo.WriteLine(line);
                    }
                }

                return(_header.Count);
            }

            _header = new List <string>();

            // generate the row with the header labels
            GenerateRow(values, lo, true, null, lo.DisplayCells, _header, isHeader: true);

            // generate an array of "--" as header markers below
            // the column header labels
            string[] breakLine = new string[values.Length];
            for (int k = 0; k < breakLine.Length; k++)
            {
                // the column can be hidden
                if (_si.columnInfo[k].width <= 0)
                {
                    breakLine[k] = string.Empty;
                    continue;
                }
                // the title can be larger than the width
                int count = _si.columnInfo[k].width;
                if (!string.IsNullOrEmpty(values[k]))
                {
                    int labelDisplayCells = lo.DisplayCells.Length(values[k]);
                    if (labelDisplayCells < count)
                    {
                        count = labelDisplayCells;
                    }
                }
                // NOTE: we can do this because "-" is a single cell character
                // on all devices. If changed to some other character, this assumption
                // would be invalidated
                breakLine[k] = StringUtil.DashPadding(count);
            }

            GenerateRow(breakLine, lo, false, null, lo.DisplayCells, _header, isHeader: true);
            return(_header.Count);
        }
Exemplo n.º 7
0
        /// <summary>
        /// write the values of the properties of an object
        /// </summary>
        /// <param name="values">array with the values in form of formatted strings.</param>
        /// <param name="lo">LineOutput interface to write to.</param>
        internal void WriteProperties(string[] values, LineOutput lo)
        {
            if (_disabled)
            {
                return;
            }

            string[] valuesToPrint = null;
            if (values == null)
            {
                // we have nothing, but we have to create an empty array
                valuesToPrint = new string[_propertyLabels.Length];
                for (int k = 0; k < _propertyLabels.Length; k++)
                {
                    valuesToPrint[k] = string.Empty;
                }
            }
            else if (values.Length < _propertyLabels.Length)
            {
                // need to pad to the end of the array
                valuesToPrint = new string[_propertyLabels.Length];
                for (int k = 0; k < _propertyLabels.Length; k++)
                {
                    if (k < values.Length)
                    {
                        valuesToPrint[k] = values[k];
                    }
                    else
                    {
                        valuesToPrint[k] = string.Empty;
                    }
                }
            }
            else if (values.Length > _propertyLabels.Length)
            {
                // need to trim
                valuesToPrint = new string[_propertyLabels.Length];
                for (int k = 0; k < _propertyLabels.Length; k++)
                {
                    valuesToPrint[k] = values[k];
                }
            }
            else
            {
                // perfect match
                valuesToPrint = values;
            }

            Debug.Assert(lo != null, "LineOutput is null");

            for (int k = 0; k < _propertyLabels.Length; k++)
            {
                WriteProperty(k, valuesToPrint[k], lo);
            }
        }
Exemplo n.º 8
0
 protected override void BeginProcessing()
 {
     if (this.lineOutput == null)
     {
         this.ProcessNullLineOutput();
     }
     Microsoft.PowerShell.Commands.Internal.Format.LineOutput lineOutput = this.lineOutput as Microsoft.PowerShell.Commands.Internal.Format.LineOutput;
     if (lineOutput == null)
     {
         this.ProcessWrongTypeLineOutput(this.lineOutput);
     }
     ((OutCommandInner)base.implementation).LineOutput = lineOutput;
     base.BeginProcessing();
 }
Exemplo n.º 9
0
        internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, int[] alignment, DisplayCells dc)
        {
            if (_disabled)
            {
                return;
            }

            // build the current row alignment settings
            int cols = _si.columnInfo.Length;

            int[] currentAlignment = new int[cols];

            if (alignment == null)
            {
                for (int i = 0; i < cols; i++)
                {
                    currentAlignment[i] = _si.columnInfo[i].alignment;
                }
            }
            else
            {
                for (int i = 0; i < cols; i++)
                {
                    if (alignment[i] == TextAlignment.Undefined)
                    {
                        currentAlignment[i] = _si.columnInfo[i].alignment;
                    }
                    else
                    {
                        currentAlignment[i] = alignment[i];
                    }
                }
            }


            if (multiLine)
            {
                string[] lines = GenerateTableRow(values, currentAlignment, lo.DisplayCells);

                for (int k = 0; k < lines.Length; k++)
                {
                    lo.WriteLine(lines[k]);
                }
            }
            else
            {
                lo.WriteLine(GenerateRow(values, currentAlignment, dc));
            }
        }
Exemplo n.º 10
0
        internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, ReadOnlySpan <int> alignment, DisplayCells dc, List <string> generatedRows)
        {
            if (_disabled)
            {
                return;
            }

            // build the current row alignment settings
            int        cols             = _si.columnInfo.Length;
            Span <int> currentAlignment = cols <= OutCommandInner.StackAllocThreshold ? stackalloc int[cols] : new int[cols];

            if (alignment == null)
            {
                for (int i = 0; i < currentAlignment.Length; i++)
                {
                    currentAlignment[i] = _si.columnInfo[i].alignment;
                }
            }
            else
            {
                for (int i = 0; i < currentAlignment.Length; i++)
                {
                    if (alignment[i] == TextAlignment.Undefined)
                    {
                        currentAlignment[i] = _si.columnInfo[i].alignment;
                    }
                    else
                    {
                        currentAlignment[i] = alignment[i];
                    }
                }
            }

            if (multiLine)
            {
                foreach (string line in GenerateTableRow(values, currentAlignment, lo.DisplayCells))
                {
                    generatedRows?.Add(line);
                    lo.WriteLine(line);
                }
            }
            else
            {
                string line = GenerateRow(values, currentAlignment, dc);
                generatedRows?.Add(line);
                lo.WriteLine(line);
            }
        }
Exemplo n.º 11
0
 internal void WriteProperties(string[] values, LineOutput lo)
 {
     if (!this.disabled)
     {
         string[] strArray = null;
         if (values == null)
         {
             strArray = new string[this.propertyLabels.Length];
             for (int j = 0; j < this.propertyLabels.Length; j++)
             {
                 strArray[j] = "";
             }
         }
         else if (values.Length < this.propertyLabels.Length)
         {
             strArray = new string[this.propertyLabels.Length];
             for (int k = 0; k < this.propertyLabels.Length; k++)
             {
                 if (k < values.Length)
                 {
                     strArray[k] = values[k];
                 }
                 else
                 {
                     strArray[k] = "";
                 }
             }
         }
         else if (values.Length > this.propertyLabels.Length)
         {
             strArray = new string[this.propertyLabels.Length];
             for (int m = 0; m < this.propertyLabels.Length; m++)
             {
                 strArray[m] = values[m];
             }
         }
         else
         {
             strArray = values;
         }
         for (int i = 0; i < this.propertyLabels.Length; i++)
         {
             this.WriteProperty(i, strArray[i], lo);
         }
     }
 }
Exemplo n.º 12
0
 internal void WriteProperties(string[] values, LineOutput lo)
 {
     if (!this.disabled)
     {
         string[] strArray = null;
         if (values == null)
         {
             strArray = new string[this.propertyLabels.Length];
             for (int j = 0; j < this.propertyLabels.Length; j++)
             {
                 strArray[j] = "";
             }
         }
         else if (values.Length < this.propertyLabels.Length)
         {
             strArray = new string[this.propertyLabels.Length];
             for (int k = 0; k < this.propertyLabels.Length; k++)
             {
                 if (k < values.Length)
                 {
                     strArray[k] = values[k];
                 }
                 else
                 {
                     strArray[k] = "";
                 }
             }
         }
         else if (values.Length > this.propertyLabels.Length)
         {
             strArray = new string[this.propertyLabels.Length];
             for (int m = 0; m < this.propertyLabels.Length; m++)
             {
                 strArray[m] = values[m];
             }
         }
         else
         {
             strArray = values;
         }
         for (int i = 0; i < this.propertyLabels.Length; i++)
         {
             this.WriteProperty(i, strArray[i], lo);
         }
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Internal helper to split a line that is too long to fit and pad it to the left
        /// with a given string.
        /// </summary>
        /// <param name="prependString">String to add to the left.</param>
        /// <param name="line">Line to print.</param>
        /// <param name="lo">LineOuput to write to.</param>
        private void WriteSingleLineHelper(string prependString, string line, LineOutput lo)
        {
            if (line == null)
            {
                line = string.Empty;
            }

            // compute the width of the field for the value string (in screen cells)
            int fieldCellCount = _columnWidth - _propertyLabelsDisplayLength;

            // split the lines
            StringCollection sc = StringManipulationHelper.GenerateLines(lo.DisplayCells, line, fieldCellCount, fieldCellCount);

            // padding to use in the lines after the first
            string padding = StringUtil.Padding(_propertyLabelsDisplayLength);

            // display the string collection
            for (int k = 0; k < sc.Count; k++)
            {
                if (k == 0)
                {
                    if (ExperimentalFeature.IsEnabled("PSAnsiRendering"))
                    {
                        lo.WriteLine(PSStyle.Instance.Formatting.FormatAccent + prependString + PSStyle.Instance.Reset + sc[k]);
                    }
                    else
                    {
                        lo.WriteLine(prependString + sc[k]);
                    }
                }
                else
                {
                    if (ExperimentalFeature.IsEnabled("PSAnsiRendering"))
                    {
                        lo.WriteLine(padding + PSStyle.Instance.Formatting.FormatAccent + PSStyle.Instance.Reset + sc[k]);
                    }
                    else
                    {
                        lo.WriteLine(padding + sc[k]);
                    }
                }
            }
        }
Exemplo n.º 14
0
        internal void GenerateHeader(string[] values, LineOutput lo)
        {
            if (_disabled)
            {
                return;
            }

            if (_hideHeader)
            {
                return;
            }

            // generate the row with the header labels
            GenerateRow(values, lo, true, null, lo.DisplayCells);

            // generate an array of "--" as header markers below
            // the column header labels
            string[] breakLine = new string[values.Length];
            for (int k = 0; k < breakLine.Length; k++)
            {
                // the column can be hidden
                if (_si.columnInfo[k].width <= 0)
                {
                    breakLine[k] = "";
                    continue;
                }
                // the title can be larger than the width
                int count = _si.columnInfo[k].width;
                if (!string.IsNullOrEmpty(values[k]))
                {
                    int labelDisplayCells = lo.DisplayCells.Length(values[k]);
                    if (labelDisplayCells < count)
                    {
                        count = labelDisplayCells;
                    }
                }
                // NOTE: we can do this because "-" is a single cell character
                // on all devices. If changed to some other character, this assumption
                // would be invalidated
                breakLine[k] = StringUtil.DashPadding(count);
            }
            GenerateRow(breakLine, lo, false, null, lo.DisplayCells);
        }
Exemplo n.º 15
0
 internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, int[] alignment, DisplayCells dc)
 {
     if (!this.disabled)
     {
         int   length   = this.si.columnInfo.Length;
         int[] numArray = new int[length];
         if (alignment == null)
         {
             for (int i = 0; i < length; i++)
             {
                 numArray[i] = this.si.columnInfo[i].alignment;
             }
         }
         else
         {
             for (int j = 0; j < length; j++)
             {
                 if (alignment[j] == 0)
                 {
                     numArray[j] = this.si.columnInfo[j].alignment;
                 }
                 else
                 {
                     numArray[j] = alignment[j];
                 }
             }
         }
         if (multiLine)
         {
             string[] strArray = this.GenerateTableRow(values, numArray, lo.DisplayCells);
             for (int k = 0; k < strArray.Length; k++)
             {
                 lo.WriteLine(strArray[k]);
             }
         }
         else
         {
             lo.WriteLine(this.GenerateRow(values, numArray, dc));
         }
     }
 }
Exemplo n.º 16
0
        private void WriteSingleLineHelper(string prependString, string line, LineOutput lo)
        {
            if (line == null)
            {
                line = "";
            }
            int firstLineLen         = this.columnWidth - this.propertyLabelsDisplayLength;
            StringCollection strings = StringManipulationHelper.GenerateLines(lo.DisplayCells, line, firstLineLen, firstLineLen);
            string           str     = new string(' ', this.propertyLabelsDisplayLength);

            for (int i = 0; i < strings.Count; i++)
            {
                if (i == 0)
                {
                    lo.WriteLine(prependString + strings[i]);
                }
                else
                {
                    lo.WriteLine(str + strings[i]);
                }
            }
        }
Exemplo n.º 17
0
 private void WriteSingleLineHelper(string prependString, string line, LineOutput lo)
 {
     if (line == null)
     {
         line = "";
     }
     int firstLineLen = this.columnWidth - this.propertyLabelsDisplayLength;
     StringCollection strings = StringManipulationHelper.GenerateLines(lo.DisplayCells, line, firstLineLen, firstLineLen);
     string str = new string(' ', this.propertyLabelsDisplayLength);
     for (int i = 0; i < strings.Count; i++)
     {
         if (i == 0)
         {
             lo.WriteLine(prependString + strings[i]);
         }
         else
         {
             lo.WriteLine(str + strings[i]);
         }
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Initialization method to be called before any other operation.
 /// </summary>
 /// <param name="lineOutput">LineOutput interfaces to write to.</param>
 /// <param name="numberOfTextColumns">Number of columns used to write out.</param>
 internal void Initialize(LineOutput lineOutput, int numberOfTextColumns)
 {
     _lo          = lineOutput;
     _textColumns = numberOfTextColumns;
 }
Exemplo n.º 19
0
 internal void Initialize(LineOutput lineOutput, ExecutionContext context)
 {
     this.lo = lineOutput;
     this.InitializeCommandsHardWired(context);
 }
Exemplo n.º 20
0
 internal void Initialize(LineOutput lineOutput, int numberOfTextColumns)
 {
     this.lo = lineOutput;
     this.textColumns = numberOfTextColumns;
 }
Exemplo n.º 21
0
        internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, ReadOnlySpan <int> alignment, DisplayCells dc, List <string> generatedRows, bool isHeader = false)
        {
            if (_disabled)
            {
                return;
            }

            // build the current row alignment settings
            int        cols             = _si.columnInfo.Length;
            Span <int> currentAlignment = cols <= OutCommandInner.StackAllocThreshold ? stackalloc int[cols] : new int[cols];

            if (alignment.IsEmpty)
            {
                for (int i = 0; i < currentAlignment.Length; i++)
                {
                    currentAlignment[i] = _si.columnInfo[i].alignment;
                }
            }
            else
            {
                for (int i = 0; i < currentAlignment.Length; i++)
                {
                    if (alignment[i] == TextAlignment.Undefined)
                    {
                        currentAlignment[i] = _si.columnInfo[i].alignment;
                    }
                    else
                    {
                        currentAlignment[i] = alignment[i];
                    }
                }
            }

            if (multiLine)
            {
                foreach (string line in GenerateTableRow(values, currentAlignment, lo.DisplayCells))
                {
                    generatedRows?.Add(line);
                    if (ExperimentalFeature.IsEnabled("PSAnsiRendering") && isHeader)
                    {
                        lo.WriteLine(PSStyle.Instance.Formatting.TableHeader + line + PSStyle.Instance.Reset);
                    }
                    else
                    {
                        lo.WriteLine(line);
                    }
                }
            }
            else
            {
                string line = GenerateRow(values, currentAlignment, dc);
                generatedRows?.Add(line);
                if (ExperimentalFeature.IsEnabled("PSAnsiRendering") && isHeader)
                {
                    lo.WriteLine(PSStyle.Instance.Formatting.TableHeader + line + PSStyle.Instance.Reset);
                }
                else
                {
                    lo.WriteLine(line);
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// write the values of the properties of an object
        /// </summary>
        /// <param name="values">array with the values in form of formatted strings</param>
        /// <param name="lo">LineOutput interface to write to</param>
        internal void WriteProperties(string[] values, LineOutput lo)
        {
            if (_disabled)
                return;

            string[] valuesToPrint = null;
            if (values == null)
            {
                // we have nothing, but we have to create an empty array
                valuesToPrint = new string[_propertyLabels.Length];
                for (int k = 0; k < _propertyLabels.Length; k++)
                    valuesToPrint[k] = "";
            }
            else if (values.Length < _propertyLabels.Length)
            {
                // need to pad to the end of the array
                valuesToPrint = new string[_propertyLabels.Length];
                for (int k = 0; k < _propertyLabels.Length; k++)
                {
                    if (k < values.Length)
                        valuesToPrint[k] = values[k];
                    else
                        valuesToPrint[k] = "";
                }
            }
            else if (values.Length > _propertyLabels.Length)
            {
                // need to trim
                valuesToPrint = new string[_propertyLabels.Length];
                for (int k = 0; k < _propertyLabels.Length; k++)
                    valuesToPrint[k] = values[k];
            }
            else
            {
                // perfect match
                valuesToPrint = values;
            }

            Debug.Assert(lo != null, "LineOutput is null");

            for (int k = 0; k < _propertyLabels.Length; k++)
            {
                WriteProperty(k, valuesToPrint[k], lo);
            }
        }
Exemplo n.º 23
0
        internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, int[] alignment, DisplayCells dc)
        {
            if (_disabled)
                return;

            // build the current row alignment settings
            int cols = _si.columnInfo.Length;
            int[] currentAlignment = new int[cols];

            if (alignment == null)
            {
                for (int i = 0; i < cols; i++)
                {
                    currentAlignment[i] = _si.columnInfo[i].alignment;
                }
            }
            else
            {
                for (int i = 0; i < cols; i++)
                {
                    if (alignment[i] == TextAlignment.Undefined)
                        currentAlignment[i] = _si.columnInfo[i].alignment;
                    else
                        currentAlignment[i] = alignment[i];
                }
            }


            if (multiLine)
            {
                string[] lines = GenerateTableRow(values, currentAlignment, lo.DisplayCells);

                for (int k = 0; k < lines.Length; k++)
                {
                    lo.WriteLine(lines[k]);
                }
            }
            else
            {
                lo.WriteLine(GenerateRow(values, currentAlignment, dc));
            }
        }
Exemplo n.º 24
0
        internal void GenerateHeader(string[] values, LineOutput lo)
        {
            if (_disabled)
                return;

            if (_hideHeader)
                return;

            // generate the row with the header labels
            GenerateRow(values, lo, true, null, lo.DisplayCells);

            // generate an array of "--" as header markers below
            // the column header labels
            string[] breakLine = new string[values.Length];
            for (int k = 0; k < _si.columnInfo.Length; k++)
            {
                // the column can be hidden
                if (_si.columnInfo[k].width <= 0)
                {
                    breakLine[k] = "";
                    continue;
                }
                // the title can be larger than the width
                int count = _si.columnInfo[k].width;
                if (!string.IsNullOrEmpty(values[k]))
                {
                    int labelDisplayCells = lo.DisplayCells.Length(values[k]);
                    if (labelDisplayCells < count)
                        count = labelDisplayCells;
                }
                // NOTE: we can do this because "-" is a single cell character
                // on all devices. If changed to some other character, this assumption
                // would be invalidated
                breakLine[k] = new string('-', count);
            }
            GenerateRow(breakLine, lo, false, null, lo.DisplayCells);
        }
Exemplo n.º 25
0
 internal void Initialize(LineOutput lineOutput, ExecutionContext context)
 {
     this.lo = lineOutput;
     this.InitializeCommandsHardWired(context);
 }
Exemplo n.º 26
0
 internal void GenerateRow(string[] values, LineOutput lo, bool multiLine, int[] alignment, DisplayCells dc)
 {
     if (!this.disabled)
     {
         int length = this.si.columnInfo.Length;
         int[] numArray = new int[length];
         if (alignment == null)
         {
             for (int i = 0; i < length; i++)
             {
                 numArray[i] = this.si.columnInfo[i].alignment;
             }
         }
         else
         {
             for (int j = 0; j < length; j++)
             {
                 if (alignment[j] == 0)
                 {
                     numArray[j] = this.si.columnInfo[j].alignment;
                 }
                 else
                 {
                     numArray[j] = alignment[j];
                 }
             }
         }
         if (multiLine)
         {
             string[] strArray = this.GenerateTableRow(values, numArray, lo.DisplayCells);
             for (int k = 0; k < strArray.Length; k++)
             {
                 lo.WriteLine(strArray[k]);
             }
         }
         else
         {
             lo.WriteLine(this.GenerateRow(values, numArray, dc));
         }
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// helper, writing a single property to the screen.
        /// It wraps the value of the property if it is tool long to fit
        /// </summary>
        /// <param name="k">index of property to write</param>
        /// <param name="propertyValue">string value of the property to write</param>
        /// <param name="lo">LineOutput interface to write to</param>
        private void WriteProperty(int k, string propertyValue, LineOutput lo)
        {
            if (propertyValue == null)
                propertyValue = "";

            // make sure we honor embedded newlines
            string[] lines = StringManipulationHelper.SplitLines(propertyValue);

            // padding to use in the lines after the first
            string padding = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string prependString = null;

                if (i == 0)
                    prependString = _propertyLabels[k];
                else
                {
                    if (padding == null)
                        padding = prependString = new string(' ', _propertyLabelsDisplayLength);

                    prependString = padding;
                }

                WriteSingleLineHelper(prependString, lines[i], lo);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// internal helper to split a line that is too long to fit and pad it to the left
        /// with a given string
        /// </summary>
        /// <param name="prependString">string to add to the left</param>
        /// <param name="line">line to print</param>
        /// <param name="lo">LineOuput to write to</param>
        private void WriteSingleLineHelper(string prependString, string line, LineOutput lo)
        {
            if (line == null)
                line = "";

            // compute the width of the field for the value string (in screen cells)
            int fieldCellCount = _columnWidth - _propertyLabelsDisplayLength;

            // split the lines 
            StringCollection sc = StringManipulationHelper.GenerateLines(lo.DisplayCells, line, fieldCellCount, fieldCellCount);

            // padding to use in the lines after the first
            string padding = new string(' ', _propertyLabelsDisplayLength);

            // display the string collection
            for (int k = 0; k < sc.Count; k++)
            {
                if (k == 0)
                {
                    lo.WriteLine(prependString + sc[k]);
                }
                else
                {
                    lo.WriteLine(padding + sc[k]);
                }
            }
        }
Exemplo n.º 29
0
 internal override void ExecuteBufferPlayBack(LineOutput.DoPlayBackCall playback)
 {
     this.playbackCall = playback;
     this.DoPrint();
 }
Exemplo n.º 30
0
 private void WriteProperty(int k, string propertyValue, LineOutput lo)
 {
     if (propertyValue == null)
     {
         propertyValue = "";
     }
     string[] strArray = StringManipulationHelper.SplitLines(propertyValue);
     string str = null;
     for (int i = 0; i < strArray.Length; i++)
     {
         string prependString = null;
         if (i == 0)
         {
             prependString = this.propertyLabels[k];
         }
         else
         {
             if (str == null)
             {
                 str = prependString = new string(' ', this.propertyLabelsDisplayLength);
             }
             prependString = str;
         }
         this.WriteSingleLineHelper(prependString, strArray[i], lo);
     }
 }