예제 #1
0
            public int Paint(Code39Settings settings, Graphics g, int left)
            {
#if DEBUG
                Rectangle gray = new Rectangle(left, 0, GetWidth(settings), settings.BarCodeHeight + settings.TopMargin + settings.BottomMargin);
                g.FillRectangle(Brushes.Gray, gray);
#endif
                int x = left;

                int w = 0;
                for (int i = 0; i < 9; i++)
                {
                    int width = (nw[i] ? settings.WideWidth : settings.NarrowWidth);

                    if (i % 2 == 0)
                    {
                        Rectangle r = new Rectangle(x, settings.TopMargin, width, settings.BarCodeHeight);
                        g.FillRectangle(brush, r);
                    }

                    x += width;
                    w += width;
                }

                return(w);
            }
예제 #2
0
            public int GetWidth(Code39Settings settings)
            {
                int width = 0;

                for (int i = 0; i < 9; i++)
                {
                    width += (nw[i] ? settings.WideWidth : settings.NarrowWidth);
                }

                return(width);
            }
예제 #3
0
        public Code39(string code, Code39Settings settings)
        {
            foreach (char c in code)
            {
                if (!codes.ContainsKey(c))
                {
                    throw new ArgumentException("Invalid character encountered in specified code.");
                }
            }

            if (!code.StartsWith("*"))
            {
                code = "*" + code;
            }
            if (!code.EndsWith("*"))
            {
                code = code + "*";
            }

            this.code     = code;
            this.settings = settings;
        }