コード例 #1
0
        private void btnCreatebarcode_Click(object sender, EventArgs e)
        {
            this.barCodeControl1.TopText  = "\n" + txtcompany.Text + "\n ================= \n" + txttoptext.Text + "\n\nPrice: " + txtCurrency.Text + txtPrice.Text;
            this.barCodeControl1.SupSpace = 22;



            //generate the barcode use the settings
            BarCodeGenerator generator = new BarCodeGenerator(barCodeControl1);
            Image            barcode   = generator.GenerateImage();

            this.barCodeControl1.SaveToFile("barcodeImage.png");
            btnSaveimage.Enabled = true;

            string barcodeimagestore = Application.StartupPath + @"\barcodeImage.png";

            //save the barcode as an image
            // barcode.Save(@"..\..\..\BarCode\barcode.png");
            //   barcode.Save(barcodeimagestore);
            //launch the generated barcode image
            //   string path = "..\\..\\..\\BarCode\\barcode.png";

            picbarcode1.ImageLocation = barcodeimagestore;
            picbarcode2.ImageLocation = barcodeimagestore;
            picbarcode3.ImageLocation = barcodeimagestore;
            picbarcode4.ImageLocation = barcodeimagestore;
            picbarcode5.ImageLocation = barcodeimagestore;
            picbarcode6.ImageLocation = barcodeimagestore;
        }
コード例 #2
0
ファイル: Frmcode.cs プロジェクト: mrDarkk/paytm
        private void Frmcode_Load(object sender, EventArgs e)
        {
            label1.Text = Form3.NO_code;

            BarcodeSettings.ApplyKey("your key");//you need a key from e-iceblue, otherwise the watermark 'E-iceblue' will be shown in barcode
            BarcodeSettings settings = new BarcodeSettings();

            settings.Type           = BarCodeType.QRCode;
            settings.Unit           = GraphicsUnit.Pixel;
            settings.ShowText       = false;
            settings.ResolutionType = ResolutionType.UseDpi;
            //input data
            string data = label1.Text;

            settings.Data      = data;
            settings.X         = 6;
            settings.ForeColor = Color.Blue;

            //generate QR code
            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image            QRbarcode = generator.GenerateImage();

            //display QR code image in picture box
            pictureBox1.Image = QRbarcode;
        }
コード例 #3
0
        public static BitmapImage GenerateBarCodeRetBitMap(this string data, bool save = false, string path = "")
        {
            BarcodeSettings setting = new BarcodeSettings();

            setting.Data = data;
            //setting.Type = Spire.Barcode.BarCodeType.Code93Extended;
            BarCodeGenerator gen          = new BarCodeGenerator(setting);
            Image            barcodeimage = gen.GenerateImage();

            if (save)
            {
                if (File.Exists(path + "\\" + data + ".png"))
                {
                    // File.Delete(path + "\\" + data + ".png");
                }
                barcodeimage.Save(path + "\\" + data + ".png", ImageFormat.Png);
            }


            MemoryStream ms = new MemoryStream();

            //variable that holds image
            barcodeimage.Save(ms, ImageFormat.Bmp);
            //my buffer byte
            byte[] buffer = ms.GetBuffer();
            //Create new MemoryStream that has the contents of buffer
            MemoryStream bufferPasser = new MemoryStream(buffer);

            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.StreamSource = bufferPasser;
            bitmap.EndInit();
            return(bitmap);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: BartoszRudnik/UP-L
        private void generateBarCode_ButtonClick(object sender, EventArgs e)
        {
            string barCode = textBox1.Text.Trim();

            try
            {
                if (!codeLength(barCode))
                {
                    throw new Exception();
                }

                BarcodeSettings barcodeSettings = new BarcodeSettings();

                barcodeSettings.Type             = BarCodeType.EAN13;
                barcodeSettings.Data             = barCode;
                barcodeSettings.UseChecksum      = CheckSumMode.ForceEnable;
                barcodeSettings.ShowTextOnBottom = true;
                barcodeSettings.TextAlignment    = StringAlignment.Center;

                BarCodeGenerator generator = new BarCodeGenerator(barcodeSettings);

                Image barCodeImage = generator.GenerateImage();
                barCodeImage = usunNapis(barCodeImage);

                pictureBox1.Image = barCodeImage;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Podano kod o zlej dlugosci");
            }
        }
コード例 #5
0
ファイル: ApiBarCode.cs プロジェクト: luanreimbeerg/MEU_TCC
        // Esse plugin usa o NuGET Spire.Barcode

        public Image SalvarCodigoBarras(string mensagem, string arquivo = null)
        {
            // Configura Codigo de Barras
            BarcodeSettings config = new BarcodeSettings();

            config.ShowText                 = false;
            config.ShowTopText              = false;
            config.ShowCheckSumChar         = false;
            config.ShowTextOnBottom         = false;
            config.ShowStartCharAndStopChar = false;

            // Atribui valor ao Codigo de Barras
            config.Data = mensagem;

            // Gera o Codigo de Barras
            BarCodeGenerator barcode = new BarCodeGenerator(config);
            Image            code    = barcode.GenerateImage();

            // Salva Imagem
            if (!string.IsNullOrEmpty(arquivo))
            {
                code.Save(arquivo.Replace(".png", "") + ".png", ImageFormat.Png);
            }

            // Retorna Imagem Codigo de Barras
            return(code);
        }
コード例 #6
0
        private void Get_AWS_Data_Click(object sender, RoutedEventArgs e)
        {
            string ID_Code    = "";
            string Key_return = "";
            Communication_DatabaseEntities1 var_data = new Communication_DatabaseEntities1();
            var Key_Return = var_data.Register_User(First_Name_Input.Text, Last_Name_Input.Text);

            foreach (var item in Key_Return)
            {
                Console.WriteLine(item.Pass_Key);
                Console.WriteLine(item.User_ID);
                ID_Code    = item.User_ID.ToString();
                Key_return = item.Pass_Key;
            }
            string          QR_INPUT = ID_Code + "," + Key_return;
            BarcodeSettings bs       = new BarcodeSettings();

            bs.Type = BarCodeType.QRCode;
            bs.Data = QR_INPUT;
            BarCodeGenerator bg = new BarCodeGenerator(bs);

            bg.GenerateImage().Save("QRCode.png");
            System.Diagnostics.Process.Start("QRCode.png");
            MessageBox.Show("User Added!");
            Outside_User enter_pass = new Outside_User();

            enter_pass.Show();
        }
コード例 #7
0
        protected void Validate_click(object sender, EventArgs e)
        {
            System.Drawing.Image image = null;
            BarCodeGenerator     barcode;
            int idCommande = 0;

            foreach (ListItem item in CheckBoxList2.Items)
            {
                if (item.Selected)
                {
                    idCommande = Int32.Parse(item.Text.Substring(item.Text.IndexOf(":") + 1));
                    int test = (int)commandManager.getBarCode(idCommande);
                    barcode = new BarCodeGenerator(commandManager.getBarCode(idCommande));
                    image   = barcode.barcodeImage;
                }
            }

            Response.Clear();
            Response.ContentType = "image/png";
            Response.AppendHeader("Content-Disposition", "attachment; filename=downloadedFile.png");
            byte[] bytes = (byte[])(new ImageConverter()).ConvertTo(image, typeof(byte[]));
            Response.BinaryWrite(bytes);
            Response.End();
            Response.Redirect("ConsultCommande.aspx");
        }
コード例 #8
0
    public static void Generate(string barcode)
    {
        var settings = new BarcodeSettings
        {
            Type             = BarCodeType.EAN128,
            Data             = barcode,
            ShowTextOnBottom = true,
            TextAlignment    = StringAlignment.Center
        };
        var    generator    = new BarCodeGenerator(settings);
        Image  barcodeImage = generator.GenerateImage();
        string path         = HttpRuntime.AppDomainAppPath.ToString() + "Images\\Barcode\\";

        using (Bitmap bitmap = new Bitmap(barcodeImage))
        {
            //string wantPath = Server.MapPath("~/Images/Barcode/");
            if (!Directory.Exists(path))
            {   //如果不存在就创建
                Directory.CreateDirectory(path);
                bitmap.Save(path + barcode + ".jpg");
            }
            else
            {
                bitmap.Save(path + barcode + ".jpg");
            }
        }
        //MyBarcodeGenerator.ShowBarcode(book.isbn13, this.Response);
        //return barcodeImage;
    }
コード例 #9
0
        private object Get2DBarcode(DataRow row)
        {
            string data = ParseData(string.Format("HRVHUB30\nHRK\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n{7}\nHR{8}\n{9}\nOTHR\n{10}\n",
                                                  GetCijenaBarcode(row["UkupanIznos"]), row["RoditeljIme"].ToString() + " " + row["RoditeljPrezime"].ToString(), row["adresa"], row["grad"],
                                                  row["ustanovaNaziv"], row["ustanovaAdresa"], row["ustanovaPosta"].ToString() + " " + row["ustanovaGrad"].ToString(), row["ustanoaIBAN"].ToString().Replace(" ", string.Empty),
                                                  row["ustanovaModel"], row["ustanovaPozivNaBroj"], row["nazivObracuna"]));

            IBarcodeSettings settings = new BarcodeSettings();

            settings.Data             = data;
            settings.Data2D           = data;
            settings.Type             = BarCodeType.Pdf417;
            settings.Pdf417DataMode   = Pdf417DataMode.Byte;
            settings.ShowText         = false;
            settings.ShowTextOnBottom = false;
            settings.ShowTopText      = false;
            settings.Pdf417Truncated  = false;
            settings.Unit             = GraphicsUnit.Millimeter;
            settings.Pdf417ECL        = Pdf417ECL.Level4;
            settings.ColumnCount      = 9;
            settings.XYRatio          = 2.2F;
            settings.X = 0.5F;
            settings.Y = 1.0F;

            BarCodeGenerator gen = new BarCodeGenerator(settings);

            ImageConverter converter = new ImageConverter();

            return((byte[])converter.ConvertTo(gen.GenerateImage(), typeof(byte[])));
        }
コード例 #10
0
        public static string Generate_Code128(string value)
        {
            BarCodeGenerator generator = new BarCodeGenerator(new BarcodeSettings()
            {
                Data      = value,
                Type      = BarCodeType.Code128,
                Data2D    = value,
                ShowText  = false,
                TopText   = value,
                BarHeight = 15
            });

            try
            {
                Image barcode = generator.GenerateImage();
                Image cropped = CropAtRect(barcode, new Rectangle()
                {
                    Height   = 60,
                    Width    = barcode.Width,
                    X        = 0,
                    Y        = 0,
                    Location = new Point()
                    {
                        X = 0,
                        Y = 17
                    }
                });
                //I will crop at frontend (so, using barcode instead of cropped)
                return(Convert.ToBase64String(ConvertBitMapToByteArray(barcode)));
            }
            catch (Exception e)
            {
                return("");
            }
        }
コード例 #11
0
        public static Image GenerateBarCode(this string data, bool save = false, string path = "")
        {
            BarcodeSettings setting = new BarcodeSettings();

            setting.Data = data;
            setting.Type = Spire.Barcode.BarCodeType.Code93Extended;
            BarCodeGenerator gen          = new BarCodeGenerator(setting);
            Image            barcodeimage = gen.GenerateImage();


            if (save)
            {
                if (!Directory.Exists(path))
                {
                    AdminstrationHelper.MakeDirectory(path);
                }
                if (File.Exists(path + "\\" + data + ".png"))
                {
                    // File.Delete(path + "\\" + data + ".png");
                }
                barcodeimage.Save(path + "\\" + data + ".png", ImageFormat.Png);
            }


            return(barcodeimage);
        }
コード例 #12
0
        private void btnTicketPrint_Click(object sender, EventArgs e)
        {
            try
            {
                BarcodeSettings barsetting = new BarcodeSettings();

                //set the x dimension
                barsetting.X    = 0.8f;
                barsetting.Unit = GraphicsUnit.Millimeter;

                barsetting.HasBorder   = true;
                barsetting.BorderWidth = 0.5F;

                //set the data
                barsetting.Data   = tbUserId.Text;
                barsetting.Data2D = tbUserId.Text;

                //generate EAN128 barcode
                barsetting.Type = BarCodeType.Code128;

                BarCodeGenerator bargenerator = new BarCodeGenerator(barsetting);
                Image            barcodeimage = bargenerator.GenerateImage();
                filename = "C:/xampp/htdocs/ProP_Sems2/Applications/C#/Main GUI/HHF APP/bin/Debug/barcodes" + tbUserId.Text + ".png";
                barcodeimage.Save(filename);
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += PrintPage;
                pd.Print();
                Process.Start(filename);
                // Process.Start(@filename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #13
0
        public void TestRenderError()
        {
            BarCodeGenerator generator    = MakeInvalidGenerator();
            string           errorMessage = null;

            generator.TestRender(out errorMessage);
            Assert.IsNotNull(errorMessage);
        }
コード例 #14
0
        public void TestInvalidImage()
        {
            BarCodeGenerator generator = MakeInvalidGenerator();

            Assert.Throws <BarCodeFormatException>(() => {
                using (generator.GenerateImage()) { }
            });
        }
コード例 #15
0
        public void GuardaCodigoBarras()
        {
            string rutaYNomArchivo = _rutaXml.Trim() + "cbb\\" + _nomArchivo + ".png";

            sMsj = "";
            iErr = 0;
            try
            {
                //Genera y guarda código de barras bidimensional
                BarcodeSettings settings = new BarcodeSettings();
                settings.Pdf417DataMode  = Pdf417DataMode.Byte;
                settings.Pdf417Truncated = false;
                settings.Pdf417ECL       = Pdf417ECL.Level5;
                settings.DpiX            = 100;
                settings.DpiY            = 100;

                settings.ImageHeight = 1;
                settings.ImageWidth  = 3;
                settings.XYRatio     = 3;

                settings.Data2D           = _modeloDte.modeloTed.xDocXml.OuterXml;
                settings.Data             = _modeloDte.modeloTed.xDocXml.OuterXml;
                settings.Type             = (BarCodeType)Enum.Parse(typeof(BarCodeType), "Pdf417");
                settings.ShowText         = false;
                settings.BarHeight        = 15;
                settings.ShowCheckSumChar = true;
                settings.ForeColor        = Color.FromName("Black");

                //generate the barcode use the settings
                BarCodeGenerator generator = new BarCodeGenerator(settings);
                Image            barcode   = generator.GenerateImage();

                //save the barcode as an image
                barcode.Save(rutaYNomArchivo);
            }
            catch (DirectoryNotFoundException)
            {
                sMsj = "Verifique la existencia de la ruta indicada en la configuración de Ruta de archivos Xml. No existe la ruta actual: " + _rutaXml.Trim() + " [CFDComprobanteFiscalDigital.GuardaCodigoBarras]";
                iErr++;
            }
            catch (IOException)
            {
                sMsj = "Verifique permisos de escritura en: " + _rutaXml.Trim() + ". No se pudo guardar el código de barras. [CFDComprobanteFiscalDigital.GuardaCodigoBarras]";
                iErr++;
            }
            catch (Exception eAFE)
            {
                if (eAFE.Message.Contains("denied"))
                {
                    sMsj = "Elimine el archivo xml, luego vuelva a intentar. " + eAFE.Message + " [CFDComprobanteFiscalDigital.GuardaCodigoBarras]";
                }
                else
                {
                    sMsj = "No se puede guardar el código de barras. " + eAFE.Message + " [CFDComprobanteFiscalDigital.GuardaCodigoBarras] " + eAFE.StackTrace;
                }
                iErr++;
            }
        }
コード例 #16
0
        public FrayteResult CreateWarehouseLocation(string LocationName, string countryCode)
        {
            FrayteResult result = new FrayteResult();

            Location location = new Location();

            location.WarehouseId  = 1;
            location.LocationName = LocationName;
            location.CountryId    = 228;
            dbContext.Locations.Add(location);
            dbContext.SaveChanges();

            location.Barcode = CommonConversion.GetNewFrayteNumber() + "|" + countryCode + "|" + location.LocationId;
            dbContext.SaveChanges();

            BarcodeSettings settings = new BarcodeSettings();
            string          data     = location.Barcode;
            string          type     = "Code128";
            short           fontSize = 8;
            string          font     = "SimSun";

            settings.Data2D = data;
            settings.Data   = data;
            settings.Type   = (BarCodeType)Enum.Parse(typeof(BarCodeType), type);

            if (fontSize != 0 && fontSize.ToString().Length > 0 && Int16.TryParse(fontSize.ToString(), out fontSize))
            {
                if (font != null && font.Length > 0)
                {
                    settings.TextFont = new System.Drawing.Font(font, fontSize, FontStyle.Bold);
                }
            }
            short barHeight = 15;

            if (barHeight != 0 && barHeight.ToString().Length > 0 && Int16.TryParse(barHeight.ToString(), out barHeight))
            {
                settings.BarHeight = barHeight;
            }

            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image            barcode   = generator.GenerateImage();

            // Path where we will have barcode
            string filePathToSave = AppSettings.LabelFolder + "Waerehouse/";

            filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave + location.LocationId);

            if (!System.IO.Directory.Exists(filePathToSave))
            {
                System.IO.Directory.CreateDirectory(filePathToSave);
            }
            barcode.Save(filePathToSave + "/" + location.LocationName + ".Png");
            result.Status = true;


            return(result);
        }
コード例 #17
0
 public static void ImplementUpcaGs1DatabarCouponForNewBarcode()
 {
     //ExStart: ImplementUpcaGs1DatabarCouponForNewBarcode
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.UpcaGs1DatabarCoupon))
     {
         generator.Save(dataDir + "UpcaGs1DatabarCoupon.png");
     }
     //ExEnd: ImplementUpcaGs1DatabarCouponForNewBarcode
 }
コード例 #18
0
 private void button1_Click(object sender, EventArgs e)
 {
     BarcodeSettings bs = new BarcodeSettings();
     bs.Type = BarCodeType.PZN;
     bs.Data = "12345";
     BarCodeGenerator bg = new BarCodeGenerator(bs);
     bg.GenerateImage().Save("PZNCode.png");
     System.Diagnostics.Process.Start("PZNCode.png");
 }
コード例 #19
0
ファイル: BarCodeControl.cs プロジェクト: tbayart/nbarcodes
        /// <summary>
        /// Creates a new instance of the <see cref="BarCodeControl"/>.
        /// </summary>
        public BarCodeControl()
        {
            _errorFont  = new Font("verdana", 16f, FontStyle.Bold);
            _errorBrush = Brushes.Red;
            _generator  = new BarCodeGenerator(this);

            BackColor = Defaults.BackColor;
            Font      = Defaults.Font;
        }
コード例 #20
0
 public static void GroupingPropertiesByBarcodeType()
 {
     //ExStart: GroupingPropertiesByBarcodeType
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.QR))
     {
         generator.QR.Version    = QRVersion.Version18;
         generator.QR.ErrorLevel = QRErrorLevel.LevelM;
         generator.Save(dataDir + "qr_out.png");
     }
     //ExEnd: GroupingPropertiesByBarcodeType
 }
コード例 #21
0
 public static void ImplementDotCodeForBarcode()
 {
     //ExStart: ImplementDotCodeForBarcode
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.DotCode))
     {
         generator.DotCodeMask = 2;
         Bitmap barcode = generator.GenerateBarCodeImage();
         barcode.Save(dataDir + "DotCode.png");
     }
     //ExEnd: ImplementDotCodeForBarcode
 }
コード例 #22
0
        public void TestValidImage()
        {
            BarCodeSettings  settings  = SettingsUtils.CreateTestSettings();
            BarCodeGenerator generator = new BarCodeGenerator(settings);

            using (var image = generator.GenerateImage()) {
                AssertImage(image);
                Assert.AreEqual(settings.Dpi, image.HorizontalResolution);
                Assert.AreEqual(settings.Dpi, image.VerticalResolution);
            }
        }
コード例 #23
0
 public static void GenarateBarcodeWithRotationAndDpi()
 {
     //ExStart: GenarateBarcodeWithRotationAndDpi
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Code128))
     {
         generator.Resolution    = 144;
         generator.RotationAngle = 90;
         generator.Save(dataDir + "rotated_dpi144.png");
     }
     //ExEnd: GenarateBarcodeWithRotationAndDpi
 }
コード例 #24
0
        private void tSBSaveBarcode_Click(object sender, EventArgs e)
        {
            BarCodeGenerator bcg = new BarCodeGenerator(bs);
            SaveFileDialog   sf  = new SaveFileDialog();

            sf.Filter = "Bitmap Image(*.bmp)|*.bmp|JPEG Image(*.jpg)|*.jpg|PNG Image(*.png)|*.png";
            if (sf.ShowDialog() == DialogResult.OK)
            {
                bcg.GenerateImage().Save(sf.FileName);
            }
        }
コード例 #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            BarcodeSettings bs = new BarcodeSettings();

            bs.Type = BarCodeType.RSSExpanded;
            bs.Data = "(12)345678(90)";
            BarCodeGenerator bg = new BarCodeGenerator(bs);

            bg.GenerateImage().Save("RSSExpandedCode.png");
            System.Diagnostics.Process.Start("RSSExpandedCode.png");
        }
コード例 #26
0
        /// <summary>
        /// Asserts the valid generation of a barcode image.
        /// </summary>
        /// <param name="type">The barcode type to render.</param>
        /// <param name="data">The data to render.</param>
        private void AssertBarcode(BarCodeType type, string data)
        {
            BarCodeSettings settings = new BarCodeSettings();

            settings.Type = type;
            settings.Data = data;
            BarCodeGenerator generator = new BarCodeGenerator(settings);

            using (var image = generator.GenerateImage()) {
                AssertImage(image);
            }
        }
コード例 #27
0
 public static void GenerateCode16KBarCode()
 {
     //ExStart: GenerateCode16KBarCode
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Code16K))
     {
         generator.AutoSizeMode           = AutoSizeMode.Nearest;
         generator.BarCodeWidth.Pixels    = 100;
         generator.CodeTextStyle.Location = CodeLocation.None;
         generator.Save(dataDir + "Code16K_Nearest.png");
     }
     //ExEnd: GenerateCode16KBarCode
 }
コード例 #28
0
ファイル: Code.cs プロジェクト: Lautenschlager-id/HeadWars
        // Methods
        /// Constructor
        public Code()
        {
            // Resizes the window
            HeadWars.Resize(320, 300);

            labels.Add(new HLabel(Translation.GetString("secret_code"), Font.WindowTitle));
            labels[0].setPosition(0, 0, "xcenter top");

            // Code
            textboxes.Add(new HTextBox(0, 0, 17, false, 250, 45));
            textboxes[0].setFont(Font.MediumTextBold);
            textboxes[0].setPosition(0, 40, "xcenter ycenter");

            buttons.Add(new HButton(Translation.GetString("validate"), 0, 0));
            buttons[0].setPosition(0, 90, "xcenter ycenter");

            labels.Add(new HLabel(message = "", Font.Text));
            labels[1].setPosition(0, 140, "xcenter");

            buttons.Add(new HButton(Translation.GetString("button_back"), 0, 0));
            buttons[1].setPosition(0, 0, "left bottom");

            // QR Code
            DatabaseManager.Connect();
            string data = DatabaseManager.getCode();

            DatabaseManager.Disconnect();

            if (data == null)
            {
                QRCodeTexture = Graphic.no_code;
            }
            else
            {
                BarcodeSettings settings = new BarcodeSettings
                {
                    Unit           = GraphicsUnit.Pixel,
                    Type           = BarCodeType.QRCode,
                    ResolutionType = ResolutionType.UseDpi,
                    BackColor      = System.Drawing.Color.White,
                    ForeColor      = System.Drawing.Color.Black,
                    X    = 4,
                    Data = data,
                    DpiY = 1,
                    DpiX = 1
                };

                BarCodeGenerator generator = new BarCodeGenerator(settings);
                QRCodeTexture = bitmapToTexture2D((Bitmap)generator.GenerateImage());
            }
            QrCodeRectangle = new Microsoft.Xna.Framework.Rectangle(0, 0, QRCodeTexture.Width, QRCodeTexture.Height);
        }
コード例 #29
0
 public static void GetGeneratedBarcodeSize()
 {
     //ExStart: GetGeneratedBarcodeSize
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.QR, "Aspose.BarCode sample"))
     {
         generator.XDimension.Pixels = 3;
         generator.D2.AspectRatio    = 1.5f;
         generator.RecalculateValues();
         Console.WriteLine("Width = " + generator.BarCodeWidth.Pixels);
         Console.WriteLine("Height = " + generator.BarCodeWidth.Pixels);
     }
     //ExEnd: GetGeneratedBarcodeSize
 }
コード例 #30
0
 public static void GenerateBarcodeWithoutRestrictedBarcodeSize()
 {
     //ExStart: GenerateBarcodeWithoutRestrictedBarcodeSize
     // if you  don't have required size, you can use AutoSizeMode = None and set all generator parameters by yourself
     using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.QR, "Aspose.BarCode sample"))
     {
         generator.XDimension.Pixels    = 3;
         generator.Margins.Left.Pixels  = 20;
         generator.Margins.Right.Pixels = 20;
         generator.Save(dataDir + "GenerateBarcodeWithoutRestrictedBarcodeSize_out.png");
     }
     //ExEnd: GenerateBarcodeWithoutRestrictedBarcodeSize
 }
コード例 #31
0
 public static Image Generate(string strcontent)
 {
      BarcodeSettings settings=new BarcodeSettings();
      settings.BarHeight = 15;
      settings.Data = strcontent;
      settings.Data2D = strcontent;
      settings.Type = BarCodeType.Pdf417;
      settings.X =6;
      settings.ShowText = false;
      settings.ShowTextOnBottom = false;
      settings.ShowCheckSumChar = false;
     BarCodeGenerator generator = new BarCodeGenerator(settings);
     Image barcode = generator.GenerateImage();
     return barcode;
 }
コード例 #32
0
        public async Task<JsonResult> SaveLists(List<String> id)
        {
            // Deserialize it to a dictionary
            // var dic =  Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<String, dynamic>>(jsonString);
            var result = String.Format("Fist item in list: '{0}'", id[0]);
            var betStake = id[0];
            var userBalance = id[0];
            int games = Convert.ToInt16(id[0]);
            var receipt = new Receipt();
            var bcg = new BarCodeGenerator();
            var betcat = new BetCategory();
            const double ttodd = 1;
            const float bettingLimit = 800000;
            if (Convert.ToDecimal(betStake) >= Convert.ToDecimal(userBalance))
                return Json(new
                {
                    Result = result,
                    RecieptTime = DateTime.Now,
                    RecieptNumber = receipt.ReceiptId
                },
                    JsonRequestBehavior.AllowGet);
            var cost = Convert.ToDouble(betStake);
            if ((cost >= 1000) && (cost <= bettingLimit))//betting limit
            {
                var all = (ArrayList)(Session["Current_bets"]);
                var gameNumbers = new int[games];
                for (var i = 0; i < games; i++)
                {
                    var bet = (string[])all[i];
                    gameNumbers[i] = Convert.ToInt32(bet[0]);
                }
                var receiptid = bcg.GenerateRandomString(7);
                if (receiptid != "")
                {
                }
                for (var i = 0; i < games; i++)
                {
                    var bet = (string[])all[i];
                    var matchno = bet[0];
                    var choice = bet[4];
                    try
                    {
                        //Straight bet
                        if (choice.Equals("H") || choice.Equals("A") || choice.Equals("X"))
                        {
                            choice = bet[4].Equals("H") ? "Home" : (bet[4].Equals("A") ? "Away" : "Draw");
                            betcat.Name = "Straight";
                        }

                            //wire bet
                        else if (choice.Equals("U") || choice.Equals("O"))
                        {
                            choice = bet[4].Equals("U") ? "Under" : "Over";
                            betcat.Name = "wire";
                        }

                            //double chance bet
                        else if (choice.Equals("1X") || choice.Equals("2X") || choice.Equals("12"))
                        {
                            betcat.Name = "dc";
                        }

                            //halftime bet
                        else if (choice.Equals("H1") || choice.Equals("HX") || choice.Equals("H2"))
                        {
                            choice = bet[4].Equals("H1") ? "Home" : (bet[4].Equals("H2") ? "Away" : "Draw");
                            betcat.Name = "halftime";
                        }

                            //handicap bet
                        else if (choice.Equals("HC1") || choice.Equals("HCX") || choice.Equals("HC2"))
                        {
                            choice = bet[4].Equals("HC1") ? "Home" : (bet[4].Equals("HC2") ? "Away" : "Draw");
                            betcat.Name = "hc";
                        }
                            //wire bet
                        else if (choice.Equals("OD") || choice.Equals("EV"))
                        {
                            choice = bet[4].Equals("OD") ? "Odd" : "Even";
                            betcat.Name = "oddeven";
                        }
                        var bm = new Bet
                        {
                            MatchId = Convert.ToInt32(matchno),
                            RecieptId = Convert.ToInt32(receiptid)
                            //bm.odd = 3;
                            //bm.betcategory = 1;
                            //bm.matchstatus = "";
                        };
                            
                    }
                    catch (Exception er)
                    {
                        var msg = er.Message;
                    }

                }
                receipt.ReceiptDate = DateTime.Now;
                receipt.TotalOdds = Convert.ToDouble(ttodd);
                receipt.ReceiptStatus = 1;
                //receipt.submitedsize = 0;
                //receipt.wonsize = 0;
                //receipt.setsize = games;
                receipt.Stake = cost;
                receipt.UserId = Session["username"].ToString();
                BetDatabase.Receipts.Add(receipt);
                var account = await BetDatabase.Accounts.SingleOrDefaultAsync(x => x.UserId == receipt.UserId);
                account.AmountE += receipt.Stake;
                account.DateE = DateTime.Now;
                BetDatabase.Accounts.AddOrUpdate(account);
                BetDatabase.SaveChanges();
            }
            else if (cost < 1000)
            {
            }
            return Json(new 
                { 
                    Result = result,
                    RecieptTime=DateTime.Now,
                    RecieptNumber=receipt.ReceiptId 
                },
                JsonRequestBehavior.AllowGet);
        }
コード例 #33
0
ファイル: BoxesController.cs プロジェクト: ealparslan/SSM
        private byte[] getBarcodeImage(string barcode, string title)
        {
            byte[] retval = null;

            try
            {
                BarcodeSettings settings = new BarcodeSettings();

                settings.Type = (BarCodeType)Enum.Parse(typeof(BarCodeType), "Code128");
                settings.Data = barcode;
                settings.HasBorder = false;
                settings.TextFont = new System.Drawing.Font("SimSun", 8, FontStyle.Bold);
                settings.BarHeight = 15;
                settings.ShowText = true;
                settings.ShowCheckSumChar = false;
                settings.ForeColor = Color.FromName("Black");
                BarCodeGenerator generator = new BarCodeGenerator(settings);
                Image barcodeImg = generator.GenerateImage();
                using (var ms = new MemoryStream())
                {
                    barcodeImg.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                    retval = ms.ToArray();
                }
            }
            catch (Exception e)
            {

                throw;
            }

            return retval;

            //try
            //{
            //    BarCode39 _barcode = new BarCode39();
            //    int barSize = 128;
            //    string fontFile = System.Web.HttpContext.Current.Server.MapPath("~/fonts/FREE3OF9.TTF");
            //    return (_barcode.Code39(barcode, barSize, true, title, fontFile));
            //}
            //catch (Exception ex)
            //{
            //    //ErrorLog.WriteErrorLog("Barcode", ex.ToString(), ex.Message);
            //}
        }