/// <summary>
        /// 构建
        /// </summary>
        /// <param name="command">打印命令</param>
        public override void Build(CPCLPrintCommand command)
        {
            var coordinate = Helper.GetBarcodeCoordinate(this);
            var cmd        = Helper.GetBarcodeRotateCommand(Rotate);

            command.Writer.WriteLine($"{cmd} {Type} {LineWidth} {Ratio} {Height} {coordinate.x} {coordinate.y} {Text}");
        }
 /// <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 CPCLPrintCommand BilingualLabel(this CPCLPrintCommand 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);
 }
示例#3
0
 /// <summary>
 /// 添加黑白反显
 /// </summary>
 /// <param name="command">打印命令</param>
 /// <param name="size">大小</param>
 private void AddInverseLine(CPCLPrintCommand command, int size)
 {
     if (!Reverse)
     {
         return;
     }
     command.Writer.WriteLine($"IL {X} {Y} {X + size / 2 * Text.Length} {Y} {size}");
 }
示例#4
0
        /// <summary>
        /// 构建
        /// </summary>
        /// <param name="command">打印命令</param>
        public override void Build(CPCLPrintCommand command)
        {
            var lineMaxLength = Helper.GetLineMaxLength(command.CommandInfo.Width - X, Symbol > 127 ? 24 : 12);
            var line          = new string(Symbol, lineMaxLength);

            command.Writer.WriteLine("SETMAG 1 1");
            command.Writer.WriteLine($"T 24 0 {X} {Y} {line}");
            command.Writer.WriteLine("SETMAG 0 0");
        }
示例#5
0
 /// <summary>
 /// 构建
 /// </summary>
 /// <param name="command">打印命令</param>
 public override void Build(CPCLPrintCommand command)
 {
     command.Writer.WriteLine("SETMAG 1 1");
     for (var i = 0; i < X1; i = ((i + 16) - 1) + 1)
     {
         command.Writer.WriteLine($"T 24 0 {X0 + i} {Y0 - 10} -");
     }
     command.Writer.WriteLine("SETMAG 0 0");
 }
        /// <summary>
        /// 构建
        /// </summary>
        /// <param name="command">打印命令</param>
        public override void Build(CPCLPrintCommand command)
        {
            var coordinate = Helper.GetBarcodeCoordinate(this);
            var cmd        = Helper.GetBarcodeRotateCommand(Rotate);

            command.Writer.WriteLine($"{cmd} QR {coordinate.x} {coordinate.y} M 2 U {Size}");
            command.Writer.WriteLine($"{ErrorLevel}A,{Text}");
            command.Writer.WriteLine("ENDQR");
        }
        /// <summary>
        /// 画标题内容项
        /// </summary>
        /// <param name="command"></param>
        /// <param name="y"></param>
        /// <param name="yMargin"></param>
        /// <param name="leftX"></param>
        /// <param name="rightX"></param>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="fontSize"></param>
        /// <param name="rightBold"></param>
        private void DrawItem(CPCLPrintCommand command, ref int y, int yMargin, int leftX, int rightX, string left,
                              string right, int fontSize, bool rightBold = false)
        {
            int x1 = leftX;
            int x2 = rightX;

            command.DrawText(x1, y, left, fontSize, 0, false, false, false);
            command.DrawText(x2, y, right, fontSize, 0, rightBold, false, false);
            y += yMargin + fontSize;
        }
示例#8
0
 /// <summary>
 /// 构建
 /// </summary>
 /// <param name="command">打印命令</param>
 public override void Build(CPCLPrintCommand command)
 {
     if (NewLine)
     {
         command.Writer.WriteLine(Raw);
     }
     else
     {
         command.Writer.Write(Raw);
     }
 }
示例#9
0
 /// <summary>
 /// 添加下划线
 /// </summary>
 /// <param name="command">打印命令</param>
 /// <param name="isOpen">是否开标签</param>
 private void AddUnderline(CPCLPrintCommand command, bool isOpen)
 {
     if (!Underline)
     {
         return;
     }
     if (isOpen)
     {
         command.Writer.WriteLine("UNDERLINE ON");
         return;
     }
     command.Writer.WriteLine("UNDERLINE OFF");
 }
示例#10
0
 /// <summary>
 /// 添加粗体
 /// </summary>
 /// <param name="command">打印命令</param>
 /// <param name="isOpen">是否开标签</param>
 private void AddBold(CPCLPrintCommand command, bool isOpen)
 {
     if (!Bold)
     {
         return;
     }
     if (isOpen)
     {
         command.Writer.WriteLine("SETBOLD 1");
         return;
     }
     command.Writer.WriteLine("SETBOLD 0");
 }
示例#11
0
        /// <summary>
        /// 构建
        /// </summary>
        /// <param name="command">打印命令</param>
        public override void Build(CPCLPrintCommand command)
        {
            AddUnderline(command, true);
            AddBold(command, true);

            var computeFontSizeResult = Helper.ComputeFontSize(FontSize);

            command.Writer.WriteLine($"SETMAG {computeFontSizeResult.scale} {computeFontSizeResult.scale}");

            AddText(command, computeFontSizeResult.font, computeFontSizeResult.size);
            AddInverseLine(command, computeFontSizeResult.size);
            AddBold(command, false);
            AddUnderline(command, false);
            command.Writer.WriteLine($"SETMAG 0 0");
        }
        /// <summary>
        /// 商品价格
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="startX"></param>
        /// <param name="startY"></param>
        /// <param name="price"></param>
        /// <param name="unit"></param>
        public static CPCLPrintCommand GoodsPriceLabelV2(this CPCLPrintCommand protocol, int startX,
                                                         int startY, decimal price, string unit)
        {
            // 获取比例
            var symbolScale  = GetScaleV2("symbol");
            var priceScale   = GetScaleV2("price");
            var unitScale    = GetScaleV2("unit");
            var decimalScale = GetScaleV2("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.WriteRawLine($"SETMAG {symbolScale.widthScale} {symbolScale.heightScale}");
            protocol.WriteRawLine($"T 03 0 {startX} {startY - symbolScaleResult.height} ¥");

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

            // 设置小数价格
            protocol.WriteRawLine($"SETMAG {decimalScale.widthScale} {decimalScale.heightScale}");
            protocol.WriteRawLine(
                $"T 03 0 {startX + symbolScaleResult.width + integerPriceWidth} {startY - decimalScaleResult.height - unitScaleResult.height - 16} .{priceResult.decimalPrice}");
            protocol.WriteRawLine("SETBOLD 0");
            // 设置单位
            protocol.WriteRawLine($"SETMAG {unitScale.widthScale} {unitScale.heightScale}");
            protocol.WriteRawLine(
                $"T 03 0 {startX + symbolScaleResult.width + integerPriceWidth} {startY - symbolScaleResult.height + 16} /{unit}");
            return(protocol);
        }
 /// <summary>
 /// 构建
 /// </summary>
 /// <param name="command">打印命令</param>
 public abstract void Build(CPCLPrintCommand command);
 /// <summary>
 /// 构建
 /// </summary>
 /// <param name="command">打印命令</param>
 public override void Build(CPCLPrintCommand command) => command.Writer.WriteLine($"BOX {X0} {Y0} {X1} {Y1} {Width}");
示例#15
0
        /// <summary>
        /// 添加文本
        /// </summary>
        /// <param name="command">打印命令</param>
        /// <param name="font">字体</param>
        /// <param name="size">字体大小</param>
        private void AddText(CPCLPrintCommand command, int font, int size)
        {
            var cmd = Helper.GetTextRotateCommand(Rotate);

            command.Writer.WriteLine($"{cmd} {font} {size} {X} {Y} {Text}");
        }
 /// <summary>
 /// 初始化一个<see cref="BizLabelTest"/>类型的实例
 /// </summary>
 /// <param name="output">输出</param>
 public BizLabelTest(ITestOutputHelper output) : base(output)
 {
     EasyPrint = new DefaultEasyPrint();
     Command   = EasyPrint.CreateCPCLCommand();
 }
示例#17
0
        /// <summary>
        /// 初始化一个<see cref="TestBase"/>类型的实例
        /// </summary>
        /// <param name="output">输出</param>
        public CPCLPrintCommandTest(ITestOutputHelper output) : base(output)
        {
            IEasyPrint print = new DefaultEasyPrint();

            Command = print.CreateCPCLCommand();
        }