示例#1
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);
     }
 }
示例#2
0
        public static IAsyncTranslation MakeTranslation(string input, TranslationCallback callback)
        {
            switch (Properties.Settings.Default.TranslationDataSource)
            {
            case DataSource.Google:
                return(new GoogleImpl.AsyncTranslation(input, callback));

            case DataSource.Microsoft:
                return(new MicrosoftImpl.AsyncTranslation(input, callback));

            case DataSource.DeepL:
                return(new DeepLImpl.AsyncTranslation(input, callback));

            default:
                return(new DummyImpl.AsyncTranslation(input, callback));
            }
        }
示例#3
0
        public AsyncTranslation(string text, TranslationCallback callback = null)
        {
            rawText       = text;
            this.callback = callback;

            if (text == null || text == "")
            {
                _translatedText = "";
                _detectedLocale = Properties.Settings.Default.targetLocale;
                _timeStamp      = "[empty]";
                isDone          = true;
                this.callback?.Invoke(this);
            }
            else
            {
                task = Task.Run(DoTranslation);
            }
        }
示例#4
0
            public PhraseRect(Rectangle Location, IAsyncOCR OCRResult, PhraseRectMode Mode, frmBabel BabelForm, TranslationCallback callback = null)
            {
                this.Location = Location;

                this.BabelForm = BabelForm;

                this.mode = Mode;
                if (Autofit)
                {
                    DoAutoFit(OCRResult);
                }
                UpdateText(OCRResult, callback);
            }
示例#5
0
 public PhraseRect(Rectangle Location, IAsyncOCR OCRResult, frmBabel BabelForm, TranslationCallback callback = null)
     : this(Location, OCRResult, NewPhraseMode, BabelForm, callback)
 {
     // nothing to do
 }
示例#6
0
 public AsyncTranslation(string text, TranslationCallback callback)
 {
     rawText = text;
     callback?.Invoke(this);
 }