Esempio n. 1
0
        public void BwApp_DoWork(object sender, DoWorkEventArgs e)
        {
            GoogleTranslateInfo gti = e.Argument as GoogleTranslateInfo;

            gti      = new GoogleTranslate(Config.APIKey).TranslateText(gti);
            e.Result = gti;
        }
        private void UpdateGoogleTranslateGUI(GoogleTranslateInfo info)
        {
            btnTranslate.Enabled   = true;
            btnTranslateTo.Enabled = true;

            txtTranslateText.Text   = info.Text;
            txtLanguages.Text       = info.SourceLanguage + " -> " + info.TargetLanguage;
            txtTranslateResult.Text = info.Result;
        }
        public void RunWorkerAsync_LanguageTranslator(GoogleTranslateInfo translationInfo)
        {
            WorkerTask gtTask = CreateTask(WorkerTask.JobLevel2.Translate);

            if (Loader.MyGTGUI == null)
            {
                Loader.MyGTGUI = new GoogleTranslateGUI(Engine.ConfigGT);
            }
            Loader.MyGTGUI.btnTranslate.Enabled   = false;
            Loader.MyGTGUI.btnTranslateTo.Enabled = false;
            gtTask.SetTranslationInfo(translationInfo);
            gtTask.RunWorker();
        }
        public void TranslateAsync(GoogleTranslateInfo info)
        {
            btnTranslate.Enabled   = false;
            btnTranslateTo.Enabled = false;

            TaskEx.Run(() =>
            {
                info = new GoogleTranslate(Config.APIKey).TranslateText(info);
            },
                       () =>
            {
                UpdateGoogleTranslateGUI(info);
            });
        }
Esempio n. 5
0
 public void StartBW_LanguageTranslator(GoogleTranslateInfo gti)
 {
     btnTranslate.Enabled   = false;
     btnTranslateTo.Enabled = false;
     CreateWorker().RunWorkerAsync(gti);
 }
 private void UpdateGoogleTranslateGUI(GoogleTranslateInfo info)
 {
     Loader.MyGTGUI.txtTranslateText.Text   = info.Text;
     Loader.MyGTGUI.txtLanguages.Text       = info.SourceLanguage + " -> " + info.TargetLanguage;
     Loader.MyGTGUI.txtTranslateResult.Text = info.Result;
 }
Esempio n. 7
0
        private void bwApp_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            GoogleTranslateInfo gti = e.Result as GoogleTranslateInfo;

            UpdateGoogleTranslateGUI(gti);
        }