package zs.qimai.com.printer2.canvas

import zs.qimai.com.printer2.enmu.FontAligin
import zs.qimai.com.printer2.enmu.FontSizeType
import zs.qimai.com.printer2.paint.PrintWriter
import java.util.ArrayList

class TestPrintTemplate(var maxLineChars: Int = 32) : PrintTemplate<Any> {
    override fun getPrintData(data: Any): ByteArray? {
        var datas = ArrayList<ByteArray>()
        var printWriter = PrintWriter(maxLineChars).apply {
            writelnLineText("Sample",aligin = FontAligin.CENTER,false,FontSizeType.FONT_3)
            writelnLineText("23333")
            writelnLineText("23333")
            writelnLineText("232333")
            writelnLineText("223333")
            writelnLineText("1213333")
            //编号
            //设置为倍高倍宽
      /*      write(byteArrayOf(27, 33, 48))
            //行间距
            write(byteArrayOf(27, 51, 20))

            write("Sample\n")
            //将打印缓冲区中的数据打印出来，并且按照当前行间距，把打印纸向前推进一行。 [注释] ·该命令把打印位置设置为行的开始位置。
            write(byteArrayOf(10))

            write("23333\n")

            //  write(byteArrayOf(27, 100,1))
            // write(byteArrayOf(10))

            //   write(byteArrayOf(10))


            write("Print text\n")
            write(byteArrayOf(10))
            write(byteArrayOf(27, 33, 0))
            // write(byteArrayOf(10))
            write("23333\n")
            write(byteArrayOf(10))
            write("232333\n")
            write(byteArrayOf(10))
            write("223333\n")
            write(byteArrayOf(10))
            write("1213333\n")*/

            //  writelnLineText("Sample\n", aligin = FontAligin.CENTER, fontSizeType = FontSizeType.FONT_3)
            // writeNewLine(1)
            //write(byteArrayOf(10))
            // writelnLineText("Print text\n", aligin = FontAligin.CENTER, fontSizeType = FontSizeType.FONT_0)
            // write("\n")
            writelnLineText(
                "---" + "已支付" + "---",
                aligin = FontAligin.CENTER,
                fontSizeType = FontSizeType.FONT_3
            )
            writelnLineText(formatAllLinePonit())
            writelnLineText(
                formatGoods("测试商品", "*1 ", "12.00"),
                fontSizeType = FontSizeType.FONT_2
            )
            writelnLineText(
                formatGoods("测试商品2", "【*2】", "15.00"),
                fontSizeType = FontSizeType.FONT_2
            )
            writelnLineText(formatAllLinePonit())
            writelnLineText("订单号:FD124Q443422")
            writelnLineText("谢谢惠顾，欢迎下次光临")
            writeNewLine(4)
            //writeNewLine(1)


            //打印商品


            //writelnLineText()


        }

        /* printWriter.writelnLineText("hello woshi靠左")
             .writelnLineText("hello 我是居中", aligin = FontAligin.CENTER)
             .writelnLineText("hello 我是居右", aligin = FontAligin.RIGHT)
             .writelnLineText("我是加粗", bold = true)
             .writelnLineText("我是放大1", fontSizeType = FontSizeType.FONT_1)
             .writelnLineText("我是放大2", fontSizeType = FontSizeType.FONT_2)
             .writelnLineText("我是放大3", fontSizeType = FontSizeType.FONT_3)*/
        datas.add(printWriter.convertByteArray())
        return printWriter.convertByteArray()
    }


}