Пример #1
0
        /// <summary>
        /// Build all information and create the TableView. Use ToString() to get the result
        /// </summary>
        /// <returns></returns>
        public TableView Build()
        {
            this.Validate();
            var newRows = this.Rows.ToList();

            this.AddRowsHeader(newRows);
            this.ChunkRows(newRows);
            this.AddPaddingInRows(newRows);
            this.InsertColumnSeparator(newRows);
            this.InsertLineSeparator(newRows);

            this.AddPaddingTop();
            var lastRow = newRows.LastOrDefault();

            foreach (var row in newRows)
            {
                this.StrBuilder.Append(this.GetLine(row));
                if (row != lastRow)
                {
                    StrBuilder.AppendLine();
                }
            }
            this.AddPaddingBottom();
            return(this);
        }
Пример #2
0
            public override string ToString()
            {
                StrBuilder builder = new StrBuilder(Name()).Append('[');

                AddFields(builder);
                return(builder.Append(']').ToString());
            }
Пример #3
0
        /// <summary>Take a Message and return formatted lines.</summary><param name="message">Message to format.</param>
        List <string> FormatMessage(int i)
        {
            var           message         = AppReporter.Report.Messages[i];
            List <string> wrappedMsngr    = message.Messenger.WrapToLines(ColWidths[(int)Cols.Messenger]);
            var           prevMessageTime = (i != 0) ? AppReporter.Report.Messages[i - 1].Time : message.Time;
            List <string> wrappedTime;

            if (i == 0 || message.Time - _PrevReportedTime > TimeSpan.FromMinutes(1))                  // Only display time if it differs from previous time.
            {
                wrappedTime = message.Time.ToShortTimeString().WrapToLines(ColWidths[(int)Cols.Time]); // Wrap one-line strings. Format TimeSpan then wrap resulting string.
            }
            else
            {
                wrappedTime = new List <string> {
                    " "
                }
            };
            _PrevReportedTime = message.Time;
            var wrappedText = message.Text.WrapToLines(ColWidths[(int)Cols.Text]);

            System.TimeSpan dt        = (message.Time - prevMessageTime);
            var             wrappedDT = dt.TotalSeconds.ToString("G3").WrapToLines(ColWidths[(int)Cols.Duration]); // Wrap one-line strings. Format TimeSpan then wrap resulting string.
            var             relPath   = Regex.Match(message.Path, @"Fluid.*").Value;

            relPath = relPath.Remove(0, 5);
            var wrappedPath   = relPath.WrapToLines(ColWidths[(int)Cols.File]);
            var wrappedCaller = message.Caller.WrapToLines(ColWidths[(int)Cols.Caller]);
            var wrappedLine   = message.Line.ToString().WrapToLines(ColWidths[(int)Cols.LineNumber]);
            var listOfLists   = new List <List <string> >(NCols)
            {
                wrappedMsngr, wrappedTime, wrappedText, wrappedDT,
                wrappedPath, wrappedCaller, wrappedLine
            };                                                                               // Find how many lines has the element with most lines.
            var listOfLengths  = listOfLists.Select(elm => elm.Count);
            int maxNLines      = listOfLengths.Max();
            var formattedLines = new List <string>(maxNLines);                        // Result is going to appear here.

            for (int j = 0; j < maxNLines; ++j)                                       // Over all lines.
            {
                StrBuilder.Clear();
                for (int k = 0; k < NCols; ++k)                                   // Over all columns.
                {
                    if (listOfLists[k].Count > j)                                 // List<string> j has an element to output at line i.
                    {
                        StrBuilder.Append(listOfLists[k][j].PadRight(ColWidths[k] + 2));
                    }
                    else
                    {
                        StrBuilder.Append(new string(' ', ColWidths[k] + 2));        // Add empty space
                    }
                }
                formattedLines.Add(StrBuilder.ToString());
            }
            return(formattedLines);
        }
Пример #4
0
        private static string CreateLockText(VesselLockDisplay vesselLock)
        {
            StrBuilder.Length = 0;
            StrBuilder.AppendLine(vesselLock.VesselName)
            .Append("Control: ").Append(vesselLock.ControlLockOwner).AppendLine()
            .Append("Update: ").Append(vesselLock.UpdateLockOwner).AppendLine()
            .Append("UnlUpdate: ").Append(vesselLock.UnloadedUpdateLockOwner).AppendLine()
            .Append("Exists in store: ").Append(vesselLock.ExistsInStore);

            return(StrBuilder.ToString());
        }
Пример #5
0
        private static string CreateLockText(VesselLockDisplay vesselLock)
        {
            StrBuilder.Length = 0;
            StrBuilder.Append("Loaded: ").Append(vesselLock.Loaded).AppendLine()
            .Append("Packed: ").Append(vesselLock.Packed).AppendLine()
            .Append("Immortal: ").Append(vesselLock.Immortal).AppendLine()
            .Append("Control: ").Append(vesselLock.ControlLockOwner).AppendLine()
            .Append("Update: ").Append(vesselLock.UpdateLockOwner).AppendLine()
            .Append("UnlUpdate: ").Append(vesselLock.UnloadedUpdateLockOwner);

            return(StrBuilder.ToString());
        }
Пример #6
0
 public ParserReader(string context)
 {
     if (!string.ReferenceEquals(context, null))
     {
         this._context = context.ToCharArray();
     }
     else
     {
         this._context = new char[0];
     }
     this._tempBuffer   = new StrBuilder();
     this._currentIndex = 0;
     this._tempIndex    = 0;
     this._level        = 0;
     this._eofIndex     = -1;
     this._markMap      = new ObjectMap <int, int>();
 }
Пример #7
0
        public string ReadLine()
        {
            if (ins == null)
            {
                return(LSystem.EMPTY);
            }
            if (ins.Available() <= 0)
            {
                return(null);
            }
            StrBuilder sbr         = new StrBuilder();
            int        c           = -1;
            bool       keepReading = true;

            do
            {
                c = ins.ReadByte();
                switch (c)
                {
                case N:
                    keepReading = false;
                    break;

                case R:
                    continue;

                case -1:
                    return(null);

                default:
                    sbr.Append((char)c);
                    break;
                }
                if (ins.Available() <= 0)
                {
                    keepReading = false;
                }
            } while (keepReading);
            return(sbr.ToString());
        }
Пример #8
0
 protected override void AddFields(StrBuilder builder)
 {
     base.AddFields(builder);
     builder.Append(", x=").Append(x).Append(", y=").Append(y);
 }
Пример #9
0
 protected virtual void AddFields(StrBuilder builder)
 {
     builder.Append("time=").Append(time).Append(", flags=")
     .Append(flags);
 }
Пример #10
0
 protected internal override void AddFields(StrBuilder builder)
 {
     base.AddFields(builder);
     builder.Append(", keyCode=").Append(keyCode).Append(", down=").Append(down);
 }
Пример #11
0
 protected internal override void AddFields(StrBuilder builder)
 {
     base.AddFields(builder);
     builder.Append(", kind=").Append(kind).Append(", id=").Append(id).Append(", pressure=").Append(pressure).Append(", size=").Append(size);
 }
Пример #12
0
 internal void RetireStrBuilder( StrBuilder b )
 {
     Debug.Assert( b.Buffer != null );
     if( strBuilderBuf == null || strBuilderBuf.Length < b.Buffer.Length )
         strBuilderBuf = b.Buffer;
 }
Пример #13
0
 protected internal override void AddFields(StrBuilder builder)
 {
     base.AddFields(builder);
     builder.Append(", id=").Append(button).Append(", down=").Append(down);
 }