VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.VisualTools Namespace / FormFieldTemplateEditorTool Class
Members Example



In This Topic
    FormFieldTemplateEditorTool Class
    In This Topic
    Visual tool that allows to display, edit and interact with form field templates on an image.
    Object Model
    FormFieldTemplateEditorTool ClassIInteractionController InterfaceFormFieldTemplateCollection ClassFormFieldTemplate ClassFormFieldTemplateViewCollection ClassFormFieldTemplateView ClassFormFieldTemplateView ClassImageViewer Class
    Syntax
    'Declaration
     
    Public Class FormFieldTemplateEditorTool 
       Inherits Vintasoft.Imaging.UI.VisualTools.UserInteraction.UserInteractionVisualTool
    public __gc class FormFieldTemplateEditorTool : public Vintasoft.Imaging.UI.VisualTools.UserInteraction.UserInteractionVisualTool 
    public ref class FormFieldTemplateEditorTool : public Vintasoft.Imaging.UI.VisualTools.UserInteraction.UserInteractionVisualTool 
    Example
    This example shows how to create a form template and add some form field templates to the form template visually.
    Class FormFieldTemplateEditorToolForm
        Inherits System.Windows.Forms.Form
        Private imageViewer1 As Vintasoft.Imaging.UI.ImageViewer
        Private buildFieldTemplateButton As System.Windows.Forms.Button
                
        ' ...
                
        ''' <summary>
        ''' Form template manager.
        ''' </summary>
        Private _templateManager As Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager
                
        ''' <summary>
        ''' The template editor tool.
        ''' </summary>
        Private _templateEditorTool As Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.VisualTools.FormFieldTemplateEditorTool
                
        ' ...
                
        Public Sub New()
            ' ...
                
            _templateEditorTool = New Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.VisualTools.FormFieldTemplateEditorTool()
            imageViewer1.VisualTool = _templateEditorTool
                
            AddHandler imageViewer1.FocusedIndexChanged, New System.EventHandler(Of Vintasoft.Imaging.UI.FocusedIndexChangedEventArgs)(AddressOf imageViewer1_FocusedIndexChanged)
                
                
                ' ...
            AddHandler buildFieldTemplateButton.Click, New System.EventHandler(AddressOf buildFieldTemplateButton_Click)
        End Sub
                
        ''' <summary>
        ''' Handles the FocusedIndexChanged event of the imageViewer1
        ''' to change the collection of form field templates of the visual tool.
        ''' </summary>
        ''' <param name="sender">The source of the event.</param>
        ''' <param name="e">The <see cref="Vintasoft.Imaging.UI.FocusedIndexChangedEventArgs"/> instance
        ''' containing the event data.</param>
        Private Sub imageViewer1_FocusedIndexChanged(sender As Object, e As Vintasoft.Imaging.UI.FocusedIndexChangedEventArgs)
            If imageViewer1.Image Is Nothing Then
                _templateEditorTool.FieldTemplateCollection = Nothing
            Else
                ' get the form page template
                Dim pageTemplate As Vintasoft.Imaging.FormsProcessing.FormRecognition.FormPageTemplate = _templateManager.GetPageTemplate(imageViewer1.Image)
                ' set items of page template as current items of the visual tool
                _templateEditorTool.FieldTemplateCollection = pageTemplate.Items
            End If
        End Sub
                
        ' ...
                
        ''' <summary>
        ''' Handles the Click event of the buildFieldTemplateButton
        ''' to create a form field template and start building of it.
        ''' </summary>
        ''' <param name="sender">The source of the event.</param>
        ''' <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        Private Sub buildFieldTemplateButton_Click(sender As Object, e As System.EventArgs)
            ' create an OMR rectangular field template
            Dim fieldTemplate As Vintasoft.Imaging.FormsProcessing.FormRecognition.FormFieldTemplate = New Vintasoft.Imaging.FormsProcessing.FormRecognition.Omr.OmrRectangularFieldTemplate()
            ' create a view for the field template
            Dim fieldTemplateView As Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.FormFieldTemplateView = Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.FormFieldTemplateViewFactory.CreateView(fieldTemplate)
                
            ' add field template to the collection of visual tool and
            ' start building of field template
            _templateEditorTool.AddAndBuild(fieldTemplateView)
        End Sub
                
        ' ...
                
    End Class
    class FormFieldTemplateEditorToolForm : System.Windows.Forms.Form
    {
        Vintasoft.Imaging.UI.ImageViewer imageViewer1;
        System.Windows.Forms.Button buildFieldTemplateButton;
                
        // ...
                
        /// <summary>
        /// Form template manager.
        /// </summary>
        Vintasoft.Imaging.FormsProcessing.FormRecognition.FormTemplateManager _templateManager;
                
        /// <summary>
        /// The template editor tool.
        /// </summary>
        Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.VisualTools.FormFieldTemplateEditorTool _templateEditorTool;
                
        // ...
                
        public FormFieldTemplateEditorToolForm()
        {
            // ...
                
            _templateEditorTool = new Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.VisualTools.FormFieldTemplateEditorTool();
            imageViewer1.VisualTool = _templateEditorTool;
                
            imageViewer1.FocusedIndexChanged += 
                new System.EventHandler<Vintasoft.Imaging.UI.FocusedIndexChangedEventArgs>(imageViewer1_FocusedIndexChanged);
                
            buildFieldTemplateButton.Click += 
                new System.EventHandler(buildFieldTemplateButton_Click);
                
            // ...
        }
                
        /// <summary>
        /// Handles the FocusedIndexChanged event of the imageViewer1
        /// to change the collection of form field templates of the visual tool.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Vintasoft.Imaging.UI.FocusedIndexChangedEventArgs"/> instance
        /// containing the event data.</param>
        private void imageViewer1_FocusedIndexChanged(object sender, Vintasoft.Imaging.UI.FocusedIndexChangedEventArgs e)
        {
            if (imageViewer1.Image == null)
            {
                _templateEditorTool.FieldTemplateCollection = null;
            }
            else
            {
                // get the form page template
                Vintasoft.Imaging.FormsProcessing.FormRecognition.FormPageTemplate pageTemplate = 
                    _templateManager.GetPageTemplate(imageViewer1.Image);
                // set items of page template as current items of the visual tool
                _templateEditorTool.FieldTemplateCollection = pageTemplate.Items;
            }
        }
                
        // ...
                
        /// <summary>
        /// Handles the Click event of the buildFieldTemplateButton
        /// to create a form field template and start building of it.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void buildFieldTemplateButton_Click(object sender, System.EventArgs e)
        {
            // create an OMR rectangular field template
            Vintasoft.Imaging.FormsProcessing.FormRecognition.FormFieldTemplate fieldTemplate = 
                new Vintasoft.Imaging.FormsProcessing.FormRecognition.Omr.OmrRectangularFieldTemplate();
            // create a view for the field template
            Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.FormFieldTemplateView fieldTemplateView = 
                Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.FormFieldTemplateViewFactory.CreateView(fieldTemplate);
                
            // add field template to the collection of visual tool and
            // start building of field template
            _templateEditorTool.AddAndBuild(fieldTemplateView);
        }
                
        // ...
                
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.UI.VisualTools.VisualTool
          Vintasoft.Imaging.UI.VisualTools.UserInteraction.UserInteractionVisualTool
             Vintasoft.Imaging.FormsProcessing.FormRecognition.UI.VisualTools.FormFieldTemplateEditorTool

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also