Пример #1
0
        private void DrawPattern(Graphics g, int x, int y, string csCharPattern)
        {
            int pixel = x;
            int num3  = y;

            for (int i = 0; i < csCharPattern.Length; i++)
            {
                int num4;
                if (csCharPattern[i] == 'n')
                {
                    num4 = (int)FunctionsGraphics.ConvertPixelToDisplay(1);
                }
                else
                {
                    num4 = (int)FunctionsGraphics.ConvertPixelToDisplay(3);
                }
                for (pixel = x; pixel < (x + num4); pixel++)
                {
                    if ((i % 2) == 0)
                    {
                        g.FillRectangle(Brushes.Black, (float)((int)FunctionsGraphics.ConvertPixelToDisplay(pixel)), (float)num3, (float)num4, base.internalbarcodeheight);
                    }
                    else
                    {
                        g.FillRectangle(Brushes.White, (float)((int)FunctionsGraphics.ConvertPixelToDisplay(pixel)), (float)num3, (float)num4, base.internalbarcodeheight);
                    }
                }
                x           += num4;
                base.cursor += num4;
            }
        }
Пример #2
0
        private void comboPageSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            PaperSize pageSize = this.GetPageSize(this.comboPageSize.SelectedItem.ToString());

            this.edtAltura.Value  = FunctionsGraphics.ConvertDisplayToMilimetro(pageSize.Height);
            this.edtLargura.Value = FunctionsGraphics.ConvertDisplayToMilimetro(pageSize.Width);
        }
Пример #3
0
        public void DrawUpcaBarcode(Graphics g, Point pt)
        {
            this._sProductType      = this.Code.Substring(0, 1);
            this._sManufacturerCode = this.Code.Substring(1, 5);
            this._sProductCode      = this.Code.Substring(6, 5);
            this._sChecksumDigit    = this.Code.Substring(11, 1);
            pt = new Point((int)FunctionsGraphics.ConvertPointToInch((float)pt.X), (int)FunctionsGraphics.ConvertPointToInch((float)pt.Y));
            float         num    = this.Width * this.Scale;
            float         height = this.Height * this.Scale;
            float         width  = num / 113f;
            GraphicsState gstate = g.Save();

            g.PageUnit  = GraphicsUnit.Inch;
            g.PageScale = 1f;
            SolidBrush    brush   = new SolidBrush(Color.Black);
            float         x       = pt.X;
            StringBuilder builder = new StringBuilder();
            float         num5    = pt.X;
            float         y       = pt.Y;
            float         num7    = 0f;
            Font          font    = new Font("Arial", this._fFontSize * this.Scale);

            this.CalculateChecksumDigit();
            builder.AppendFormat("{0}{1}{2}{3}{4}{5}{6}{1}{0}", new object[] { this._sQuiteZone, this._sLeadTail, this.ConvertToDigitPatterns(this._sProductType, this._aLeft), this.ConvertToDigitPatterns(this._sManufacturerCode, this._aLeft), this._sSeparator, this.ConvertToDigitPatterns(this._sProductCode, this._aRight), this.ConvertToDigitPatterns(this._sChecksumDigit, this._aRight) });
            string text = builder.ToString();
            float  num8 = g.MeasureString(text, font).Height;

            for (int i = 0; i < builder.Length; i++)
            {
                if (text.Substring(i, 1) == "1")
                {
                    if (num5 == pt.X)
                    {
                        num5 = x;
                    }
                    if (((i > 0x13) && (i < 0x38)) || ((i > 0x3b) && (i < 0x5f)))
                    {
                        g.FillRectangle(brush, x, y, width, height - num8);
                    }
                    else
                    {
                        g.FillRectangle(brush, x, y, width, height);
                    }
                }
                x   += width;
                num7 = x;
            }
            x = num5 - g.MeasureString(this._sProductType, font).Width;
            float num10 = y + (height - num8);

            g.DrawString(this._sProductType, font, brush, new PointF(x, num10));
            x += (g.MeasureString(this._sProductType, font).Width + (45f * width)) - g.MeasureString(this._sManufacturerCode, font).Width;
            g.DrawString(this._sManufacturerCode, font, brush, new PointF(x, num10));
            x += g.MeasureString(this._sManufacturerCode, font).Width + (5f * width);
            g.DrawString(this._sProductCode, font, brush, new PointF(x, num10));
            x += 46f * width;
            g.DrawString(this._sChecksumDigit, font, brush, new PointF(x, num10));
            g.Restore(gstate);
        }
Пример #4
0
 public override void DrawCode(Graphics g, Point pt)
 {
     if (!this.CheckBarCode())
     {
         base.DrawStringErro(g, pt.X, pt.Y);
     }
     else
     {
         pt = new Point(FunctionsGraphics.ConvertDisplayToMilimetro(pt.X), FunctionsGraphics.ConvertDisplayToMilimetro(pt.Y));
         float         num    = this.BarCodeWidth * this.Scale;
         float         height = this.BarCodeHeight * this.Scale;
         float         width  = num / 113f;
         GraphicsState gstate = g.Save();
         g.PageUnit  = GraphicsUnit.Millimeter;
         g.PageScale = 1f;
         SolidBrush    brush   = new SolidBrush(Color.Black);
         float         x       = pt.X;
         StringBuilder builder = new StringBuilder();
         float         num5    = pt.X;
         float         y       = pt.Y;
         float         num7    = 0f;
         Font          font    = new Font("Arial", this._fFontSize * this.Scale);
         string        code    = this.Code;
         string        str2    = "";
         str2 = this.ConvertLeftPattern(code.Substring(0, 7));
         builder.AppendFormat("{0}{1}{2}{3}{4}{1}{0}", new object[] { this._sQuiteZone, this._sLeadTail, str2, this._sSeparator, this.ConvertToDigitPatterns(code.Substring(7), this._aRight) });
         string text = builder.ToString();
         float  num8 = g.MeasureString(text, font).Height;
         for (int i = 0; i < builder.Length; i++)
         {
             if (text.Substring(i, 1) == "1")
             {
                 if (num5 == pt.X)
                 {
                     num5 = x;
                 }
                 if (((i > 12) && (i < 0x37)) || ((i > 0x39) && (i < 0x65)))
                 {
                     g.FillRectangle(brush, x, y, width, height - num8);
                 }
                 else
                 {
                     g.FillRectangle(brush, x, y, width, height);
                 }
             }
             x   += width;
             num7 = x;
         }
         x = num5 - g.MeasureString(this.Code.Substring(0, 1), font).Width;
         float num10 = y + (height - num8);
         g.DrawString(code.Substring(0, 1), font, brush, new PointF(x, num10));
         x += (g.MeasureString(code.Substring(0, 1), font).Width + (43f * width)) - g.MeasureString(code.Substring(1, 6), font).Width;
         g.DrawString(code.Substring(1, 6), font, brush, new PointF(x, num10));
         x += g.MeasureString(code.Substring(1, 6), font).Width + (11f * width);
         g.DrawString(code.Substring(7), font, brush, new PointF(x, num10));
         g.Restore(gstate);
     }
 }
Пример #5
0
 private void SetPageReport()
 {
     this.pageReport.PaperName    = this.comboPageSize.SelectedItem.ToString();
     this.pageReport.MarginBottom = Convert.ToInt16(this.edtBottom.Value);
     this.pageReport.MarginLeft   = Convert.ToInt16(this.edtLeft.Value);
     this.pageReport.MarginRigth  = Convert.ToInt16(this.edtRigth.Value);
     this.pageReport.MarginTop    = Convert.ToInt16(this.edtTop.Value);
     this.pageReport.LandScape    = this.rdbPaisagem.Checked;
     this.pageReport.PageHeight   = FunctionsGraphics.ConvertMilimetroToPixel((int)this.edtAltura.Value);
     this.pageReport.PageWidth    = FunctionsGraphics.ConvertMilimetroToPixel((int)this.edtLargura.Value);
 }
Пример #6
0
 private void Iniciatize()
 {
     for (int i = 0; i <= (this.comboPageSize.Items.Count - 1); i++)
     {
         if (this.comboPageSize.Items[i].ToString().Equals(this.pageReport.PaperName))
         {
             this.comboPageSize.SelectedIndex = i;
             break;
         }
     }
     this.edtBottom.Value     = this.pageReport.MarginBottom;
     this.edtLeft.Value       = this.pageReport.MarginLeft;
     this.edtRigth.Value      = this.pageReport.MarginRigth;
     this.edtTop.Value        = this.pageReport.MarginTop;
     this.edtLargura.Value    = (int)FunctionsGraphics.ConvertPixelToMilimetro(this.pageReport.PageWidth);
     this.edtAltura.Value     = (int)FunctionsGraphics.ConvertPixelToMilimetro(this.pageReport.PageHeight);
     this.rdbPaisagem.Checked = this.pageReport.LandScape;
     this.rdbRetrato.Checked  = !this.pageReport.LandScape;
 }
Пример #7
0
 public override void DrawCode(Graphics g, int x, int y)
 {
     if (!this.CheckBarCode())
     {
         base.DrawStringErro(g, x, y);
     }
     else
     {
         int    num2;
         string str    = "0";
         string str2   = '*' + base.code.ToUpper() + '*';
         int    length = str2.Length;
         string str3   = "";
         for (num2 = 0; num2 < length; num2++)
         {
             if (num2 > 0)
             {
                 str3 = str3 + str;
             }
             str3 = str3 + this.coded39Char[this.alphabet39.IndexOf(str2[num2])];
         }
         int    num3 = str3.Length;
         int    num4 = 0;
         double num5 = 3.0;
         for (num2 = 0; num2 < num3; num2++)
         {
             if (str3[num2] == '1')
             {
                 num4 += (int)(num5 * ((double)this.weight));
             }
             else
             {
                 num4 += (int)this.weight;
             }
         }
         int   width = 0;
         int   num7  = 0;
         SizeF ef    = g.MeasureString(this.headerText, this.headerFont);
         SizeF ef2   = g.MeasureString(base.code, this.footerFont);
         int   num8  = x;
         int   num9  = x;
         num8  = (num4 - ((int)ef.Width)) / 2;
         num9 += (num4 - ((int)ef2.Width)) / 2;
         if (this.showHeader)
         {
             num7 = ((int)ef.Height) + y;
             g.DrawString(this.headerText, this.headerFont, Brushes.Black, (float)num8, (float)y);
         }
         else
         {
             num7 = y;
         }
         int height = 0;
         if (base.ShowCode)
         {
             height = ((int)this.BarCodeHeight) - ((int)ef2.Height);
         }
         else
         {
             height = (int)this.BarCodeHeight;
         }
         for (num2 = 0; num2 < num3; num2++)
         {
             if (g.PageUnit == GraphicsUnit.Display)
             {
                 if (str3[num2] == '1')
                 {
                     width = (int)(FunctionsGraphics.ConvertPixelToDisplay((int)num5) * FunctionsGraphics.ConvertPixelToDisplay((int)this.weight));
                 }
                 else
                 {
                     width = (int)FunctionsGraphics.ConvertPixelToDisplay((int)this.weight);
                 }
             }
             else if (str3[num2] == '1')
             {
                 width = (int)(num5 * ((double)this.weight));
             }
             else
             {
                 width = (int)this.weight;
             }
             g.FillRectangle(((num2 % 2) == 0) ? Brushes.Black : Brushes.White, x, num7, width, height);
             x += width;
         }
         num7 += height;
         if (base.ShowCode)
         {
             g.DrawString(base.code, this.footerFont, Brushes.Black, (float)num9, (float)num7);
             num7 += (int)ef2.Height;
         }
     }
 }
Пример #8
0
 public static double ConvertPixelToDisplay(int pixel)
 {
     return(FunctionsGraphics.ConvertPixelToDisplay(pixel));
 }