Example #1
0
        public BarcodeFieldDialog(BarcodeField ff, RasterImage image) : this()
        {
            bcff       = ff;
            this.image = image;
            BarcodeEngine eng = new BarcodeEngine();

            BarcodeSymbology[] symbologies = (BarcodeSymbology[])Enum.GetValues(typeof(BarcodeSymbology));

            cboxSymbology.DisplayMember = "FriendlyName";
            cboxSymbology.ValueMember   = "ActualSymbology";

            for (int i = 0; i < symbologies.Length; i++)
            {
                string symbology = "Unknown";
                try
                {
                    symbology = BarcodeEngine.GetSymbologyFriendlyName(symbologies[i]);
                }
                catch (Exception)
                {
                    symbology = Enum.GetName(typeof(BarcodeSymbology), symbologies[i]);
                }

                BarcodeFriendlySymbology bfs = new BarcodeFriendlySymbology(symbologies[i], symbology);

                cboxSymbology.Items.Add(bfs);

                if (bfs.ActualSymbology == bcff.Symbology)
                {
                    cboxSymbology.SelectedItem = bfs;
                }
            }

            txtName.Text = bcff.Name;
            if (cboxSymbology.SelectedItem == null)
            {
                cboxSymbology.SelectedIndex = 0;
            }
        }
Example #2
0
        private bool DoZoneSetup(DataGridViewCell cell, bool stayOnPage)
        {
            bool zoneIsOnCurrentPage = DoPageSetup(cell, stayOnPage);

            UpdateNavigationEnables();

            if (!zoneIsOnCurrentPage)
            {
                return(false);
            }

            object ff = cell.Tag;

            if (annotationField != null)
            {
                annotationField.IsVisible = true;
            }

            dgv.CurrentCell = cell;

            string header = cell.OwningColumn.HeaderText;

            this.Text = "Review: " + header;

            LeadRect bounds       = LeadRect.Empty;
            LeadRect answerBounds = LeadRect.Empty;
            string   color        = "Green";

            if (ff is OmrCollection)
            {
                OmrCollection sff = (OmrCollection)ff;

                RasterImage target = GetCroppedImage(masterSheet, sff.Bounds);

                sfp.Visible = true;
                trp.Visible = false;
                sfp.Populate(sff, target, cell);
                bounds = sff.Bounds;
                color  = "Green";

                ReviewParameters       rp = sff.Tag as ReviewParameters;
                VerificationParameters p  = rp.ErroredParameters;
                p.IsReviewed         = true;
                p.UseValueChanged    = sff.Value != sff.OriginalValue;
                rp.ErroredParameters = p;
            }
            else if (ff is OmrField)
            {
                OmrField       omr = (OmrField)ff;
                OmrFieldResult ofr = (OmrFieldResult)omr.Result;

                RasterImage target = GetCroppedImage(masterSheet, omr.Bounds);

                sfp.Visible = false;
                trp.Visible = true;

                trp.Populate(target, cell, ofr.Text);
                bounds = omr.Bounds;
                color  = "Green";
            }
            else if (ff is BarcodeField)
            {
                BarcodeField       bcf  = (BarcodeField)ff;
                BarcodeFieldResult bcfr = (BarcodeFieldResult)bcf.Result;

                RasterImage target = GetCroppedImage(masterSheet, bcf.Bounds);

                sfp.Visible = false;
                trp.Visible = true;

                string value = "";

                if (bcfr != null && bcfr.BarcodeData != null && bcfr.BarcodeData.Count > 0)
                {
                    value = bcfr.BarcodeData[0].Value;
                }

                trp.Populate(target, cell, value);
                bounds = bcf.Bounds;
                color  = "Blue";
            }
            else if (ff is OcrField)
            {
                OcrField       ocf    = (OcrField)ff;
                OcrFieldResult ofr    = (OcrFieldResult)ocf.Result;
                RasterImage    target = GetCroppedImage(masterSheet, ocf.Bounds);

                sfp.Visible = false;
                trp.Visible = true;

                string text       = ofr != null ? ofr.Text : "";
                int    confidence = ofr != null ? ofr.Confidence : -1;

                trp.Populate(target, cell, text, confidence);
                bounds = ocf.Bounds;
                color  = "Red";
            }
            else if (ff is ImageField)
            {
                ImageField       imf  = (ImageField)ff;
                ImageFieldResult imfr = (ImageFieldResult)imf.Result;

                sfp.Visible = false;
                trp.Visible = true;

                if (imfr == null)
                {
                    RasterImage target = GetCroppedImage(masterSheet, imf.Bounds);
                    trp.Populate(target, cell, imf.Name);
                }
                else
                {
                    trp.Populate(imfr.Image, cell, imf.Name);
                }

                bounds = imf.Bounds;
                color  = "Yellow";
            }

            DoAnswerFieldSetup(cell);
            AddHighlight(bounds, color);

            return(true);
        }