Example #1
0
        public void BarcodeContainsCorrectElementCommand(BarcodeType type, string cmd)
        {
            var sut = new BarcodeElement()
            {
                BarcodeType = type
            };

            Assert.Contains(cmd, sut.ToString());
        }
Example #2
0
        /// <summary>
        /// Creates barcode view model from barcode model element
        /// </summary>
        /// <param name="barcode">Barcode model</param>
        /// <param name="templateViewModel">Parent template</param>
        /// <returns>Created barcode view model</returns>
        private static BarcodeViewModel CreateBarcodeViewModel(BarcodeElement barcode, TemplateViewModel templateViewModel)
        {
            BarcodeViewModel barcodeViewModel = new BarcodeViewModel(
                barcode.Name,
                new Rect(barcode.Left, barcode.Top, barcode.Width, barcode.Height),
                templateViewModel);

            barcodeViewModel.SelectedBarcodeType = barcode.BarcodeType;
            barcodeViewModel.QrVersion           = barcode.QrVersion;
            return(barcodeViewModel);
        }
Example #3
0
        /// <summary>
        /// Creates Barcode element from BarcodeViewModel and adds to the OmrPage
        /// </summary>
        /// <param name="page">Page to add element to</param>
        /// <param name="barcodeViewModel">ViewModel to take data from</param>
        private static void AddBarcodeElement(OmrPage page, BarcodeViewModel barcodeViewModel)
        {
            BarcodeElement barcode = page.AddBarcodeElement(
                barcodeViewModel.Name,
                (int)barcodeViewModel.Width,
                (int)barcodeViewModel.Height,
                (int)barcodeViewModel.Top,
                (int)barcodeViewModel.Left);

            barcode.BarcodeType = barcodeViewModel.SelectedBarcodeType;
            barcode.QrVersion   = barcodeViewModel.QrVersion;
        }
        public static void Run()
        {
            try
            {
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_OCR();

                // Load template file
                OmrTemplate template = OmrTemplate.Load(dataDir + "sample_1.amr");

                // Load the image to be analyzed
                OmrImage image = OmrImage.Load(dataDir + "sample1.jpg");

                // do not forget to set the license for BarCode in case BarCode elements are used
                //Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License();
                //licenseBarCode.SetLicense(dataDir + "Aspose.Total.lic");
                 
                //// do not forget to set the license for BarCode in case BarCode elements are used
                //var licenseOmr = new Aspose.OCR.License();
                //licenseOmr.SetLicense(dataDir + "Aspose.Total.lic");

                // Adding BarCode element requires creation of BarcodeElement object
                // While specifying the barcode display name, its position and size
                BarcodeElement barcodeElement = new BarcodeElement("Aztec BarCode", new PointF(0, 0), new SizeF(205, 205));
                // Add the BarCode element to the page element collection
                template.Pages[0].Elements.Add(barcodeElement);

                // Create an instance of OmrEngine and load the template using file path
                OmrEngine engine = new OmrEngine(template);
                // Extract OMR data and store the results in an instance of OmrProcessingResults
                OmrProcessingResult result = engine.ExtractData(new[] { image });
                // Get all page data into an instance of Hashtable
                Hashtable[] pages = result.PageData;
                // Loop over all the pages
                foreach (Hashtable page in pages)
                {
                    // Display key and value
                    foreach (string key in page.Keys)
                    {
                        Console.WriteLine("key: " + key + ": " + "value: " + page[key]);
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                // Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
        public static void Run()
        {
            try
            {
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_OCR();

                // Load template file
                OmrTemplate template = OmrTemplate.Load(dataDir + "sample_1.amr");

                // Load the image to be analyzed
                OmrImage image = OmrImage.Load(dataDir + "sample1.jpg");

                // do not forget to set the license for BarCode in case BarCode elements are used
                //Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License();
                //licenseBarCode.SetLicense(dataDir + "Aspose.Total.lic");

                //// do not forget to set the license for BarCode in case BarCode elements are used
                //var licenseOmr = new Aspose.OCR.License();
                //licenseOmr.SetLicense(dataDir + "Aspose.Total.lic");

                // Adding BarCode element requires creation of BarcodeElement object
                // While specifying the barcode display name, its position and size
                BarcodeElement barcodeElement = new BarcodeElement("Aztec BarCode", new PointF(0, 0), new SizeF(205, 205));
                // Add the BarCode element to the page element collection
                template.Pages[0].Elements.Add(barcodeElement);

                // Create an instance of OmrEngine and load the template using file path
                OmrEngine engine = new OmrEngine(template);
                // Extract OMR data and store the results in an instance of OmrProcessingResults
                OmrProcessingResult result = engine.ExtractData(new[] { image });
                // Get all page data into an instance of Hashtable
                Hashtable[] pages = result.PageData;
                // Loop over all the pages
                foreach (Hashtable page in pages)
                {
                    // Display key and value
                    foreach (string key in page.Keys)
                    {
                        Console.WriteLine("key: " + key + ": " + "value: " + page[key]);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                // Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
Example #6
0
        public void BarcodeIsCreatedWithDefaults()
        {
            var sut = new BarcodeElement();

            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.BarcodeOrientation, sut.BarcodeOrientation);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.FieldHeight, sut.FieldHeight);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.ModuleWidth, sut.ModuleWidth);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.PrintInterpretationLine, sut.PrintInterpretationLine);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.PrintInterpretationLineAboveCode, sut.PrintInterpretationLineAboveCode);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.BarcodeType, sut.BarcodeType);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.UCCCheckDigit, sut.UCCCheckDigit);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.WideBarToNarrowBar, sut.WideBarToNarrowBar);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.PrintCheckDigit, sut.PrintCheckDigit);
            Assert.Equal(ZPLForgeDefaults.Elements.Barcode.Mod43CheckDigit, sut.Mod43CheckDigit);
        }
 public LabelBuilder AddBarcode(BarcodeElement barcode)
 {
     Context.Content.Add(barcode ?? throw new ArgumentNullException(nameof(barcode)));
     return(this);
 }
Example #8
0
        public void BarcodeHasFieldOrigin()
        {
            var sut = new BarcodeElement();

            Assert.Contains("^FO", sut.ToString());
        }
Example #9
0
        public void BarcodeHasFieldSeperator()
        {
            var sut = new BarcodeElement();

            Assert.Contains("^FS", sut.ToString());
        }
Example #10
0
        public void BarcodeIsLabelContentElement()
        {
            var sut = new BarcodeElement();

            Assert.IsAssignableFrom <LabelContent>(sut);
        }