示例#1
0
        public AsyncTranslation(string text, frmBabel Form, Action <AsyncTranslation> callback = null)
        {
            rawText        = text;
            this.Form      = Form;
            this.callback += callback;

            if (Properties.Settings.Default.dummyData)
            {
                _translatedText = rawText;
                _detectedLocale = Properties.Settings.Default.targetLocale;
                _timeStamp      = "[dummy]";
                isDone          = true;
                callback?.Invoke(this);
            }
            else if (text == null || text == "")
            {
                _translatedText = "";
                _detectedLocale = Properties.Settings.Default.targetLocale;
                _timeStamp      = "[empty]";
                isDone          = true;
                callback?.Invoke(this);
            }
            else
            {
                task = Task.Run(DoTranslation);
            }
        }
示例#2
0
        public AsyncOCR(SImage image, frmBabel Form, Action <AsyncOCR> callback = null)
        {
            this.image     = image.Copy();
            this.Form      = Form;
            this.callback += callback;

            if (Properties.Settings.Default.dummyData)
            {
                _bigBox     = OCRBox.DummyBigBox();
                _smallBoxes = OCRBox.DummySmallBoxes();
                _timeStamp  = "[dummy]";
                isDone      = true;
                callback?.Invoke(this);
            }
            else if (image == null)
            {
                _bigBox     = null;
                _smallBoxes = new OCRBox[0];
                _timeStamp  = "[empty]";
                isDone      = true;
                callback?.Invoke(this);
            }
            else
            {
                task = Task.Run(DoOCR);
            }
        }