예제 #1
0
        private async void AuthTestBtn_Click(object sender, RoutedEventArgs e)
        {
            Common.appSettings.DeepLsecretKey = DeepLTransSecretKeyBox.Text;
            ITranslator deepLTrans = new DeepLTranslator();

            deepLTrans.TranslatorInit(DeepLTransSecretKeyBox.Text, DeepLTransSecretKeyBox.Text);

            if (await deepLTrans.TranslateAsync("apple", "zh", "en") != null)
            {
                HandyControl.Controls.Growl.Success($"DeepL {Application.Current.Resources["APITest_Success_Hint"]}");
            }
            else
            {
                HandyControl.Controls.Growl.Error($"DeepL {Application.Current.Resources["APITest_Error_Hint"]}\n{deepLTrans.GetLastError()}");
            }
        }
예제 #2
0
        private async void TransTestBtn_Click(object sender, RoutedEventArgs e)
        {
            ITranslator deepLTrans = new DeepLTranslator();

            deepLTrans.TranslatorInit(DeepLTransSecretKeyBox.Text, DeepLTransSecretKeyBox.Text);
            string res = await deepLTrans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text);

            if (res != null)
            {
                HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString());
            }
            else
            {
                HandyControl.Controls.Growl.Error(
                    $"DeepL {Application.Current.Resources["APITest_Error_Hint"]}\n{deepLTrans.GetLastError()}");
            }
        }