コード例 #1
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            Tbx.Clear();
            LbxWord.Items.Clear();
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = AppInfoHelper.GetArticleFolder();
            dialog.Multiselect      = false; //该值确定是否可以选择多个文件
            dialog.Title            = "请选择文件夹";
            dialog.Filter           = "所有文件(*.xml)|*.xml";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                articlePath     = dialog.FileName;
                TbxArticle.Text = dialog.SafeFileName.Replace(".xml", "");
            }
            words        = new HashSet <string>();
            dict         = CbxDictionary.Text;
            wordList     = new List <string>();
            transList    = new List <string>();
            phoneticList = new List <string>();
            if (File.Exists(articlePath))
            {
                MPB.Value = 0;
                MPB.Show();
                OpenArticle();
                t = new Thread(BackgroundProcess);
                t.IsBackground = true;
                t.Start();
            }
        }
コード例 #2
0
 public LegalTextParserFactory(Tbx tbxSource)
 {
     bgParser = new BgLegalTextParser(tbxSource);
     hrParser = new HrLegalTextParser(tbxSource);
     huParser = new HuLegalTextParser(tbxSource);
     plParser = new PlLegalTextParser(tbxSource);
     roParser = new RoLegalTextParser(tbxSource);
     skParser = new SkLegalTextParser(tbxSource);
     slParser = new SlLegalTextParser(tbxSource);
 }
コード例 #3
0
 private void cbx_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key != Key.Up && (e.Key == Key.Return || e.Key == Key.Return) && Cbx.LivePreviewItem != null)
     {
         Cbx.SelectedItem   = RuntimeHelpers.GetObjectValue(Cbx.LivePreviewItem);
         Tbx.SelectionStart = Tbx.Text.Length;
         Cbx.IsDropDownOpen = false;
         Tbx.Focus();
         e.Handled = true;
     }
 }
コード例 #4
0
        public CorpusIndexManager(IndexingMode indexingMode, string rootDirectory, string indexDirectory, string tbxIateLocation = null, string logLocation = null, int?parallelIndexingLimit = null, bool readOnly = true)
        {
            m_readOnly     = readOnly;
            m_indexingMode = indexingMode;

            if (!Directory.Exists(rootDirectory))
            {
                throw new ArgumentException("The source directory must exist!");
            }

            /*if (Directory.Exists(indexDirectory) && !Directory.EnumerateFileSystemEntries(indexDirectory).GetEnumerator().MoveNext())
             * {
             *  throw new ArgumentException("The indexing directory must be empty!");
             * }*/

            m_rootSourceDirectory = rootDirectory;

            if (logLocation != null)
            {
                m_logLocation = logLocation;
                if (!m_logLocation.EndsWith(Path.DirectorySeparatorChar.ToString()))
                {
                    m_logLocation += Path.DirectorySeparatorChar;
                }
                if (!Directory.Exists(m_logLocation))
                {
                    Directory.CreateDirectory(m_logLocation);
                }
            }

            m_rootIndexDirectory = indexDirectory;
            if (!m_rootIndexDirectory.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                m_rootIndexDirectory += Path.DirectorySeparatorChar;
            }
            if (!Directory.Exists(m_rootIndexDirectory))
            {
                Directory.CreateDirectory(m_rootIndexDirectory);
            }

            if (tbxIateLocation != null)
            {
                Tbx sourceTbx     = null;
                var serializerTbx = new System.Xml.Serialization.XmlSerializer(typeof(Tbx));
                using (var xmlReader = XmlReader.Create(tbxIateLocation))
                {
                    sourceTbx = (Tbx)serializerTbx.Deserialize(xmlReader);
                }

                m_parserFactory = new LegalTextParserFactory(sourceTbx);
            }

            SetupWriters();
        }
コード例 #5
0
ファイル: Dictionary.cs プロジェクト: csblnc/learningen
 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("找不到词典,请添加词典!");
         }
     }
 }
コード例 #6
0
        public LegalTextParser(Tbx tbxData)
        {
            lock (m_tbxLock)
            {
                if (m_tbxSource == null)
                {
                    m_tbxSource = tbxData;

                    var topics = m_tbxSource.Text.body.Where(b => b.Description.Type == "subjectField").Select(b => new { Key = b.Id.ToString(), Value = b.Description.Value }).Where(b => !String.IsNullOrWhiteSpace(b.Value));
                    foreach (var topic in topics)
                    {
                        m_tbxCache[topic.Key] = topic.Value.Split(';').ToList();;
                    }
                }
            }
        }
コード例 #7
0
 private void cbx_IsDropDownOpenChanged(object sender, EventArgs e)
 {
     if (Cbx.IsDropDownOpen)
     {
         return;
     }
     updating = true;
     try
     {
         Cbx.SelectedItem   = null;
         Tbx.SelectionStart = Tbx.Text.Length;
         Tbx.Focus();
     }
     finally
     {
         updating = false;
     }
 }
コード例 #8
0
        private void UpdateFilter()
        {
            if (Tbx.Text == string.Empty)
            {
                Cbx.IsDropDownOpen = false;
                Cbx.Items.Filter   = null;
            }
            else
            {
                updating = true;
                try
                {
                    Cbx.IsDropDownOpen = true;
                    if (Cbx.SelectedIndex != 0)
                    {
                        Cbx.Items.Filter = item =>
                        {
                            if (Tbx.Text.Length <= 0)
                            {
                                return(true);
                            }
                            var val = item as IComboBoxProperties;

                            if (val != null)
                            {
                                return(val.Name != null && val.Name.ToLower().Contains(Tbx.Text.ToLower()));
                            }
                            return(true);
                        };
                    }
                    Tbx.Focus();
                }
                finally
                {
                    updating = false;
                }
            }
        }
コード例 #9
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);
                        }
                    }
                }
            }
        }
コード例 #10
0
 public SlLegalTextParser(Tbx tbxSource) : base(tbxSource)
 {
 }