当前位置: 首页>>代码示例>>C#>>正文


C# IgnoreList.LoadWords方法代码示例

本文整理汇总了C#中IgnoreList.LoadWords方法的典型用法代码示例。如果您正苦于以下问题:C# IgnoreList.LoadWords方法的具体用法?C# IgnoreList.LoadWords怎么用?C# IgnoreList.LoadWords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IgnoreList的用法示例。


在下文中一共展示了IgnoreList.LoadWords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: backgroundWorker_DoWork

        /*-----------------------------------------------------------------------------------------*/
        /* Background worker                                                                       */
        /*-----------------------------------------------------------------------------------------*/
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            OxmlDocument doc = new OxmlDocument(this.GetOXML());
            Scope scope = new Scope(Properties.Settings.Default.ScopeSize);
            scope.MinimumTokenLength = Properties.Settings.Default.MinimumTokenLength;

            doc.PurgeShading();
            doc.PurgeBookmarks();

            // Load ignore list

            if (!String.IsNullOrEmpty(_ignoreListName))
            {
                IgnoreList IgnoreList = new IgnoreList(GetListPath(_ignoreListName));
                scope.IgnoreWords(IgnoreList.LoadWords(_language));
            }

            // Analyse document

            int blockCount = 0;
            float numberOfBlocks = (float)doc.GetNumberOfBlocks();
            var block = doc.GetNextOxmlBlock();

            while (block != null)
            {
                var tokens = block.GenerateOxmlTokens();
                foreach (var token in tokens)
                {
                    scope.FeedToken(token);
                }
                block = doc.GetNextOxmlBlock();

                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                int progress = (int)(++blockCount / numberOfBlocks * 100);
                worker.ReportProgress(progress);
            }

            // Add bookmarks to document

            var conflicts = scope.GetConflicts();
            foreach (var root in conflicts.Keys)
            {
                foreach (var conflict in conflicts[root])
                {
                    foreach (var token in conflict)
                    {
                        Debug.WriteLine(String.Format("Adding bookmark {0} for root '{1}' with text '{2}' and range {3}",
                            token.BookmarkName, token.Root, token.Text, token.Range.ToString()));
                        doc.BookmarkRange(token.Range, token.BookmarkName);
                    }
                }
            }

            // Update OXML only if it is valid

            string oxml = doc.ToOxml();

            if (oxml != null)
            {
                this._conflicts = conflicts;
                this.SetOXML(doc.ToOxml());
            }
            else
            {
                MessageBox.Show("An error occured while processing this document.", "Eagle Add-In");
            }
        }
开发者ID:cthiange,项目名称:eagle,代码行数:76,代码来源:ThisAddIn.cs


注:本文中的IgnoreList.LoadWords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。