Esempio n. 1
0
        private void _btnFinishCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (_rdFromDisk.Checked)
                {
                    using (RasterCodecs codecs = new RasterCodecs())
                    {
                        codecs.Options.Load.Resolution = 300;
                        codecs.Options.RasterizeDocument.Load.Resolution = 300;
                        scannedImage = codecs.Load(_txtPagePath.Text);
                    }
                }

                if (scannedImage == null)
                {
                    MessageBox.Show("Please add a valid image");
                    return;
                }

                FormsPageType pageType = FormsPageType.Normal;

                if (_rbNormal.Checked)
                {
                    pageType = FormsPageType.Normal;
                }
                else if (_rbIDCard.Checked)
                {
                    pageType = FormsPageType.IDCard;
                }
                else if (_rbOmr.Checked)
                {
                    pageType = FormsPageType.Omr;
                }

                MainForm frm = new MainForm(scannedImage.CloneAll(), _txtMasterFormsName.Text, _txtMasterFormsDirectory.Text, pageType);
                scannedImage.Dispose();
                scannedImage = null;
                this.Hide();
                frm.Show();
            }
            catch (Exception exp)
            {
                Messager.ShowError(this, exp);
            }
        }
Esempio n. 2
0
        private void AddMasterFormPages(RasterImage imagesToAdd, DiskMasterForm currentform, string folderName)
        {
            try
            {
                DiskMasterForm            currentMasterForm = currentform;
                FormRecognitionAttributes attributes        = currentMasterForm.ReadAttributes();
                FormPages   formPages = currentMasterForm.ReadFields();
                RasterImage formImage = currentMasterForm.ReadForm();

                for (int i = 0; i < imagesToAdd.PageCount; i++)
                {
                    //Add each new page to the masterform by creating attributes for each page
                    imagesToAdd.Page = i + 1;
                    AddPageToMasterForm(imagesToAdd.Clone(), attributes, -1, null);
                }

                //Add image
                if (formImage != null)
                {
                    formImage.AddPages(imagesToAdd.CloneAll(), 1, imagesToAdd.PageCount);
                }
                else
                {
                    formImage = imagesToAdd.CloneAll();
                }

                //Only add processing pages for the new pages
                if (formPages != null)
                {
                    for (int i = 0; i < imagesToAdd.PageCount; i++)
                    {
                        formPages.Add(new FormPage(formPages.Count + 1, imagesToAdd.XResolution, imagesToAdd.YResolution));
                    }
                }
                else
                {
                    //No processing pages exist so we must create them
                    FormRecognitionEngine recognitionEngine    = SetupRecognitionEngine();
                    FormProcessingEngine  tempProcessingEngine = new FormProcessingEngine();
                    tempProcessingEngine.OcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);
                    //tempProcessingEngine.BarcodeEngine = barcodeEngine;

                    for (int i = 0; i < recognitionEngine.GetFormProperties(attributes).Pages; i++)
                    {
                        tempProcessingEngine.Pages.Add(new FormPage(i + 1, imagesToAdd.XResolution, imagesToAdd.YResolution));
                    }

                    formPages = tempProcessingEngine.Pages;
                }

                //FormField newField = null;
                //AnnHiliteObject newObject = new AnnHiliteObject();
                //newField = new TextFormField();
                //newField.Name = "test";
                //newField.Bounds = new LogicalRectangle(50, 50, 50, 50, LogicalUnit.Pixel);

                //FormField newField1 = null;
                //AnnHiliteObject newObject1 = new AnnHiliteObject();
                //newField1 = new OmrFormField();
                //newField1.Name = "test1";
                //newField1.Bounds = new LogicalRectangle(50, 50, 50, 50, LogicalUnit.Pixel);

                //newObject.Tag = newField;
                //newObject1.Tag = newField1;
                //FormField currentField = newObject.Tag as FormField;
                //FormField currentField1 = newObject1.Tag as FormField;

                //formPages[0].Add(currentField);
                //formPages[0].Add(currentField1);

                currentMasterForm.WriteForm(formImage);
                currentMasterForm.WriteAttributes(attributes);
                currentMasterForm.WriteFields(formPages);
                DBHelper.UpdateTifPageCount(formImage.PageCount.ToString(), folderName);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 3
0
        private void ViewerForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Color drawColor;

            if (_viewer.Image != null)
            {
                if (_viewer.Image.Width >= 150 && _viewer.Image.Height >= 150)
                {
                    _viewer.Image = _tempImage.CloneAll();

                    using (RasterImageGdiPlusGraphicsContainer container = new RasterImageGdiPlusGraphicsContainer(_viewer.Image))
                    {
                        // Create string to draw.
                        String drawString = "";


                        if (StandardOptions.Added)
                        {
                            drawString += " Status : ADDED\n";
                            drawString += " Index: ";
                            drawString += StandardOptions.PageNumber;
                            if (!StandardOptions.NOMRC)
                            {
                                drawString += "\n";
                                drawString += " Input Quality: ";

                                switch (StandardOptions.InputImageComboSel)
                                {
                                case 0:
                                    drawString += "Auto";
                                    break;

                                case 1:
                                    drawString += "Noisy";
                                    break;

                                case 2:
                                    drawString += "Scanned";
                                    break;

                                case 3:
                                    drawString += "Printed";
                                    break;

                                case 4:
                                    drawString += "Computer Generated";
                                    break;

                                case 5:
                                    drawString += "Photo";
                                    break;

                                case 6:
                                    drawString += "User Defined";
                                    break;
                                }

                                drawString += "\n Output Quality : ";
                                switch (StandardOptions.OutputImageComboSel)
                                {
                                case 0:
                                    drawString += "Auto";
                                    break;

                                case 1:
                                    drawString += "Poor";
                                    break;

                                case 2:
                                    drawString += "Average";
                                    break;

                                case 3:
                                    drawString += "Good";
                                    break;

                                case 4:
                                    drawString += "Excellent";
                                    break;

                                case 5:
                                    drawString += "User Defined";
                                    break;
                                }
                            }
                            drawColor = Color.Green;
                        }
                        else
                        {
                            drawString += " Status : NOT ADDED";
                            drawColor   = Color.Red;
                        }

                        // Create font and brush.
                        int fontSize = 12;
                        LinearGradientBrush gradientBrush;
                        Font       drawFont  = new Font("Arial", fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
                        SolidBrush drawBrush = new SolidBrush(Color.Black);

                        // Set format of string.
                        SizeF size = container.Graphics.MeasureString(drawString, drawFont);
                        Pen   pen  = new Pen(drawColor, 0);
                        container.Graphics.DrawRectangle(pen, 0, 0, _viewer.Image.Width, size.Height);

                        _drawRect = new RectangleF(0, 0, _viewer.Image.Width, size.Height);

                        StringFormat drawFormat = new StringFormat();
                        drawFormat.Alignment = StringAlignment.Center;
                        gradientBrush        = new LinearGradientBrush(_drawRect, drawColor, Color.White, LinearGradientMode.ForwardDiagonal);

                        container.Graphics.FillRectangle(gradientBrush, _drawRect);

                        container.Graphics.DrawString(drawString, drawFont, drawBrush, _drawRect);//,drawFormat);
                    }
                }
            }
        }