private void autoOCRButton_Click(object sender, EventArgs e) { oldNum = currentNum; // Set up the thread for scanning the images stopEvent = new ManualResetEvent(false); finishedEvent = new ManualResetEvent(false); stopEvent.Reset(); finishedEvent.Reset(); updateProgressDelegate = new DelegateUpdateProgress(this.UpdateProgress); OcrThread worker = new OcrThread(this, stopEvent, finishedEvent, subfile.NumSubtitles); Thread thread = new Thread(new ThreadStart(worker.Run)); // Start the thread thread.Start(); using (pf = new ProgressForm(this, subfile.NumSubtitles)) pf.ShowDialog(); // If we ordinarily finished, then the thread has already run out. // But if the user pressed the cancel button, we have to stop the thread if (!finishedEvent.WaitOne(0, true)) { CancelThread(); } currentNum = oldNum; currentSubtitle = LoadSubtitleImage(currentNum); UpdateSRTPage(); mainTabControl.SelectedIndex = 1; }
private void StartImageOCR() { ImageOCR(currentSubtitle); UpdateTextBox(); subfile.UpdateSubtitleText(currentNum, currentSubtitle); ActivateNextUnknownLetter(); // If the checkbox to continue with the next subtitle is checked, try to search the whole movie for an unknown character // We do that in another thread so we don't block the UI if (activeLetter == null && autoProgress.Checked) { oldNum = currentNum; // Set up the thread for scanning the images stopEvent = new ManualResetEvent(false); finishedEvent = new ManualResetEvent(false); stopEvent.Reset(); finishedEvent.Reset(); updateProgressDelegate = new DelegateUpdateProgress(this.UpdateProgress); OcrThread worker = new OcrThread(this, stopEvent, finishedEvent, currentNum, subfile.NumSubtitles); Thread thread = new Thread(new ThreadStart(worker.Run)); // Start the thread thread.Start(); using (pf = new ProgressForm(this, subfile.NumSubtitles)) pf.ShowDialog(); if (!finishedEvent.WaitOne(0, true)) { // FIXME. Add some code so that when the user clicks cancel, the image stays on the last processed subtitle } if (worker.FoundNum != -1) { currentNum = worker.FoundNum; } else { currentNum = subfile.NumSubtitles - 1; } currentSubtitle = LoadSubtitleImage(currentNum); ImageOCR(currentSubtitle); UpdateTextBox(); ActivateNextUnknownLetter(); } }
private void StartPrecalculating() { // Set up the thread for scanning the images stopEvent = new ManualResetEvent(false); finishedEvent = new ManualResetEvent(false); stopEvent.Reset(); finishedEvent.Reset(); updateProgressDelegate = new DelegateUpdateProgress(this.UpdateProgress); OcrThread worker = new OcrThread(this, stopEvent, finishedEvent, subfile.NumSubtitles); Thread thread = new Thread(new ThreadStart(worker.Run)); // Start the thread thread.Start(); // If we ordinarily finished, then the thread has already run out. // But if the user pressed the cancel button, we have to stop the thread if (!finishedEvent.WaitOne(0, true)) CancelThread(); currentNum = oldNum; currentSubtitle = LoadSubtitleImage(currentNum); UpdateSRTPage(); mainTabControl.SelectedIndex = 1; }
private void StartImageOCR() { ImageOCR(currentSubtitle); UpdateTextBox(); subfile.UpdateSubtitleText(currentNum, currentSubtitle); ActivateNextUnknownLetter(); // If the checkbox to continue with the next subtitle is checked, try to search the whole movie for an unknown character // We do that in another thread so we don't block the UI if (activeLetter == null && autoProgress.Checked) { oldNum = currentNum; // Set up the thread for scanning the images stopEvent = new ManualResetEvent(false); finishedEvent = new ManualResetEvent(false); stopEvent.Reset(); finishedEvent.Reset(); updateProgressDelegate = new DelegateUpdateProgress(this.UpdateProgress); OcrThread worker = new OcrThread(this, stopEvent, finishedEvent, currentNum, subfile.NumSubtitles); Thread thread = new Thread(new ThreadStart(worker.Run)); // Start the thread thread.Start(); using (pf = new ProgressForm(this, subfile.NumSubtitles)) pf.ShowDialog(); if (!finishedEvent.WaitOne(0, true)) { // FIXME. Add some code so that when the user clicks cancel, the image stays on the last processed subtitle } if (worker.FoundNum != -1) currentNum = worker.FoundNum; else currentNum = subfile.NumSubtitles - 1; currentSubtitle = LoadSubtitleImage(currentNum); ImageOCR(currentSubtitle); UpdateTextBox(); ActivateNextUnknownLetter(); } }