Beispiel #1
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);
        }
Beispiel #2
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());
        }
        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());
        }
Beispiel #4
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());
        }