private static void ApplyErrorCorrection(BarcodeQR barcode, dynamic errorCorrection)
        {
            string errorCorrectionString;

            ConvertHelper.TryToNormString(errorCorrection, out errorCorrectionString);

            switch (errorCorrectionString)
            {
            case "low":
                barcode.ErrorCorrection = QRCodeErrorCorrection.L;
                break;

            case "medium":
                barcode.ErrorCorrection = QRCodeErrorCorrection.M;
                break;

            case "quartile":
                barcode.ErrorCorrection = QRCodeErrorCorrection.Q;
                break;

            case "high":
                barcode.ErrorCorrection = QRCodeErrorCorrection.H;
                break;

            default:
                barcode.ErrorCorrection = QRCodeErrorCorrection.L;
                break;
            }
        }
        protected override BarcodeBase CreateBarcode(dynamic elementMetadata)
        {
            var barcode = new BarcodeQR();

            ApplyErrorCorrection(barcode, elementMetadata.ErrorCorrection);

            return(barcode);
        }
Exemplo n.º 3
0
        private void mnuQRCode_Click(object sender, EventArgs e)
        {
            var text = new BarcodeQR("SIRIUS");
            var form = new PropertyForm(text);

            if (DialogResult.OK != form.ShowDialog(this))
            {
                return;
            }
            this.Document.Action.ActEntityAdd(text);
        }
Exemplo n.º 4
0
        static void BarcodeData()
        {
            var qr = new BarcodeQR()
            {
                IsFixedAspectRatio = false,
                Width         = 5,
                Height        = 5,
                Align         = Alignment.LeftBottom,
                Location      = new System.Numerics.Vector2(0, 0),
                ShapeType     = BarcodeShapeType.Hatch,
                HatchInterval = 0.2f,
                HatchAngle    = 90,
            };

            qr.Data = "HELLO SPIRALLAB SIRIUS LIBRARY";
            qr.Regen();

            string lineOfCodes = @"
            using System; 
            namespace Test 
            {
                class MyClass
                {
                    public string BarcodeData
                    { 
                        get
                        {
                            return string.Format(""{0}-{1}-{2}"", this.Year, this.Month, this.Day);
                        }
                    }
                    public string Year { get; set; }
                    public string Month { get; set; }
                    public string Day { get; set; }
                }
            }";

            qr.ScriptInstanceName = "Test.MyClass";
            qr.ScriptPropertyName = "BarcodeData";
            qr.ScriptArguments    = new string[]
            {
                "Year=2021",
                "Month=08",
                "Day=31",
            };

            if (qr.ScriptCompile(lineOfCodes, out var errors))
            {
                Console.WriteLine("No error(s)");
            }
            else
            {
                foreach (var err in errors)
                {
                    Console.WriteLine(err.ToString());
                }
                Console.ReadKey();
                return;
            }
            qr.ScriptExecute(out var executeResult, true);
            var qrData = qr.TextData;

            Debug.Assert(0 == string.Compare(executeResult, qrData));
            Console.WriteLine($"Barcode entity has changed to {executeResult}");
        }