예제 #1
0
        private void btnEncodeOptions_Click(object sender, EventArgs e)
        {
            if (cmbEncoderType.SelectedItem == null)
            {
                MessageBox.Show(this, "Please select a barcode format first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                EncodingOptions options;
                switch ((BarcodeFormat)cmbEncoderType.SelectedItem)
                {
                case BarcodeFormat.QR_CODE:
                    options = new ZXing.QrCode.QrCodeEncodingOptions
                    {
                        Height = picEncodedBarCode.Height,
                        Width  = picEncodedBarCode.Width
                    };
                    break;

                case BarcodeFormat.PDF_417:
                    options = new ZXing.PDF417.PDF417EncodingOptions
                    {
                        Height = picEncodedBarCode.Height,
                        Width  = picEncodedBarCode.Width
                    };
                    break;

                case BarcodeFormat.DATA_MATRIX:
                    options = new ZXing.Datamatrix.DatamatrixEncodingOptions
                    {
                        Height      = picEncodedBarCode.Height,
                        Width       = picEncodedBarCode.Width,
                        SymbolShape = ZXing.Datamatrix.Encoder.SymbolShapeHint.FORCE_SQUARE,
                        MinSize     = new Dimension(picEncodedBarCode.Width, picEncodedBarCode.Height)
                    };
                    break;

                default:
                    options = new EncodingOptions
                    {
                        Height = picEncodedBarCode.Height,
                        Width  = picEncodedBarCode.Width
                    };
                    break;
                }
                var dlg = new EncodingOptionsForm
                {
                    Options = options
                };
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    EncodingOptions = dlg.Options;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(this, exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private EncodingOptions GetEncodeOptions()
        {
            if (this.cmbEncoderType.SelectedItem == null)
            {
                return(new EncodingOptions());
            }
            BarcodeFormat format = (BarcodeFormat)this.cmbEncoderType.SelectedValue;

            EncodingOptions options;

            switch (format)
            {
            case BarcodeFormat.QR_CODE:
                options = new ZXing.QrCode.QrCodeEncodingOptions()
                {
                    CharacterSet = "UTF-8"
                };

                break;

            case BarcodeFormat.PDF_417:
                options = new ZXing.PDF417.PDF417EncodingOptions()
                {
                    CharacterSet = "UTF-8"
                };
                break;

            case BarcodeFormat.DATA_MATRIX:
                options = new ZXing.Datamatrix.DatamatrixEncodingOptions
                {
                    SymbolShape = ZXing.Datamatrix.Encoder.SymbolShapeHint.FORCE_SQUARE
                };
                break;

            case BarcodeFormat.AZTEC:
                options = new ZXing.Aztec.AztecEncodingOptions();
                break;

            case BarcodeFormat.CODE_128:
                options = new ZXing.OneD.Code128EncodingOptions();
                break;

            default:
                options = new EncodingOptions();
                break;
            }
            if (this.CurrentBarcode != null)
            {
                options.Width  = this.CurrentBarcode.Rect.Width;
                options.Height = this.CurrentBarcode.Rect.Height;
            }
            return(options);
        }
예제 #3
0
 private void btnEncodeOptions_Click(object sender, EventArgs e)
 {
    if (cmbEncoderType.SelectedItem == null)
    {
       MessageBox.Show(this, "Please select a barcode format first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
       return;
    }
    try
    {
       EncodingOptions options;
       switch ((BarcodeFormat)cmbEncoderType.SelectedItem)
       {
          case BarcodeFormat.QR_CODE:
             options = new ZXing.QrCode.QrCodeEncodingOptions
                        {
                           Height = picEncodedBarCode.Height,
                           Width = picEncodedBarCode.Width
                        };
             break;
          case BarcodeFormat.PDF_417:
             options = new ZXing.PDF417.PDF417EncodingOptions
                        {
                           Height = picEncodedBarCode.Height,
                           Width = picEncodedBarCode.Width
                        };
             break;
          case BarcodeFormat.DATA_MATRIX:
             options = new ZXing.Datamatrix.DatamatrixEncodingOptions
             {
                Height = picEncodedBarCode.Height,
                Width = picEncodedBarCode.Width,
                SymbolShape = ZXing.Datamatrix.Encoder.SymbolShapeHint.FORCE_SQUARE,
                MinSize = new Dimension(picEncodedBarCode.Width, picEncodedBarCode.Height)
             };
             break;
          default:
             options = new EncodingOptions
                        {
                           Height = picEncodedBarCode.Height,
                           Width = picEncodedBarCode.Width
                        };
             break;
       }
       var dlg = new EncodingOptionsForm
                    {
                       Options = options
                    };
       if (dlg.ShowDialog(this) == DialogResult.OK)
       {
          EncodingOptions = dlg.Options;
       }
    }
    catch (Exception exc)
    {
       MessageBox.Show(this, exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
 }