public ITrans GetTrans() { if (Trans.Strategy == Strategy) { return(Trans); } switch (Strategy) { case TransStrategy.Baidu: Trans = new BaiduTrans(); break; case TransStrategy.Tencent: Trans = new TencentTrans(); break; case TransStrategy.Google: Trans = new GoogleTrans(); break; case TransStrategy.Microsoft: Trans = new MicrosoftTrans(); break; case TransStrategy.Custom: Trans = new CustomTrans(); break; default: Trans = new BaiduTrans(); break; } return(Trans); }
private void Trans_Click(object sender, RoutedEventArgs e) { string str = Index.ChatingContMsg.Selection.Text; if (!String.IsNullOrEmpty(str)) { ComboBoxItem comboBoxItem = (ComboBoxItem)this.ToLanguage.SelectedItem; string ret = BaiduTrans.Trans(str, comboBoxItem.DataContext.ToString()); JObject jObject = JObject.Parse(ret); Index.ChatingContMsg.Selection.Text = jObject["trans_result"][0]["dst"].ToString(); } }