Пример #1
0
 private static ILineFormatter CreateLineFormatter(string documentLine, int maxWidth)
 {
     if (documentLine.ToLower().StartsWith("<l"))
     {
         return(new LeftAlignFormatter(documentLine, maxWidth));
     }
     if (documentLine.ToLower().StartsWith("<r"))
     {
         return(new RightAlignFormatter(documentLine, maxWidth));
     }
     if (documentLine.ToLower().StartsWith("<c"))
     {
         return(new CenterAlignFormatter(documentLine, maxWidth));
     }
     if (documentLine.ToLower().StartsWith("<f>"))
     {
         return(new HorizontalRuleFormatter(documentLine, maxWidth));
     }
     if (documentLine.ToLower().StartsWith("<t"))
     {
         return(new TitleFormatter(documentLine, maxWidth));
     }
     if (documentLine.ToLower().StartsWith("<bx"))
     {
         return(new BoxFormatter(documentLine, maxWidth));
     }
     if (documentLine.ToLower().StartsWith("<j"))
     {
         var fmtr = new JustifyAlignFormatter(documentLine, maxWidth, true, _lastColumnWidths);
         _lastColumnWidths = fmtr.GetColumnWidths();
         return(fmtr);
     }
     return(new GenericFormatter(documentLine, maxWidth));
 }
Пример #2
0
 private static ILineFormatter GetJustifiedFormatter(string documentLine, int maxWidth, bool shouldBreak)
 {
     documentLine = documentLine.Replace("<p", "<j");
     documentLine = documentLine.Replace("<P", "<J");
     var match = Regex.Match(documentLine, "<[j|J][^:]+(:[^>]+)>");
     var mt = match.Success ? match.Groups[1].Value : "";
     var ratio = 1d;
     if (!string.IsNullOrEmpty(mt))
     {
         documentLine = documentLine.Replace(mt + ">", ">");
         ratio = Convert.ToDouble(mt.Trim(':'));
     }
     var fmtr = new JustifyAlignFormatter(documentLine, maxWidth, shouldBreak, ratio, _lastColumnWidths);
     _lastColumnWidths = fmtr.GetColumnWidths();
     return fmtr;
 }
Пример #3
0
        private static ILineFormatter GetJustifiedFormatter(string documentLine, int maxWidth, bool shouldBreak)
        {
            documentLine = documentLine.Replace("<p", "<j");
            documentLine = documentLine.Replace("<P", "<J");
            var match = Regex.Match(documentLine, "<[j|J][^:]+(:[^>]+)>");
            var mt    = match.Success ? match.Groups[1].Value : "";
            var ratio = 1d;

            if (!string.IsNullOrEmpty(mt))
            {
                documentLine = documentLine.Replace(mt + ">", ">");
                ratio        = Convert.ToDouble(mt.Trim(':'));
            }
            var fmtr = new JustifyAlignFormatter(documentLine, maxWidth, shouldBreak, ratio, _lastColumnWidths);

            _lastColumnWidths = fmtr.GetColumnWidths();
            return(fmtr);
        }
Пример #4
0
 private static ILineFormatter CreateLineFormatter(string documentLine, int maxWidth)
 {
     if (documentLine.ToLower().StartsWith("<l"))
         return new LeftAlignFormatter(documentLine, maxWidth);
     if (documentLine.ToLower().StartsWith("<r"))
         return new RightAlignFormatter(documentLine, maxWidth);
     if (documentLine.ToLower().StartsWith("<c"))
         return new CenterAlignFormatter(documentLine, maxWidth);
     if (documentLine.ToLower().StartsWith("<f>"))
         return new HorizontalRuleFormatter(documentLine, maxWidth);
     if (documentLine.ToLower().StartsWith("<t"))
         return new TitleFormatter(documentLine, maxWidth);
     if (documentLine.ToLower().StartsWith("<bx"))
         return new BoxFormatter(documentLine, maxWidth);
     if (documentLine.ToLower().StartsWith("<j"))
     {
         var fmtr = new JustifyAlignFormatter(documentLine, maxWidth, true, _lastColumnWidths);
         _lastColumnWidths = fmtr.GetColumnWidths();
         return fmtr;
     }
     return new GenericFormatter(documentLine, maxWidth);
 }