Beispiel #1
0
 private void BtnSearch_Click(object sender, EventArgs e)
 {
     Tbx.Clear();
     if (CbxDictionary.Text == "有道词典")
     {
         try
         {
             if (GetTransOnWeb(CbxSearch.Text) == "")
             {
                 if (CbxSearch.Text != "")
                 {
                     Tbx.AppendText("不在此词典中");
                 }
             }
             else
             {
                 Tbx.AppendText(GetPhoneticOnWeb(CbxSearch.Text));
                 Tbx.AppendText(GetTransOnWeb(CbxSearch.Text));
             }
         }
         catch (System.Net.WebException webe)
         {
             Console.WriteLine("Exception caught: {0}", webe);
             Tbx.AppendText("无法连接到远程服务器,请检查网络设置!");
         }
     }
     else
     {
         if (File.Exists(dictDict[CbxDictionary.Text]))
         {
             if (GetTransFromBook(dictDict[CbxDictionary.Text], CbxSearch.Text) == "")
             {
                 if (CbxSearch.Text != "")
                 {
                     Tbx.AppendText("不在此词典中");
                 }
             }
             else
             {
                 Tbx.AppendText(GetPhoneticFromBook(dictDict[CbxDictionary.Text], CbxSearch.Text));
                 Tbx.AppendText("\r\n");
                 Tbx.AppendText(GetTransFromBook(dictDict[CbxDictionary.Text], CbxSearch.Text));
             }
         }
         else
         {
             MessageBox.Show("找不到词典,请添加词典!");
         }
     }
 }
Beispiel #2
0
        private void OpenArticle()
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(articlePath);
            XmlNode root  = xdoc.DocumentElement;
            string  trans = "";

            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.Name == "section")
                {
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        if (node2.Name == "p")
                        {
                            trans = node2.InnerText;
                            Tbx.AppendText("    " + trans + "\r\n");
                            CutWord(trans);
                        }
                    }
                }
            }
        }