Esempio n. 1
0
 private void CopyAndTranslate()
 {
     if (SCaptrueFlag)
     {
         return;               //在截屏时,不进行复制翻译操作。
     }
     if (STOPTranlate)
     {
         return;
     }
     try
     {
         Select_str = GetCopySelect();
         if (Select_str == "")
         {
             return;
         }
         resultStr = TranslateAPI.Translate(Select_str, _settings);
         Console.WriteLine(resultStr);
         ResultFormShow = Select_str != "";
     }
     catch
     {
         Console.WriteLine("剪切板操作失败!");
     }
 }
Esempio n. 2
0
        public void TestMethodTranslate()
        {
            var config = new Configuration();

            TranslateAPI.TranslateServiceUrl = config.TranslateServiceUrl;
            TranslateAPI.TanslateRespose     = config.TanslateRespose;

            Assert.AreEqual("This is a test text", TranslateAPI.Translate("de", "en", "Das ist eine test Text"));
        }
Esempio n. 3
0
        private void cBt1_Click(object sender, EventArgs e)
        {
            TitleX = TitleX.Replace("\r\n", "");
            TitleX = TitleX.Replace("\r", "");
            TitleX = TitleX.Replace("\n", "");
            switch (SEbt.Text)
            {
            case "百度翻译":
                new Thread(() =>
                {
                    lock_Form = true;
                    Result    = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                         {
                                                                                                             ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                         }
                                                                                                         this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                         this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                         this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "有道翻译":
                new Thread(() =>
                {
                    lock_Form = true;
                    Result    = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                         {
                                                                                                             ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                         }
                                                                                                         this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                         this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                         this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "必应翻译":
                new Thread(() =>
                {
                    lock_Form = true;
                    Result    = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                         {
                                                                                                             ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                         }
                                                                                                         this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                         this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                         this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "谷歌翻译":
                new Thread(() =>
                {
                    lock_Form = true;
                    Result    = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                         {
                                                                                                             ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                         }
                                                                                                         this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                         this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                         this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;
            }
        }
Esempio n. 4
0
        private void SEbt_Click(object sender, EventArgs e)
        {
            switch (SEbt.Text)
            {
            case "小牛翻译":
                SEbt.Text = "有道翻译";
                new Thread(() =>
                {
                    lock_Form = true;
                    settings.TranslateMode = "Youdao";
                    Result = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                      {
                                                                                                          ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                      }
                                                                                                      this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                      this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                      this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "有道翻译":
                SEbt.Text = "必应翻译";
                new Thread(() =>
                {
                    lock_Form = true;
                    settings.TranslateMode = "Bing";
                    Result = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                      {
                                                                                                          ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                      }
                                                                                                      this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                      this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                      this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "必应翻译":
                SEbt.Text = "谷歌翻译";
                new Thread(() =>
                {
                    lock_Form = true;
                    settings.TranslateMode = "Google";
                    Result = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                      {
                                                                                                          ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                      }
                                                                                                      this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                      this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                      this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "谷歌翻译":
                SEbt.Text = "百度翻译";
                new Thread(() =>
                {
                    lock_Form = true;
                    settings.TranslateMode = "Baidu";
                    Result = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => { ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                                                                                                      {
                                                                                                          ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                                                                                                      }
                                                                                                      this.Height      = 74 + ResultLabel.Height + 8;
                                                                                                      this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                                                                                                      this.Width       = 10 + ResultLabel.Width + 10; }), null);
                    lock_Form = false;
                }).Start();
                break;

            case "百度翻译":
                SEbt.Text = "小牛翻译";
                new Thread(() =>
                {
                    lock_Form = true;
                    settings.TranslateMode = "XiaoNiu";
                    Result = TranslateAPI.Translate(TitleX, settings); BeginInvoke(new Action(() => {
                        ResultLabel.Text = Result; while (ResultLabel.Height * 3 / 2 > ResultLabel.MaximumSize.Width)
                        {
                            ResultLabel.MaximumSize = new Size(ResultLabel.MaximumSize.Width + 50, 1800);
                        }
                        this.Height      = 74 + ResultLabel.Height + 8;
                        this.MaximumSize = new Size(10 + ResultLabel.Width + 10, 1800);
                        this.Width       = 10 + ResultLabel.Width + 10;
                    }), null);
                    lock_Form = false;
                }).Start();
                break;
            }
        }