void cbbTranslateOption_SelectedIndexChanged(object sender, EventArgs e) { try { _translator = TranslateFactory.GetTranslator((TranslatorEnum)cbbTranslateOption.SelectedIndex); } catch (Exception err) { MessageBox.Show(err.Message); } }
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)); } }
public void Speak() { Translator translator = new Translator(); translator.GetAudioStream(_translatedText, _translatedLanguage.Code, delegate(Stream s) { if (PlayStream != null) { PlayStream(this, new StreamEventArgs(s)); } }); }
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; }); }