예제 #1
0
        public static byte[] CreatePageModeData(Emulation emulation, int width)
        {
            byte[] data;

            data = Encoding.UTF8.GetBytes("Hello World.\n");

            Bitmap starLogoImage;

            using (var stream = Properties.Resources.star_logo_image)
            {
                starLogoImage = new Bitmap(stream);
            }

            int height = 30 * 8;        // 30mm!!

            Rectangle rectangle;

            ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation);

            builder.BeginDocument();

            builder.Append(Encoding.UTF8.GetBytes("\n*Normal*\n"));

            rectangle = new Rectangle(0, 0, width, height);

            builder.BeginPageMode(rectangle, BitmapConverterRotation.Normal);

            builder.Append(data);

            builder.AppendPageModeVerticalAbsolutePosition(160);

            builder.Append(data);

            builder.AppendPageModeVerticalAbsolutePosition(80);

            builder.AppendAbsolutePosition(data, 40);

            builder.EndPageMode();

            builder.Append(Encoding.UTF8.GetBytes("\n*Right90*\n"));

            //rectangle = new Rectangle(0, 0, width, height);
            //rectangle = new Rectangle(0, 0, height, width);
            rectangle = new Rectangle(0, 0, width, width);

            builder.BeginPageMode(rectangle, BitmapConverterRotation.Right90);

            builder.Append(data);

            builder.AppendPageModeVerticalAbsolutePosition(160);

            builder.Append(data);

            builder.AppendPageModeVerticalAbsolutePosition(80);

            builder.AppendAbsolutePosition(data, 40);

            builder.EndPageMode();

            //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180*\n"));

            //rectangle = new Rectangle(0, 0, width, height);

            //builder.BeginPageMode(rectangle, BitmapConverterRotation.Rotate180);

            //builder.Append(data);

            //builder.AppendPageModeVerticalAbsolutePosition(160);

            //builder.Append(data);

            //builder.AppendPageModeVerticalAbsolutePosition(80);

            //builder.AppendAbsolutePosition(data, 40);

            //builder.EndPageMode();

            //builder.Append(Encoding.UTF8.GetBytes("\n*Left90*\n"));

            //rectangle = new Rectangle(0, 0, width, height);
            //rectangle = new Rectangle(0, 0, height, width);

            //builder.BeginPageMode(rectangle, BitmapConverterRotation.Left90);

            //builder.Append(data);

            //builder.AppendPageModeVerticalAbsolutePosition(160);

            //builder.Append(data);

            //builder.AppendPageModeVerticalAbsolutePosition(80);

            //builder.AppendAbsolutePosition(data, 40);

            //builder.EndPageMode();

            builder.Append(Encoding.UTF8.GetBytes("\n*Mixed Text*\n"));

            //rectangle = new Rectangle(0, 0, width, height);
            rectangle = new Rectangle(0, 0, width, width);

            builder.BeginPageMode(rectangle, BitmapConverterRotation.Normal);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendAbsolutePosition(data, width / 2);

            builder.AppendPageModeRotation(BitmapConverterRotation.Right90);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendAbsolutePosition(data, width / 2);

            builder.AppendPageModeRotation(BitmapConverterRotation.Rotate180);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendAbsolutePosition(data, width / 2);

            builder.AppendPageModeRotation(BitmapConverterRotation.Left90);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendAbsolutePosition(data, width / 2);

            builder.EndPageMode();

            builder.Append(Encoding.UTF8.GetBytes("\n*Mixed Bitmap*\n"));

            //rectangle = new Rectangle(0, 0, width, height);
            rectangle = new Rectangle(0, 0, width, width);

            builder.BeginPageMode(rectangle, BitmapConverterRotation.Normal);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendBitmapWithAbsolutePosition(starLogoImage, false, width / 2);

            builder.AppendPageModeRotation(BitmapConverterRotation.Right90);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, width / 2);

            builder.AppendPageModeRotation(BitmapConverterRotation.Rotate180);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, width / 2);

            builder.AppendPageModeRotation(BitmapConverterRotation.Left90);

            builder.AppendPageModeVerticalAbsolutePosition(width / 2);

            builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, width / 2);

            builder.EndPageMode();

            builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed);

            builder.EndDocument();

            return(builder.Commands);
        }