コード例 #1
0
ファイル: ListExtensions.cs プロジェクト: nuscien/trivial
 /// <summary>
 /// Adds a console text.
 /// </summary>
 /// <param name="list">The console text collection.</param>
 /// <param name="s">The string value.</param>
 /// <param name="style">The style.</param>
 public static void Add(this IList <ConsoleText> list, StringBuilder s, ConsoleTextStyle style = null)
 {
     if (list == null)
     {
         throw new ArgumentNullException(nameof(list), "list should not be null.");
     }
     list.Add(new ConsoleText(s, style));
 }
コード例 #2
0
 /// <summary>
 /// Initialzies a new instance of the HighlightConsoleStyle class.
 /// </summary>
 /// <param name="normal">The normal style.</param>
 /// <param name="highlight">The highlight style.</param>
 /// <param name="q">The query string.</param>
 public HighlightConsoleStyle(ConsoleTextStyle normal, ConsoleTextStyle highlight, IEnumerable <string> q)
 {
     Normal    = normal;
     Highlight = highlight;
     if (q != null)
     {
         Query.AddRange(q.Where(ele => !string.IsNullOrEmpty(ele)));
     }
 }
コード例 #3
0
ファイル: ConsoleAdaptor.cs プロジェクト: androdev4u/XLParser
 public void SetTextStyle(ConsoleTextStyle style) {
   switch(style) {
     case ConsoleTextStyle.Normal:
       Console.ForegroundColor = ConsoleColor.White;
       break; 
     case ConsoleTextStyle.Error:
       Console.ForegroundColor = ConsoleColor.Red;
       break; 
   }
 }
コード例 #4
0
    internal static void AppendNumber(List <ConsoleText> col, int i, ConsoleTextStyle style, int count = 1)
    {
        var k = i + count;

        for (var j = i; j < k; j++)
        {
            var s = j.ToString("g");
            col.Add(s, style);
            col.Add(' ', 4 - s.Length, style);
        }
    }
コード例 #5
0
        public void SetTextStyle(ConsoleTextStyle style)
        {
            switch (style)
            {
            case ConsoleTextStyle.Normal:
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case ConsoleTextStyle.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                break;
            }
        }
コード例 #6
0
 /// <summary>
 /// Initialzies a new instance of the HighlightConsoleStyle class.
 /// </summary>
 /// <param name="normal">The normal style.</param>
 /// <param name="highlight">The highlight style.</param>
 /// <param name="q">The query string.</param>
 /// <param name="comparisonType">One of the enumeration values that specifies the rules for the search.</param>
 public HighlightConsoleStyle(ConsoleTextStyle normal, ConsoleTextStyle highlight, string q, StringComparison?comparisonType = null)
 {
     Normal    = normal;
     Highlight = highlight;
     if (!string.IsNullOrEmpty(q))
     {
         Query.Add(q);
     }
     if (comparisonType.HasValue)
     {
         ComparisonType = comparisonType.Value;
     }
 }
コード例 #7
0
    /// <summary>
    /// Writes an exception, followed by the current line terminator, to the standard output stream.
    /// It will flush immediately.
    /// </summary>
    /// <param name="cli">The command line interface proxy.</param>
    /// <param name="captionStyle">The style of header.</param>
    /// <param name="messageStyle">The style of details.</param>
    /// <param name="ex">The exception.</param>
    /// <param name="stackTrace">true if output stack trace; otherwise, false.</param>
    public static void WriteLine(this StyleConsole cli, ConsoleTextStyle captionStyle, ConsoleTextStyle messageStyle, Exception ex, bool stackTrace = false)
    {
        if (ex == null)
        {
            return;
        }
        if (cli == null)
        {
            cli = StyleConsole.Default;
        }
        var header = new ConsoleText(Resource.Error, captionStyle);

        if (!string.IsNullOrWhiteSpace(ex.Message))
        {
            header.Content.Append(ex.Message);
        }
        var message = new ConsoleText(Environment.NewLine, messageStyle);

        if (!string.IsNullOrWhiteSpace(ex.HelpLink))
        {
            message.Content.AppendLine(ex.HelpLink);
        }
        message.Content.Append(ex.GetType().FullName);
        if (ex.InnerException != null)
        {
            message.Content.Append($" > {ex.InnerException.GetType().FullName}");
            if (ex.InnerException is AggregateException aggEx && aggEx.InnerExceptions != null)
            {
                foreach (var iEx in aggEx.InnerExceptions)
                {
                    message.Content.AppendLine();
                    message.Content.Append($"- {iEx.GetType().FullName}\t{iEx.Message}");
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(ex.InnerException.Message))
                {
                    message.Content.AppendLine();
                    message.Content.Append(ex.InnerException.Message);
                }
            }
        }
コード例 #8
0
ファイル: ConsoleTextBox.cs プロジェクト: jmptrader/Irony-2
 public void SetTextStyle(ConsoleTextStyle style)
 {
     CurrentStyle = style == ConsoleTextStyle.Normal ? _normalStyle : _errorStyle;
 }
コード例 #9
0
    /// <summary>
    /// Writes the specified chemistry periodic table, followed by the current line terminator, to the standard output stream.
    /// </summary>
    /// <param name="console">The console instance.</param>
    /// <param name="style">The style.</param>
    public static void WriteTable(StyleConsole console, ChemicalElementConsoleStyle style)
    {
        var col = new List <ConsoleText>();

        if (style == null)
        {
            style = new();
        }
        var symbolStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.SymbolConsoleColor,
            ForegroundRgbColor     = style.SymbolRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };
        var numberStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.AtomicNumberConsoleColor,
            ForegroundRgbColor     = style.AtomicNumberRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };
        var punctuationStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.PunctuationConsoleColor,
            ForegroundRgbColor     = style.PunctuationRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };

        col.Add("1 ", punctuationStyle);
        AppendSymbol(col, ChemicalElement.H, symbolStyle);
        col.Add(' ', 64, punctuationStyle);
        AppendSymbol(col, ChemicalElement.He, symbolStyle);
        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 1, numberStyle);
        col.Add(' ', 64, punctuationStyle);
        AppendNumber(col, 2, numberStyle);
        col.AddNewLine();
        col.AddNewLine();

        col.Add("2 ", punctuationStyle);
        AppendSymbol(col, ChemicalElement.Li, symbolStyle);
        AppendSymbol(col, ChemicalElement.Be, symbolStyle);
        col.Add(' ', 40, punctuationStyle);
        AppendSymbol(col, ChemicalElement.B, symbolStyle);
        AppendSymbol(col, ChemicalElement.C, symbolStyle);
        AppendSymbol(col, ChemicalElement.N, symbolStyle);
        AppendSymbol(col, ChemicalElement.O, symbolStyle);
        AppendSymbol(col, ChemicalElement.F, symbolStyle);
        AppendSymbol(col, ChemicalElement.Ne, symbolStyle);
        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 3, numberStyle, 2);
        col.Add(' ', 40, punctuationStyle);
        AppendNumber(col, 5, numberStyle, 6);
        col.AddNewLine();
        col.AddNewLine();

        col.Add("3 ", punctuationStyle);
        AppendSymbol(col, ChemicalElement.Na, symbolStyle);
        AppendSymbol(col, ChemicalElement.Mg, symbolStyle);
        col.Add(' ', 40, punctuationStyle);
        AppendSymbol(col, ChemicalElement.Al, symbolStyle);
        AppendSymbol(col, ChemicalElement.Si, symbolStyle);
        AppendSymbol(col, ChemicalElement.P, symbolStyle);
        AppendSymbol(col, ChemicalElement.S, symbolStyle);
        AppendSymbol(col, ChemicalElement.Cl, symbolStyle);
        AppendSymbol(col, ChemicalElement.Ar, symbolStyle);
        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 11, numberStyle, 2);
        col.Add(' ', 40, punctuationStyle);
        AppendNumber(col, 13, numberStyle, 6);
        col.AddNewLine();
        col.AddNewLine();

        col.Add("4 ", punctuationStyle);
        for (var i = 19; i <= 36; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 19, numberStyle, 18);
        col.AddNewLine();
        col.AddNewLine();

        col.Add("5 ", punctuationStyle);
        for (var i = 37; i <= 54; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 37, numberStyle, 18);
        col.AddNewLine();
        col.AddNewLine();

        col.Add("6 ", punctuationStyle);
        for (var i = 55; i < 58; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        for (var i = 72; i <= 86; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 55, numberStyle, 2);
        col.Add("... ", punctuationStyle);
        AppendNumber(col, 72, numberStyle, 15);
        col.AddNewLine();
        col.AddNewLine();

        col.Add("7 ", punctuationStyle);
        for (var i = 87; i < 90; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        for (var i = 104; i <= 118; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        col.AddNewLine();
        col.Add("  ", punctuationStyle);
        AppendNumber(col, 87, numberStyle, 2);
        col.Add("... ", punctuationStyle);
        AppendNumber(col, 104, numberStyle, 15);
        col.AddNewLine();
        col.AddNewLine();

        col.Add(ChemicalElement.La.Symbol, symbolStyle);
        col.Add('-', 1, punctuationStyle);
        col.Add(ChemicalElement.Lu.Symbol, symbolStyle);
        col.Add("\t  ", punctuationStyle);
        for (var i = 57; i <= 71; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        col.AddNewLine();
        col.Add("\t  ", punctuationStyle);
        AppendNumber(col, 57, numberStyle, 15);
        col.AddNewLine();
        col.AddNewLine();

        col.Add(ChemicalElement.Ac.Symbol, symbolStyle);
        col.Add('-', 1, punctuationStyle);
        col.Add(ChemicalElement.Lr.Symbol, symbolStyle);
        col.Add("\t  ");
        for (var i = 89; i <= 103; i++)
        {
            AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
        }

        col.AddNewLine();
        col.Add("\t  ", punctuationStyle);
        AppendNumber(col, 89, numberStyle, 15);
        col.AddNewLine();
        col.AddNewLine();

        if (ChemicalElement.Has(119) && ChemicalElement.Has(120))
        {
            col.Add("8 ", punctuationStyle);
            col.Add("119 ", numberStyle);
            col.Add('-', 1, punctuationStyle);
            col.Add(" 168 ", numberStyle);
            AppendSymbol(col, ChemicalElement.Get(119), symbolStyle);
            AppendSymbol(col, ChemicalElement.Get(120), symbolStyle);
            for (var i = 121; i < 131; i++)
            {
                if (ChemicalElement.Has(i))
                {
                    AppendSymbol(col, ChemicalElement.Get(i), symbolStyle);
                }
                else
                {
                    break;
                }
            }

            col.Add("...", punctuationStyle);
            col.AddNewLine();
        }
        else
        {
            col.Add("8 ", punctuationStyle);
            col.Add("119 ", numberStyle);
            col.Add('-', 1, punctuationStyle);
            col.Add(" 168 ", numberStyle);
            col.AddNewLine();
        }

        col.Add("9 ", punctuationStyle);
        col.Add("169 ", numberStyle);
        col.Add('-', 1, punctuationStyle);
        col.Add(" 218 ", numberStyle);
        col.AddNewLine();

        (console ?? StyleConsole.Default).Write(col);
    }
コード例 #10
0
    private static void AppendSymbol(List <ConsoleText> col, ChemicalElement element, ConsoleTextStyle style)
    {
        var s = element.Symbol?.Trim();

        if (string.IsNullOrEmpty(s))
        {
            return;
        }
        if (s.Length > 4)
        {
            s = s.Substring(0, 4);
        }
        col.Add(s, style);
        col.Add(' ', 4 - s.Length, style);
    }
コード例 #11
0
    /// <summary>
    /// Writes the specified string value, followed by the current line terminator, to the standard output stream.
    /// </summary>
    /// <param name="style">The console style.</param>
    /// <param name="element">A chemicial element.</param>
    /// <param name="writeEnglishName">true if writes English name.</param>
    internal static List <ConsoleText> ToSimpleConsoleText(ChemicalElementConsoleStyle style, ChemicalElement element, bool writeEnglishName)
    {
        if (string.IsNullOrWhiteSpace(element.Symbol) || element.Period < 1)
        {
            return(null);
        }
        var name = writeEnglishName ? element.EnglishName : element.Name;

        if (style == null)
        {
            style = new();
        }
        var col = new List <ConsoleText>
        {
            {
                $"{element.AtomicNumber:g}\t",
                new ConsoleTextStyle
                {
                    ForegroundConsoleColor = style.AtomicNumberConsoleColor,
                    ForegroundRgbColor     = style.AtomicNumberRgbColor,
                    BackgroundConsoleColor = style.BackgroundConsoleColor,
                    BackgroundRgbColor     = style.BackgroundRgbColor
                }
            },
            {
                element.Symbol,
                new ConsoleTextStyle
                {
                    ForegroundConsoleColor = style.SymbolConsoleColor,
                    ForegroundRgbColor     = style.SymbolRgbColor,
                    BackgroundConsoleColor = style.BackgroundConsoleColor,
                    BackgroundRgbColor     = style.BackgroundRgbColor
                }
            },
            {
                $"\t{name}",
                new ConsoleTextStyle
                {
                    ForegroundConsoleColor = style.NameConsoleColor,
                    ForegroundRgbColor     = style.NameRgbColor,
                    BackgroundConsoleColor = style.BackgroundConsoleColor,
                    BackgroundRgbColor     = style.BackgroundRgbColor
                }
            }
        };

        if (!double.IsNaN(element.AtomicWeight))
        {
            var punctuationStyle = new ConsoleTextStyle
            {
                ForegroundConsoleColor = style.PunctuationConsoleColor,
                ForegroundRgbColor     = style.PunctuationRgbColor,
                BackgroundConsoleColor = style.BackgroundConsoleColor,
                BackgroundRgbColor     = style.BackgroundRgbColor
            };
            if (name.Length < 8)
            {
                col.Add('\t', 2, punctuationStyle);
            }
            else
            {
                col.Add(" \t", punctuationStyle);
            }
            col.Add(element.AtomicWeight.ToString("#.######"), punctuationStyle);
        }

        col.AddNewLine();
        return(col);
    }
コード例 #12
0
    /// <summary>
    /// Writes the element information to the standard output stream.
    /// </summary>
    /// <param name="style">The console style.</param>
    /// <param name="element">A chemicial element.</param>
    /// <param name="containIsotopes">true if also write its isotopes; otherwise, false.</param>
    internal static List <ConsoleText> ToConsoleText(ChemicalElementConsoleStyle style, ChemicalElement element, bool containIsotopes = false)
    {
        if (element is null)
        {
            return(null);
        }
        if (style == null)
        {
            style = new();
        }
        var name = element.Name;
        var col  = new List <ConsoleText>
        {
            {
                $"{element.AtomicNumber:g}\t",
                new ConsoleTextStyle
                {
                    ForegroundConsoleColor = style.AtomicNumberConsoleColor,
                    ForegroundRgbColor     = style.AtomicNumberRgbColor,
                    BackgroundConsoleColor = style.BackgroundConsoleColor,
                    BackgroundRgbColor     = style.BackgroundRgbColor
                }
            },
            {
                element.Symbol,
                new ConsoleTextStyle
                {
                    ForegroundConsoleColor = style.SymbolConsoleColor,
                    ForegroundRgbColor     = style.SymbolRgbColor,
                    BackgroundConsoleColor = style.BackgroundConsoleColor,
                    BackgroundRgbColor     = style.BackgroundRgbColor
                }
            }
        };
        var nameStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.NameConsoleColor,
            ForegroundRgbColor     = style.NameRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };

        if (!string.IsNullOrWhiteSpace(element.EnglishName) && !name.Equals(element.EnglishName))
        {
            col.Add($"\t{element.EnglishName}", nameStyle);
        }
        col.AddNewLine();
        col.Add($" {name}", nameStyle);
        var punctuationStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.PunctuationConsoleColor,
            ForegroundRgbColor     = style.PunctuationRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };

        if (name.Length == 1 && name[0] >= 0x2E00)
        {
            col.Add($"\t(U+{(int)name[0]:X4})", punctuationStyle);
        }
        col.AddNewLine();
        var keyStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.PropertyKeyConsoleColor,
            ForegroundRgbColor     = style.PropertyKeyRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };
        var valueStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.PropertyValueConsoleColor,
            ForegroundRgbColor     = style.PropertyValueRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };

        if (!double.IsNaN(element.AtomicWeight))
        {
            col.Add(" Weight", keyStyle);
            col.Add(" = ", punctuationStyle);
            col.Add(element.AtomicWeight.ToString("#.########"), valueStyle);
            col.AddNewLine();
        }

        if (element.Period > 0 && element.Group > 0)
        {
            col.Add(" Period", keyStyle);
            col.Add(" = ", punctuationStyle);
            col.Add(element.Period.ToString("g"), valueStyle);
            col.Add("    ", punctuationStyle);
            col.Add("Group", keyStyle);
            col.Add(" = ", punctuationStyle);
            col.Add(element.Group.ToString("g"), valueStyle);
            if (!string.IsNullOrWhiteSpace(element.Block))
            {
                col.Add("    ", punctuationStyle);
                col.Add("Block", keyStyle);
                col.Add(" = ", punctuationStyle);
                col.Add(element.Block, valueStyle);
            }
        }

        if (!containIsotopes)
        {
            return(col);
        }
        var isotopes = element.Isotopes();

        if (isotopes.Count < 1)
        {
            return(col);
        }
        col.AddNewLine();
        var isotopeStyle = new ConsoleTextStyle
        {
            ForegroundConsoleColor = style.IsotopeConsoleColor,
            ForegroundRgbColor     = style.IsotopeRgbColor,
            BackgroundConsoleColor = style.BackgroundConsoleColor,
            BackgroundRgbColor     = style.BackgroundRgbColor
        };

        col.Add(isotopes.Count == 1 ? ChemistryResource.Isotope : ChemistryResource.Isotopes, isotopeStyle);
        col.Add($" ({isotopes.Count})", punctuationStyle);
        var i = 0;

        if (isotopes.Count > 150)
        {
            foreach (var isotope in isotopes)
            {
                if (i % 8 == 0)
                {
                    col.AddNewLine();
                }
                col.Add($"{isotope.AtomicMassNumber}\t", isotopeStyle);
                i++;
            }

            col.AddNewLine();
            return(col);
        }

        col.AddNewLine();
        foreach (var isotope in isotopes)
        {
            if (isotope is null)
            {
                continue;
            }
            i++;
            var weight = isotope.HasAtomicWeight ? isotope.AtomicWeight.ToString("#.########") : string.Empty;
            col.Add($" {isotope.AtomicMassNumber}\t{weight}", isotopeStyle);
            if (weight.Length < 8)
            {
                col.Add('\t', 1, isotopeStyle);
            }
            if (i % 3 > 0)
            {
                col.Add(" \t");
            }
            else
            {
                col.AddNewLine();
            }
        }

        if (i % 3 > 0)
        {
            col.AddNewLine();
        }
        return(col);
    }
コード例 #13
0
ファイル: ListExtensions.cs プロジェクト: nuscien/trivial
 /// <summary>
 /// Adds a console text.
 /// </summary>
 /// <param name="list">The console text collection.</param>
 /// <param name="c">The character.</param>
 /// <param name="repeatCount">The number of times to append value.</param>
 /// <param name="style">The style.</param>
 public static void Add(this IList <ConsoleText> list, char c, int repeatCount = 1, ConsoleTextStyle style = null)
 {
     if (list == null)
     {
         throw new ArgumentNullException(nameof(list), "list should not be null.");
     }
     list.Add(new ConsoleText(c, repeatCount, style));
 }
コード例 #14
0
 public void SetTextStyle(ConsoleTextStyle style)
 {
     // not supported
 }
コード例 #15
0
 public static void WriteLine(this string str, ConsoleTextStyle style = ConsoleTextStyle.NORMAL, ConsoleAlignment align = ConsoleAlignment.LEFT)
 {
     WriteIt(str, style, align: align);
 }
コード例 #16
0
    /// <summary>
    /// Converts to boolean list and writes to the standard output stream.
    /// White represented as false, black represented as true.
    /// </summary>
    /// <param name="cli">The command line interface proxy.</param>
    /// <param name="style">The style that foreground represents black and background represents white.</param>
    /// <returns>The boolean list.</returns>
    /// <exception cref="InvalidOperationException">It was not an EAN-13 ro EAN-8 code.</exception>
    public List <bool> ToBarcode(StyleConsole cli, ConsoleTextStyle style = null)
    {
        List <bool> barcode;

        try
        {
            barcode = ToBarcode();
        }
        catch (InvalidOperationException)
        {
            cli.WriteLine(style, value);
            throw;
        }

        var col = new List <ConsoleText>();

        if (style == null)
        {
            style = new ConsoleTextStyle(System.Drawing.Color.FromArgb(16, 16, 16), ConsoleColor.Black, System.Drawing.Color.FromArgb(206, 206, 206), ConsoleColor.Gray);
        }
        var black = new ConsoleTextStyle(style.ForegroundRgbColor, style.ForegroundConsoleColor, style.ForegroundRgbColor, style.ForegroundConsoleColor);
        var white = new ConsoleTextStyle(style.BackgroundRgbColor, style.BackgroundConsoleColor, style.BackgroundRgbColor, style.BackgroundConsoleColor);
        var bg    = new string(' ', 12 + barcode.Count);

        col.Add(bg, white);
        col.Add(Environment.NewLine);
        var s = value;

        cli.Flush();
        if (cli.Mode == StyleConsole.Modes.Text && cli.Handler == null)
        {
            cli.WriteLine(style, s);
            return(barcode);
        }
        else if (barcode.Count + 12 > GetBufferSafeWidth(cli))
        {
            col.Clear();
            foreach (var b in barcode)
            {
                col.Add(' ', 1, b ? black : white);
            }

            col.Add(Environment.NewLine);
            col.Add(s, style);
            cli.WriteLine(col);
            return(barcode);
        }
        else if (barcode.Count == 95 && s.Length == 13)
        {
            for (var i = 0; i < 4; i++)
            {
                col.Add(' ', 7, white);
                foreach (var b in barcode)
                {
                    col.Add(' ', 1, b ? black : white);
                }

                col.Add(' ', 5, white);
                col.Add(Environment.NewLine);
            }

            var isbn = false;
            if (s.StartsWith("97"))
            {
                if (s.StartsWith("9790"))
                {
                    isbn = true;
                    col.Add("ISMN 9 ", style);
                }
                else if (s.StartsWith("978") || s.StartsWith("979"))
                {
                    isbn = true;
                    col.Add("ISBN 9 ", style);
                }
                else if (s.StartsWith("977"))
                {
                    isbn = true;
                    col.Add("ISSN 9 ", style);
                }
            }

            if (!isbn)
            {
                col.Add(' ', 4, white);
                col.Add(s[0], 1, style);
                col.Add(' ', 2, white);
            }

            for (var i = 0; i < 3; i++)
            {
                col.Add(' ', 1, barcode[i] ? black : white);
            }

            for (var i = 1; i < 7; i++)
            {
                col.Add(' ', 3, white);
                col.Add(s[i], 1, style);
                col.Add(' ', 3, white);
            }

            for (var i = 45; i < 50; i++)
            {
                col.Add(' ', 1, barcode[i] ? black : white);
            }

            for (var i = 7; i < 13; i++)
            {
                col.Add(' ', 3, white);
                col.Add(s[i], 1, style);
                col.Add(' ', 3, white);
            }

            for (var i = 92; i < 95; i++)
            {
                col.Add(' ', 1, barcode[i] ? black : white);
            }

            col.Add(' ', 5, white);
            col.Add(Environment.NewLine);
        }
        else if (barcode.Count == 67 && s.Length == 8)
        {
            for (var i = 0; i < 4; i++)
            {
                col.Add(' ', 6, white);
                foreach (var b in barcode)
                {
                    col.Add(' ', 1, b ? black : white);
                }

                col.Add(' ', 6, white);
                col.Add(Environment.NewLine);
            }

            col.Add(' ', 6, white);
            for (var i = 0; i < 3; i++)
            {
                col.Add(' ', 1, barcode[i] ? black : white);
            }

            for (var i = 0; i < 4; i++)
            {
                col.Add(' ', 3, white);
                col.Add(s[i], 1, style);
                col.Add(' ', 3, white);
            }

            for (var i = 31; i < 36; i++)
            {
                col.Add(' ', 1, barcode[i] ? black : white);
            }

            for (var i = 4; i < 8; i++)
            {
                col.Add(' ', 3, white);
                col.Add(s[i], 1, style);
                col.Add(' ', 3, white);
            }

            for (var i = 64; i < 67; i++)
            {
                col.Add(' ', 1, barcode[i] ? black : white);
            }

            col.Add(' ', 6, white);
            col.Add(Environment.NewLine);
        }
        else if ((barcode.Count == 48 && s.Length == 5) || (barcode.Count == 21 && s.Length == 2))
        {
            col.Add(' ', 14, white);
            foreach (var c in s)
            {
                col.Add(c, 1, style);
                col.Add(' ', 8, white);
            }

            col.Add(' ', 1, white);
            col.Add(Environment.NewLine);
            for (var i = 0; i < 4; i++)
            {
                col.Add(' ', 6, white);
                foreach (var b in barcode)
                {
                    col.Add(' ', 1, b ? black : white);
                }

                col.Add(' ', 6, white);
                col.Add(Environment.NewLine);
            }
        }
        else
        {
            for (var i = 0; i < 4; i++)
            {
                col.Add(' ', 6, white);
                foreach (var b in barcode)
                {
                    col.Add(' ', 1, b ? black : white);
                }

                col.Add(' ', 6, white);
                col.Add(Environment.NewLine);
            }
        }

        col.Add(bg, white);
        (cli ?? StyleConsole.Default).WriteLine(col);
        return(barcode);
    }