/*******************************************************************/
        /*******************************************************************/
        private void runOptimizeSpeedButton_Click(object sender, System.EventArgs e)
        {
            if(testImgListBox.Items.Count!=0)
                changeWindowMode(2);

            if(!timer.Enabled)
            {
                FindAlwaysCheckBox.Checked = false;
                optInstance = speedOptHandler;
                optInstance.reset();
                UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_UPDATE_VALS);
                UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_OPTIMUM_VALS);
                UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_STATISTICS_STATUS);

                OptimizeButton.Text = "Stop";
                mAssistant.onTimer = true;
                timer.Enabled = true;
            }
            else
            {
                timer.Enabled = false;
                OptimizeButton.Text = "Run Optimization";
                mAssistant.onTimer = false;
                UpdateStatisticsData(MatchingOpt.RUN_FAILED);
            }
        }
        /*******************************************************************/
        /*******************************************************************/
        private void runStatisticsButton_Click(object sender, System.EventArgs e)
        {
            if(testImgListBox.Items.Count!=0)
                changeWindowMode(2);

            if(!timer.Enabled)
            {
                FindAlwaysCheckBox.Checked = false;
                optInstance = inspectOptHandler;
                optInstance.reset();
                UpdateStatisticsData(MatchingOpt.UPDATE_INSP_RECOGRATE);
                UpdateStatisticsData(MatchingOpt.UPDATE_INSP_STATISTICS);

                StatisticsButton.Text = "Stop";
                timer.Enabled = true;
                mAssistant.onTimer = true;
            }
            else
            {
                timer.Enabled = false;
                StatisticsButton.Text = "Run Inspect";
                mAssistant.onTimer = false;
            }
        }
        /********************************************************************/
        /********************************************************************/
        private void resetModelbutton_Click(object sender, System.EventArgs e)
        {
            groupBoxCreateModel.Enabled = true;
            mAssistant.onExternalModelID = false;
            FindAlwaysCheckBox.Checked = false;
            resetModelbutton.Enabled   = false;
            saveModelbutton.Enabled    = true;

            DetectionContour = null;
            ModelContour     = null;

            if(mAssistant.getDispImage()!=null)
                groupBoxCreateROI.Enabled = true;

            speedOptHandler.reset();
            optInstance = speedOptHandler;
            UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_UPDATE_VALS);
            UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_OPTIMUM_VALS);
            UpdateStatisticsData(MatchingOpt.UPDATE_RECOG_STATISTICS_STATUS);

            inspectOptHandler.reset();
            optInstance = inspectOptHandler;
            UpdateStatisticsData(MatchingOpt.UPDATE_INSP_STATISTICS);
            UpdateStatisticsData(MatchingOpt.UPDATE_INSP_RECOGRATE);

            //reset Model parameters
            mAssistant.resetCachedModelParams();

            if(tabControl.SelectedIndex != 0)
            {
                tabControl.SelectedIndex = 0;
            }
            else
            {
                changeWindowMode(1);
                CreateModelGraphics();
                mView.repaint();
            }
        }