/// <summary>
 /// 双语标签
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="startX">标签起始x坐标</param>
 /// <param name="startY">标签起始y坐标</param>
 /// <param name="zhCnLabel">中文标签</param>
 /// <param name="enLabel">英文标签</param>
 /// <param name="lineSpacing">行距</param>
 /// <param name="zhCnFontSize">中文字体大小</param>
 /// <param name="enFontSize">英文字体大小</param>
 public static IBluetoothPrinterProtocol BilingualLabel(this IBluetoothPrinterProtocol protocol, int startX,
                                                        int startY, string zhCnLabel, string enLabel, int lineSpacing = 5, FontSize zhCnFontSize = FontSize.Size24, FontSize enFontSize = FontSize.Size16)
 {
     protocol.DrawText(startX, startY, zhCnLabel, zhCnFontSize);
     protocol.DrawText(startX, startY + (int)zhCnFontSize + lineSpacing, enLabel, enFontSize);
     return(protocol);
 }
        public static IBluetoothPrinterProtocol GoodsPriceLabel(this IBluetoothPrinterProtocol protocol, int startX,
                                                                int startY, decimal price, string unit)
        {
            // 获取比例
            var symbolScale  = GetScale("symbol");
            var priceScale   = GetScale("price");
            var unitScale    = GetScale("unit");
            var decimalScale = GetScale("decimal");

            // 获取分离后的价格
            var priceResult = SplitPrice(price);

            // 获取比例结果
            var symbolScaleResult  = ComputeScale(symbolScale.widthScale, symbolScale.heightScale, symbolScale.fontSize);
            var priceScaleResult   = ComputeScale(priceScale.widthScale, priceScale.heightScale, priceScale.fontSize);
            var unitScaleResult    = ComputeScale(unitScale.widthScale, unitScale.heightScale, unitScale.fontSize);
            var decimalScaleResult = ComputeScale(decimalScale.widthScale, decimalScale.heightScale, decimalScale.fontSize);

            // 获取整数价格宽度
            var integerPriceWidth = ComputeWidth(priceScale.widthScale, priceScale.fontSize, priceResult.integerPrice);

            // 设置金钱符号
            protocol.AppendLine($"SETMAG {symbolScale.widthScale} {symbolScale.heightScale}");
            protocol.AppendLine($"T 03 0 {startX} {startY - symbolScaleResult.height} ¥");

            // 设置整数价格
            protocol.AppendLine($"SETMAG {priceScale.widthScale} {priceScale.heightScale}");
            protocol.AppendLine($"T 03 0 {startX + symbolScaleResult.width} {startY - priceScaleResult.height} {priceResult.integerPrice}");

            // 设置小数价格
            protocol.AppendLine($"SETMAG {decimalScale.widthScale} {decimalScale.heightScale}");
            protocol.AppendLine(
                $"T 03 0 {startX + symbolScaleResult.width + integerPriceWidth} {startY - decimalScaleResult.height - unitScaleResult.height - 16} .{priceResult.decimalPrice}");

            // 设置单位
            protocol.AppendLine($"SETMAG {unitScale.widthScale} {unitScale.heightScale}");
            protocol.AppendLine(
                $"T 03 0 {startX + symbolScaleResult.width + integerPriceWidth} {startY - symbolScaleResult.height + 16} /{unit}");
            return(protocol);
        }
 /// <summary>
 /// 画文字
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="startX">文字起始x坐标</param>
 /// <param name="startY">文字起始y坐标</param>
 /// <param name="width">文字绘制区域宽度(可以为0,不为0的时候文字需要根据宽度自动换行)</param>
 /// <param name="height">文字绘制区域高度(可以为0)</param>
 /// <param name="text">内容</param>
 public static IBluetoothPrinterProtocol DrawText(this IBluetoothPrinterProtocol protocol, int startX,
                                                  int startY, int width, int height, string text) =>
 protocol.DrawText(startX, startY, width, height, text, FontSize.Size16, TextStyle.None,
                   PrintColor.Black, RotationAngle.None);
 /// <summary>
 /// 画矩形
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="leftTopX">矩形框左上角x坐标</param>
 /// <param name="leftTopY">矩形框左上角y坐标</param>
 /// <param name="rightBottomX">矩形框右下角x坐标</param>
 /// <param name="rightBottomY">矩形框右下角y坐标</param>
 public static IBluetoothPrinterProtocol DrawRect(this IBluetoothPrinterProtocol protocol, int leftTopX,
                                                  int leftTopY, int rightBottomX, int rightBottomY) =>
 protocol.DrawRect(leftTopX, leftTopY, rightBottomX, rightBottomY, 1, LineStyle.Dotted);
 /// <summary>
 /// 绘制线条
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="y">线条起始点y坐标</param>
 public static IBluetoothPrinterProtocol DrawLine(this IBluetoothPrinterProtocol protocol, int y) => protocol.DrawLine(0, y, protocol.Width, y, 1, LineStyle.Full);
 /// <summary>
 /// 绘制线条
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="startX">线条起始点x坐标</param>
 /// <param name="startY">线条起始点y坐标</param>
 /// <param name="endX">线条结束点x坐标</param>
 /// <param name="endY">线条结束点y坐标</param>
 public static IBluetoothPrinterProtocol DrawLine(this IBluetoothPrinterProtocol protocol, int startX,
                                                  int startY, int endX, int endY) =>
 protocol.DrawLine(startX, startY, endX, endY, 1, LineStyle.Full);
 /// <summary>
 /// 设置打印纸张大小
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="width">宽度。单位:像素(Pixcls)</param>
 /// <param name="height">高度。单位:像素(Pixcls)</param>
 public static IBluetoothPrinterProtocol SetPage(this IBluetoothPrinterProtocol protocol, int width, int height) => protocol.SetPage(width, height, PrintOrientation.None);
 /// <summary>
 /// 画文字
 /// </summary>
 /// <param name="protocol">协议</param>
 /// <param name="startX">文字起始x坐标</param>
 /// <param name="startY">文字起始y坐标</param>
 /// <param name="text">内容</param>
 /// <param name="fontSize">字体大小</param>
 public static IBluetoothPrinterProtocol DrawText(this IBluetoothPrinterProtocol protocol, int startX,
                                                  int startY, string text, FontSize fontSize) =>
 protocol.DrawText(startX, startY, 0, 0, text, fontSize, TextStyle.None,
                   PrintColor.Black, RotationAngle.None);
 /// <summary>
 /// 初始化一个<see cref="TestBase"/>类型的实例
 /// </summary>
 /// <param name="output">输出</param>
 public ZicoxBluetoothPrinterTest(ITestOutputHelper output) : base(output)
 {
     Factory = new ZicoxBluetoothPrinterFactory();
     Printer = Factory.Create();
 }