Beispiel #1
0
        // USE CASE: Using collection events
        public static void Using_collection_events(IEngine engine)
        {
            // Collection events are mainly intended for use in creating UI views for FlexiCapture Engine objects.
            // By listening to collection events listeners can duly react to changes in the model.

            trace("Open the project...");
            IProject project = engine.OpenProject(SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj");

            // Start listening to project.Batches events. In a real-life usage scenario the listener
            // would be some kind of a visual control, showing the list of batches and redrawing
            // itself when the collection changes
            SampleCollectionEventsSink batchesEvents = new SampleCollectionEventsSink(project.Batches, "project.Batches");

            try {
                trace("Add a new batch...");
                IBatch batch = project.Batches.AddNew("TestBatch");

                trace("Open the new batch...");
                batch.Open();

                // Start listening to batch.Documents events. In a real-life usage scenario the listener
                // would be some kind of a visual control, showing the list of documents and redrawing
                // itself when the collection changes
                SampleCollectionEventsSink documentsEvents = new SampleCollectionEventsSink(batch.Documents, "batch.Documents");

                try {
                    trace("Add the image files to the batch...");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_1.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_2.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_3.tif");

                    trace("Recognize the batch...");
                    batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null);

                    trace("Export the results...");
                    batch.Export(null, null);

                    trace("Close and delete the batch...");
                } finally {
                    documentsEvents.Dispose();
                    batch.Close();
                    project.Batches.DeleteAll();
                }

                trace("Close the project...");
            } finally {
                batchesEvents.Dispose();
                project.Close();
            }
        }
        // USE CASE: Using collection events
        public static void Using_collection_events( IEngine engine )
        {
            // Collection events are mainly intended for use in creating UI views for FlexiCapture Engine objects.
            // By listening to collection events listeners can duly react to changes in the model.

            trace( "Open the project..." );
            IProject project = engine.OpenProject( SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj" );

            // Start listening to project.Batches events. In a real-life usage scenario the listener
            // would be some kind of a visual control, showing the list of batches and redrawing
            // itself when the collection changes
            SampleCollectionEventsSink batchesEvents = new SampleCollectionEventsSink( project.Batches, "project.Batches" );

            try {
                trace( "Add a new batch..." );
                IBatch batch = project.Batches.AddNew( "TestBatch" );

                trace( "Open the new batch..." );
                batch.Open();

                // Start listening to batch.Documents events. In a real-life usage scenario the listener
                // would be some kind of a visual control, showing the list of documents and redrawing
                // itself when the collection changes
                SampleCollectionEventsSink documentsEvents = new SampleCollectionEventsSink( batch.Documents, "batch.Documents" );

                try {
                    trace( "Add the image files to the batch..." );
                    batch.AddImage( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );
                    batch.AddImage( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
                    batch.AddImage( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );

                    trace( "Recognize the batch..." );
                    batch.Recognize( null, RecognitionModeEnum.RM_ReRecognizeMinimal, null );

                    trace( "Export the results..." );
                    batch.Export( null, null );

                    trace( "Close and delete the batch..." );
                } finally {
                    documentsEvents.Dispose();
                    batch.Close();
                    project.Batches.DeleteAll();
                }

                trace( "Close the project..." );
            } finally {
                batchesEvents.Dispose();
                project.Close();
            }
        }