Пример #1
0
        private async Task StartControlAfterFirstCon()
        {
            try
            {
                Bitmap nextImageSize = (Bitmap)picOriginalSx.Image;
                //Continua finche la pagina sinsitra e destra non arriva alla fine del libro
                while (nNextSx + 2 <= lastNumber && nNextDx + 2 <= lastNumber)
                {
                    //Creo i due task uno per la pagina sinistra, uno per la destra e li eseguo
                    var sxTask = Task.Run(() => FirstThreadPageSxAsync());
                    var dxTask = Task.Run(() => FirstThreadPageDxAsync());

                    //Attendo il completamento dei due task paralleli
                    var numSxTesseract = await sxTask;
                    var numDxTesseract = await dxTask;

                    //Inserisco i due numeri torvati della pagina sx e dx dopo il rilevamento Tesseract e li controllo in sequenza
                    firstAfterCont.SetNextNum(numSxTesseract, numDxTesseract);
                    //Verifico e aggiorno la sequenza
                    firstAfterCont.Update(stringSxDetected, stringDxDetected);
                    //MessageBox.Show(firstAfterCont.GetNumberAfterGetCorrectNumber().ToString());

                    //Quando isRight da false perchè si è verificato un errore durante il controllo
                    //(es. si è saltata una pagina durante la digitalizzazione oppure ci sono due pagine senza numero)
                    if (firstAfterCont.IsRight() == false)
                    {
                        //Azzero i contatoti delle pagine
                        nNextSx = 0;
                        nNextDx = 0;
                        Boolean rightIsFalse = firstAfterCont.IsRight();
                        Boolean empty        = firstAfterCont.isEmpty();
                        //Se c'è un errore mostro i file name delle due pagine sbagliate
                        if (rightIsFalse == false)
                        {
                            if (empty == true)
                            {
                                MessageBox.Show("NON E' STATO RILEVATO ALCUN NUMERO NELLE PAGINE " + insertFileNameSx + " E " + insertFileNameDx + "");
                            }
                            else
                            {
                                //MessageBox.Show("C'è un errore dopo la pagina"+numSxErr.ToString()+"e"+numDxErr.ToString()+"");
                                MessageBox.Show("C'è un errore nel controllo della numerazione nelle pagine " + insertFileNameSx + "  e  " + insertFileNameDx.ToString() + "");
                            }
                        }
                        return;
                    }
                }
                Boolean rightIsTrue = firstAfterCont.IsRight();
                if (rightIsTrue == true)
                {
                    MessageBox.Show("Controllo eseguito con successo, LIBRO IN ORDINE");
                }
            }
            catch (Exception ex)
            {
                DialogResult result;
                result = MessageBox.Show(ex.Message);
            }
        }