private void Remove(HighlightInfoList list, DomElement element) { for (int iCount = list.Count - 1; iCount >= 0; iCount--) { HighlightInfo info = list[iCount]; bool delete = false; if (info.OwnerElement == element) { delete = true; } else if (info.OwnerElement != null && info.OwnerElement.IsParentOrSupParent(element)) { delete = true; } if (delete) { if (info.Range != null) { this.Document.InvalidateView(info.Range); } list.RemoveAt(iCount); } }//for }
/// <summary> /// 更新高亮度显示区域信息 /// </summary> internal void UpdateHighlightInfos() { _InnerHighlightInfos = null; if (this.HighlightRanges != null) { // 让用户指定的高亮度区域状态无效 foreach (HighlightInfo info in this.HighlightRanges) { if (info.Range != null) { info.Range.Invalidate(); } } } _HoverHighlightInfo = null; }
/// <summary> /// 获得高亮度显示信息对象 /// </summary> /// <param name="element"></param> /// <param name="args"></param> /// <returns></returns> private HighlightInfo GetHighlightInfo(DomElement element) { if (_HighlightBuffer == null) { _HighlightBuffer = new HighlightInfoList(); } else { // 在缓存区中逆向搜索 // 由于绘制文档内容都是按照顺序绘制文档内容 for (int iCount = _HighlightBuffer.Count - 1; iCount >= 0; iCount--) { if (_HighlightBuffer[iCount].Contains(element)) { return(_HighlightBuffer[iCount]); } } } DomContainerElement parent = element.Parent; while (parent != null) { HighlightInfoList infos = parent.GetHighlightInfos(); if (infos != null && infos.Count > 0) { foreach (HighlightInfo info in infos) { if (info.Contains(element)) { // 保存在缓存区中 _HighlightBuffer.Add(info); return(info); } } } parent = parent.Parent; } return(null); }