private void MatchCompletedForms_Click(object sender, System.EventArgs e)
        {
            this.Cursor      = System.Windows.Forms.Cursors.WaitCursor;
            statusLabel.Text = "Form Matching In Progress ... Please Wait";
            Application.DoEvents();
            System.Windows.Forms.TabPage newtabpage;
            string newtabName;
            int    minConfidence      = 80;
            int    lMatchedConfidence = 0;
            int    sensitivity        = 60;

            picssxicr1.ImageSource = PegasusImaging.WinForms.SSXICR4.peImageSource.IMGSRC_DIB;
            picssxicr1.OwnDIB      = true;


            for (int i = 0; i < 3; i++)
            {
                //create new tab and add to tabcontrol.
                //create new IX7 control and place it on new tab
                //MessageBox.Show(filledForms[i]);
                newtabName          = filledForms[i].Substring(filledForms[i].LastIndexOf("\\") + 1);
                newtabpage          = new System.Windows.Forms.TabPage(newtabName);
                newtabpage.TabIndex = i;
                FilledFormsTabControl.Controls.Add(newtabpage);
                IXfilled[i]        = new PegasusImaging.WinForms.ImagXpress7.PICImagXpress();
                IXfilled[i].Parent = newtabpage;
                IXfilled[i].Left   = IXfilled[i].Top = 0;
                IXfilled[i].Width  = newtabpage.Width;
                IXfilled[i].Height = newtabpage.Height;
                newtabpage.Controls.Add(IXfilled[i]);

                IXfilled[i].AutoSize = PegasusImaging.WinForms.ImagXpress7.enumAutoSize.ISIZE_BestFit;
                IXfilled[i].FileName = filledForms[i];
                picssxicr1.hDIB      = IXfilled[i].CopyDIB();

                matchedtemplate[i] = picssxicr1.MatchTemplate(true, false, minConfidence, sensitivity, ref lMatchedConfidence);
                IXfilled[i].hDIB   = picssxicr1.GetPreprocessImagehDIB();
                picssxicr1.DeletePreprocessImage();

                FilledFormsTabControl.SelectedIndex = i;
            }


            statusLabel.Text = "Form Matching Complete";

            MatchCompletedForms.Enabled = false;
            LoadTemplateForms.Enabled   = false;
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }
        /*	/// <summary>
         *      /// The main entry point for the application.
         *      /// </summary>
         *      [STAThread]
         *      static void Main()
         *      {
         *              Application.Run(new FormsMatching());
         *      }*/

        private void LoadTemplateForms_Click(object sender, System.EventArgs e)
        {
            System.Windows.Forms.TabPage newtabpage;

            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

            picssxicr1.ImageSource = PegasusImaging.WinForms.SSXICR4.peImageSource.IMGSRC_DIB;
            picssxicr1.OwnDIB      = true;

            string newtabName;

            for (int i = 0; i < 3; i++)
            {
                //create new tab and add to tabcontrol.
                //create new IX7 control and place it on new tab
                newtabName          = blankForms[i].Substring(blankForms[i].LastIndexOf("\\") + 1);
                newtabpage          = new System.Windows.Forms.TabPage();
                newtabpage.Text     = newtabName;
                newtabpage.TabIndex = i;
                BlankFormsTabControl.Controls.Add(newtabpage);
                BlankFormsTabControl.SelectedIndex = i;
                IXblank[i]        = new PegasusImaging.WinForms.ImagXpress7.PICImagXpress();
                IXblank[i].Parent = newtabpage;
                IXblank[i].Left   = IXblank[i].Top = 0;
                IXblank[i].Width  = newtabpage.Width;
                IXblank[i].Height = newtabpage.Height;
                newtabpage.Controls.Add(IXblank[i]);

                IXblank[i].AutoSize = PegasusImaging.WinForms.ImagXpress7.enumAutoSize.ISIZE_BestFit;
                IXblank[i].FileName = blankForms[i];
                statusLabel.Text    = blankForms[i] + " is being added to template database";
                Application.DoEvents();
                picssxicr1.hDIB = IXblank[i].CopyDIB();
                picssxicr1.AddTemplateImage(newtabName);
            }

            statusLabel.Text            = "Template Forms Added To Database";
            MatchCompletedForms.Enabled = true;
            LoadTemplateForms.Enabled   = false;

            this.Cursor = System.Windows.Forms.Cursors.Default;
        }