Exemplo n.º 1
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //Resize based on dpi
            var contextImage = new Bitmap(Image, new Size((int)Math.Round(Image.Width * context.ScaleFactor), (int)Math.Round(Image.Height * context.ScaleFactor)));

            NumberOfBytesPerRow = (int)(Math.Ceiling(contextImage.Width / 8.0)); //Each pixel is 1 bit or (1/8) byte
            TotalNumberOfBytes  = contextImage.Height * NumberOfBytesPerRow;

            List <string> result = new List <string>();

            result.Add(string.Format("~DG{0}:{1}.{2},{3},{4},", StorageDevice, ImageName, Extension, TotalNumberOfBytes, NumberOfBytesPerRow));

            //Foreach row
            for (int row = 0; row < contextImage.Height; row++)
            {
                string rowBinary = "";
                for (int col = 0; col < contextImage.Width; col++)
                {
                    rowBinary += contextImage.GetPixel(col, row).GetBrightness() >= 0.5 ? "0" : "1";
                }

                //Round up to X8
                rowBinary = rowBinary.PadRight(NumberOfBytesPerRow * 8, '0');
                //Each hexadecimal character represents a horizontal nibble of four dots
                string rowHex = "";
                for (int i = 0; i < rowBinary.Length; i += 4)
                {
                    rowHex += Convert.ToInt32(rowBinary.Substring(i, 4), 2).ToString("X");
                }

                result.Add(rowHex);
            }

            return(result);
        }
Exemplo n.º 2
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            var contextImage = new Bitmap(Image, new Size((int)Math.Round(Image.Width * context.ScaleFactor), (int)Math.Round(Image.Height * context.ScaleFactor)));

            byte[] objectData;
            using (var ms = new MemoryStream())
            {
                contextImage.Save(ms, ImageFormat.Png);
                objectData = ms.ToArray();
            }

            StringBuilder sb = new StringBuilder();

            foreach (Byte b in objectData)
            {
                sb.Append(String.Format("{0:X}", b).PadLeft(2, '0'));
            }
            string dataString = sb.ToString();

            List <string> result = new List <string>
            {
                string.Format("~DY{0}:{1}{2},{3},{4},{5},{6},{7}", StorageDevice, ObjectName, "", "P", "P", objectData.Length, "", dataString)
            };

            return(result);
        }
Exemplo n.º 3
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^CWa,d:o.x
            List <string> result = new List <string>();

            result.Add("^CW" + FontReplaceLetter + "," + Device + ":" + FontFileName);

            return(result);
        }
Exemplo n.º 4
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add(string.Format("^XG{0}:{1}.{2},{3},{4},", StorageDevice, ImageName, Extension, MagnificationFactorX, MagnificationFactorY));

            return(result);
        }
Exemplo n.º 5
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add(string.Format("^IM{0}:{1}.{2}", StorageDevice, ObjectName, Extension));

            return(result);
        }
Exemplo n.º 6
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            List <string> result = new List <string>();

            result.AddRange(Font.Render(context));
            result.AddRange(Origin.Render(context));
            result.Add(RenderFieldDataSection());

            return(result);
        }
Exemplo n.º 7
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^GCd,t,c
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add("^GC" + context.Scale(Diameter) + "," + context.Scale(BorderThickness) + "," + LineColor + "^FS");

            return(result);
        }
Exemplo n.º 8
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            string textOrientation = Orientation;

            if (string.IsNullOrEmpty(textOrientation))
            {
                textOrientation = context.DefaultTextOrientation;
            }
            return(new[] { "^A" + FontName + textOrientation + "," + context.Scale(FontHeight) + "," + context.Scale(FontWidth) });
        }
Exemplo n.º 9
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^ GE300,100,10,B ^ FS
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add("^GE" + context.Scale(Width) + "," + context.Scale(Height) + "," + context.Scale(BorderThickness) + "," + LineColor + "^FS");

            return(result);
        }
Exemplo n.º 10
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^GDw,h,t,c,o
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add("^GD" + context.Scale(Width) + "," + context.Scale(Height) + "," + context.Scale(BorderThickness) + "," + LineColor + "," + (RightLeaningiagonal ? "R" : "L") + "^FS");

            return(result);
        }
Exemplo n.º 11
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^GSo,h,w
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add("^GS" + Orientation + "," + context.Scale(Height) + "," + context.Scale(Width) + "^FD" + CharacterLetter + "^FS");

            return(result);
        }
Exemplo n.º 12
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            List <string> result = new List <string>();

            result.AddRange(Font.Render(context));
            result.AddRange(Origin.Render(context));
            result.Add("^TB" + Font.Orientation + "," + context.Scale(Width) + "," + context.Scale(Height));
            result.Add(RenderFieldDataSection());

            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Output the ZPL string using given context
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public List <string> Render(ZPLRenderOptions context)
        {
            List <string> result = new List <string>();

            if (context.AddStartEndFormat)
            {
                result.Add("^XA");
            }

            if (context.AddDefaultLabelHome)
            {
                result.Add("^LH0,0");
            }

            result.Add(context.ChangeInternationalFontEncoding);

            foreach (var e in this.Where(x => x.IsEnabled))
            {
                //Empty line
                if (context.AddEmptyLineBeforeElementStart)
                {
                    result.Add("");
                }

                //Comments
                if (context.DisplayComments)
                {
                    if (e.Comments.Any())
                    {
                        result.Add("^FX");
                        e.Comments.ForEach(x => result.Add("//" + x.Replace("^", "[caret]").Replace("~", "[tilde]")));
                    }
                }

                //Actual element
                if (context.CompressedRendering)
                {
                    result.Add(string.Join("", e.Render(context)));
                }
                else
                {
                    result.AddRange(e.Render(context));
                }
            }

            if (context.AddStartEndFormat)
            {
                result.Add("^XZ");
            }

            return(result);
        }
Exemplo n.º 14
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^ FO100,100
            //^ BQN,2,10
            //^ FDMM,AAC - 42 ^ FS
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add("^BQN," + Model + "," + context.Scale(MagnificationFactor) + "," + ErrorCorrection + "," + MaskValue);
            result.Add("^FD" + ErrorCorrection + "M," + Content + "^FS");

            return(result);
        }
Exemplo n.º 15
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            List <string> result = new List <string>();

            for (int i = 0; i <= 1500; i += 100)
            {
                result.AddRange(new ZPLGraphicBox(0, i, 3000, 1).Render());
            }
            for (int i = 0; i <= 1500; i += 100)
            {
                result.AddRange(new ZPLGraphicBox(i, 0, 1, 3000).Render());
            }
            return(result);
        }
Exemplo n.º 16
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^FO100,100 ^ BY3
            //^BCN,100,Y,N,N
            //^FD123456 ^ FS
            List <string> result = new List <string>();

            result.AddRange(Origin.Render(context));
            result.Add("^BC" + Orientation + ","
                       + context.Scale(Height) + ","
                       + (PrintInterpretationLine ? "Y" : "N") + ","
                       + (PrintInterpretationLineAboveCode ? "Y" : "N"));
            result.Add("^FD" + Content + "^FS");

            return(result);
        }
Exemplo n.º 17
0
        public override IEnumerable <string> Render(ZPLRenderOptions context)
        {
            //^ XA
            //^ CF0,30,30 ^ FO25,50
            //   ^ FB250,4,,
            //^ FDFD command that IS\&
            // preceded by an FB \&command.
            // ^ FS
            // ^ XZ
            List <string> result = new List <string>();

            result.AddRange(Font.Render(context));
            result.AddRange(Origin.Render(context));
            result.Add("^FB" + context.Scale(Width) + "," + MaxLineCount + "," + context.Scale(LineSpace) + "," + TextJustification + "," + context.Scale(HangingIndent));
            result.Add(RenderFieldDataSection());

            return(result);
        }
Exemplo n.º 18
0
 public string ToZPLString(ZPLRenderOptions context)
 {
     return(string.Join("\n", Render(context)));
 }
Exemplo n.º 19
0
 public override IEnumerable <string> Render(ZPLRenderOptions context)
 {
     return(new[] { "^BY" + context.Scale(ModuleWidth) + "," + Math.Round(BarWidthRatio, 1) + "," + context.Scale(Height) });
 }
Exemplo n.º 20
0
 public override IEnumerable <string> Render(ZPLRenderOptions context)
 {
     //^ FO50,50
     return(new string[] { "^FO" + context.Scale(PositionX) + "," + context.Scale(PositionY) });
 }
Exemplo n.º 21
0
 public abstract IEnumerable <string> Render(ZPLRenderOptions context);
Exemplo n.º 22
0
 public override IEnumerable <string> Render(ZPLRenderOptions context)
 {
     return(new[] { RawContent });
 }
Exemplo n.º 23
0
 public override IEnumerable <string> Render(ZPLRenderOptions context)
 {
     return(new[] { "^A" + FontName + Orientation + "," + context.Scale(FontHeight) + "," + context.Scale(FontWidth) });
 }