wp7词典,wp7 在线词典初级版

又过了三天了,词典有了点模样,在遇到难题是睡一觉还是管用的,不知道是不是模拟器的问题汉字的查询不对路,算了,以后再自己完善吧,这东西就到这了先。。。
代码:
wp7 在线词典初级版wp7词典wp7 在线词典初级版wp7词典View Code 1 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 52 53 54 55 56 57
wp7 在线词典初级版wp7词典 wp7 在线词典初级版wp7词典
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Net; 5 using System.Windows; 6 using System.Windows.Controls; 7 using System.Windows.Documents; 8 using System.Windows.Input; 9 using System.Windows.Media; 10 using System.Windows.Media.Animation; 11 using System.Windows.Shapes; 12 using Microsoft.Phone.Controls; 13 using System.IO; 14 using System.Xml.Linq; 15 using System.Text; 16 using System.Windows.Data; 17 using System.Text.RegularExpressions; 18 namespace wp7dict 19 { 20 public partial class _disibledevent=> 21 { 22 private string mp3url=""; 23 public _disibledevent=> 24 { 25 InitializeComponent(); 26 27 } 28 29 private void search_Click(object sender, RoutedEventArgs e) 30 { 31 if (textBox1.Text != null && textBox1.Text != "") 32 { 33 WebClient webc = new WebClient(); 34 webc.OpenReadAsync(new Uri("http://dict-co.iciba.com/api/dictionary.php?w=" + textBox1.Text)); 35 webc.OpenReadCompleted += new OpenReadCompletedEventHandler(webc_OpenReadCompleted); 36 } 37 } 38 39 void webc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) 40 { 41 string webxml, Pos="", Acceptation=""; 42 using (StreamReader readxml = new StreamReader(e.Result, Encoding.UTF8)) 43 { 44 webxml = readxml.ReadToEnd(); 45 } 46 TextReader txtr = new StringReader(webxml); 47 XDocument xdo = XDocument.Load(txtr); 48 #region //汉字查询 49 Regex cn = new Regex("[\u4e00-\u9fa5]+"); 50 if (cn.IsMatch(textBox1.Text)) 51 { 52 MessageBox.Show("汉译英还有问题就先这样吧!"); 53 //var chinese = from query in xdo.Descendants("acceptation") 54 // select new dictionary 55 // { 56 // synonym = query.Element("synonym").Value.ToString() 57 // }; 58 //foreach (var i in chinese.ToArray()) 59 //{ 60 // Pos = Pos + i.synonym.ToString() + '\n'; 61 //} 62 //SoundMarkTextBlock.Text = "翻译:" + Pos; 63 } 64 #endregion 65 #region 查找英语和数字 66 else 67 { 68 try 69 { 70 var major = from query in xdo.Descendants("dict") 71 select new dictionary 72 { 73 ps = "音标:" + "/" + query.Element("ps").Value + "/", 74 pron = query.Element("pron").Value 75 }; 76 var pos = (from query in xdo.Descendants("pos") select query);//破地方,太费时间了 77 var acceptation = (from query in xdo.Descendants("acceptation") select query); 78 SoundMarkTextBlock.Text = major.ToArray()[0].ps.ToString(); 79 foreach (var i in pos.ToArray()) 80 { 81 Pos = Pos + i.Value.ToString() + "/"; 82 } 83 NatureTextBlock.Text = "词性:" + Pos; 84 foreach (var i in acceptation.ToArray()) 85 { 86 Acceptation = Acceptation + i.Value.ToString() + " \\"; 87 } 88 ExplainTextBlock.Text = "解释:" + Acceptation; 89 SoundOfLetterButton.Opacity = 1; 90 mp3url = major.ToArray()[0].pron.ToString(); 91 } 92 catch (Exception) 93 { 94 SoundOfLetterButton.Opacity = 0; 95 textBox1.Text = ""; 96 SoundMarkTextBlock.Text = "音标: 无信息!"; 97 NatureTextBlock.Text = "词性: 无信息!"; 98 ExplainTextBlock.Text = "解释: 无信息!"; 99 } 100 #endregion 101 } 102 try 103 { 104 var dict = from query in xdo.Descendants("sent") 105 select new dictionary 106 { 107 orig = query.Element("orig").Value.ToString(), 108 trans = query.Element("trans").Value.ToString() 109 }; 110 listBox2.ItemsSource = dict; 111 textBlock1.Opacity = 1; 112 } 113 catch (Exception) 114 { 115 textBlock1.Opacity = 0; 116 textBox1.Text = ""; 117 MessageBox.Show("查找失败!!"); 118 } 119 120 } 121 122 private void SoundOfLetterButton_Click(object sender, RoutedEventArgs e) 123 { 124 if (mp3url!="") 125 { 126 SoundOfLetterME.Source =new Uri(mp3url); 127 128 } 129 } 130 131 } 132 }
真是够呛,在论坛里看到一牛人做了个豆瓣FM(wp7版),太棒了,今后就研究研究怎么整的,咱也做个虾米网的播放器,不知想法靠谱不,希望成功呀!!
Tags:  wp7在线音乐 wp7在线 wp7在线看视频 wp7在线视频 wp7词典

延伸阅读

最新评论

发表评论