Beispiel #1
0
 private void tRefresh_Tick(object sender, EventArgs e)
 {
     if (dirty)
     {
         ts.Enqueue(AsyncStatic.MakeTranslation(txtInput.Text, Translation_callback));
         dirty = false;
     }
 }
Beispiel #2
0
 public void UpdateText(IAsyncOCR OCRResult, TranslationCallback callback = null)
 {
     // Only reevaluate if the underlying text actually changed
     if (atrans == null || this.GetText(OCRResult) != this.atrans.rawText)
     {
         string NewText = GetText(OCRResult);
         BabelForm.Invoke(BabelForm.SafeIncrementOdometer, new object[] { 0, NewText.Length }); // Update odometer
         atrans = AsyncStatic.MakeTranslation(NewText, callback);
     }
 }
Beispiel #3
0
 // Trigger OCR recognition if appropriate
 bool DoOCR(bool Auto = false)
 {
     if (AppState != State.snapped)
     {
         return(false);                           // Prevent double OCR
     }
     // Proceed if it's a manual request, or if it's an auto request and autoOCR is on
     if (!Auto || AutoOCR) //Properties.Settings.Default.autoOCR)
     {
         ChangeState(State.OCRing);
         IncrementOdometer(1, 0); // Add one snap to the odometer
         OCRResult = AsyncStatic.MakeOCR(snap, AsyncOCR_callback);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #4
0
        private void Settings_Load(object sender, EventArgs e)
        {
            SafeLoadLanguages = LoadLanguages;
            if (gsl == null)
            {
                gsl = AsyncStatic.MakeGSL(LoadLanguages);
            }
            else
            {
                LoadLanguages(gsl);
            }

            txtGoogleKeyFile.Text     = Properties.Settings.Default.googleApiKeyPath;
            txtGoogleProjectName.Text = Properties.Settings.Default.googleProjectName;

            txtMsOcrApiKey.Text        = Properties.Settings.Default.microsoftOcrApiKey;
            txtMsOcrEndpoint.Text      = Properties.Settings.Default.microsoftOcrEndpoint;
            txtMsTranslatorApiKey.Text = Properties.Settings.Default.microsoftTranslatorApiKey;

            txtDeepLKey.Text = Properties.Settings.Default.DeepLKey;

            cboOCR.Items.Clear();
            cboOCR.Items.AddRange(ocrSources);
            cboOCR.SelectedItem = cboOCR.Items
                                  .Cast <ComboBoxItem <DataSource> >()
                                  .First(item => item.data == Properties.Settings.Default.OCRDataSource);

            cboTranslation.Items.Clear();
            cboTranslation.Items.AddRange(translationSources);
            cboTranslation.SelectedItem = cboTranslation.Items
                                          .Cast <ComboBoxItem <DataSource> >()
                                          .First(item => item.data == Properties.Settings.Default.TranslationDataSource);

            cbxDisplayTimes.Checked = Properties.Settings.Default.displayTimes;
            numRateLimit.Value      = Properties.Settings.Default.reqsPerSecond;
        }
Beispiel #5
0
 // This setting needs to be split across each translation data source.
 // Some re-engineering may be involved.
 private void btnRefreshGSL_Click(object sender, EventArgs e)
 {
     gsl = AsyncStatic.MakeGSL(LoadLanguages);
 }