예제 #1
0
 void cbbTranslateOption_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         _translator = TranslateFactory.GetTranslator((TranslatorEnum)cbbTranslateOption.SelectedIndex);
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
 }
예제 #2
0
        void FormDic_Load(object sender, EventArgs e)
        {
            try
            {
                cbbTranslateOption.SelectedIndex = 0;
                _translator = TranslateFactory.GetTranslator((TranslatorEnum)cbbTranslateOption.SelectedIndex);
            }
            catch (Exception err)
            {
                MessageBox.Show(string.Format("{0},程序将推出",err.Message));

                Application.Exit(new CancelEventArgs(true));
            }
        }
예제 #3
0
 public void Speak()
 {
     Translator translator = new Translator();
     translator.GetAudioStream(_translatedText, _translatedLanguage.Code, delegate(Stream s) {
         if (PlayStream != null) {
             PlayStream(this, new StreamEventArgs(s));
         }
     });
 }
예제 #4
0
        public void Translate(Language language)
        {
            if (String.IsNullOrEmpty(Text)) {
                return;
            }

            _translatedLanguage = language;

            Translator translator = new Translator();
            translator.Translate(_text, _translatedLanguage.Code, delegate(string translatedText) {
                TranslatedText = translatedText;
            });
        }